
///////////////////////////////////////////////
//For Login validation
function confirmLogin(thisForm)
{
  //////////////////////

thisForm.USERNAME.value=trim(thisForm.USERNAME.value);

	if(isBlank(thisForm.USERNAME.value))
	{
		alert('Enter the Email address.');
		thisForm.USERNAME.focus();
		return (false);
	}
	else if(!isValidEmailIdNew(thisForm.USERNAME.value))
    {
      alert('Enter the valid Email address.');
      thisForm.USERNAME.focus();
      return(false);
    } 

   else if(isBlank(thisForm.PASSWORD.value))
   {  alert('Enter the Password.');
      thisForm.PASSWORD.focus();
	  return (false);
   }else{  	

	 return true;
   }
}

 
function isBlank(Str)
 {
   while(''+Str.charAt(0)==' ')
   Str=Str.substring(1,Str.length);
   while(''+Str.charAt(Str.length-1)==' ')
   Str=Str.substring(0,Str.length-1);
   if (Str == '')
   { return(true);
   }
   else
   { return(false);
   };
 }

function trim(Str)
 {
   if (!(isBlank(Str)))
   {
	  while(''+Str.charAt(0)==' ')
	  Str=Str.substring(1,Str.length);
	  while(''+Str.charAt(Str.length-1)==' ')
	  Str=Str.substring(0,Str.length-1);
	  return(Str);
   }
   else
   { return ('');
   };
 }

function isValidEmailIdNew(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var lbo=lstr-1;
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lbo){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lbo){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
		else if (hasSpecChar(str))
		{
		return(false) ;
		}

 		 return true					
	}

 function hasSpecChar(Str)
 {
	var alloweduser = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_@.-";

	 for(var count = 0; count < Str.length; count++)
	 {
		if(alloweduser.indexOf(Str.substring(count, count + 1)) == -1)
		{
		  return(true);
		}

	 };
	 return(false);
 }
 //////////////////////

 //cookie setting. for uid
var uid=getURLParam("uid");
if(uid!="") {
	Set_Cookie_new( 'idsSNSUID', uid, 0, '/', '', '' );

}


////////////////////////////////////////////// 
function Set_Cookie_new( name, value, expires, path, domain, secure )
{

var today = new Date();
today.setTime( today.getTime() );
if ( expires )
{
expires = 6 * 1000 * 60 * 60 * 24 * 30;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

////////////////////////////////////////////


 function getURLParam(strParamName)
{
	var strReturn = "";
	var strHref = window.location.href;
	if ( strHref.indexOf("?") > -1 ){
	var strQueryString = strHref.substr(strHref.indexOf("?"));
	var aQueryString = strQueryString.split("&");
	for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
	if ( 
	aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
	var aParam = aQueryString[iParam].split("=");
	strReturn = aParam[1];
	break;
	}
	}
	}
	return unescape(strReturn);
}


