//This Function is used to open the pop up window
function openPopUp(url, width, height) {
	var windowAttributes = "status=no,toobar=no,menubar=no,scrollbars=yes,resizable=yes";
	if ( navigator.appName == "Netscape" ) {
	    windowAttributes += ",height=" + height + ",width=" + width;
	    if (navigator.appVersion.charAt(0) >= 4) {
	        windowAttributes += ",screenX=";
	        windowAttributes += ((screen.availWidth)/2)- (width/2);
	        windowAttributes += ",screenY=";
	        windowAttributes += ((screen.availHeight)/2)- (height/2);
	    }
	} 
	else if ( navigator.appName == "Microsoft Internet Explorer" ) {
	    windowAttributes += ",height=" + height + ",width=" + width;
	    if (navigator.appVersion.charAt(0) >= 4) {
	        windowAttributes += ",left=";
	        windowAttributes += ((screen.availWidth)/2)- (width/2);
	        windowAttributes += ",top=";
	        windowAttributes += ((screen.availHeight)/2)- (height/2);
	    }
	} 
	else {
	    windowAttributes += ",height=" + height + ",width=" + width;
	}
	newWindow = window.open(url, "", windowAttributes);

}

function ChkZipCode(Str){
//this method has used regular expression to check zip code
//here instead of quates use '/' in the start and end of expression.
	var regexp=/^\d{5,10}$/;
	var a=Str.match(regexp);
	if(a==null)return true; else return false;
}

function IsInvalidEmailCharacter(sText)
{
   var ValidChars = "0123456789.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_@.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }



function ChkEmail(Str){
	if (IsInvalidEmailCharacter(Str)==false)
	{
		return true;
	}
	var regexp=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	var a=Str.match(regexp);
	if(a==null)return true; else return false;
}	

function ChkIP(Str){
	var regexp=/^\d{1,3}$/;
	var a=Str.match(regexp);
	//alert(a);
	if(a==null)return true; else return false;
}	

//this function goes back to the last page
function GoBack(){
	window.history.back();
}

function SetCookieValue(CookieName,CookieValue){
	var ExpiredCookie=new Date();
	var OneYearFromNow=ExpiredCookie.getTime()+(365*24*60*60*1000);
	ExpiredCookie.setTime(OneYearFromNow);
	SetCookie(CookieName,CookieValue,ExpiredCookie);
}

function GetCookieVal(CookieName){
	return GetCookie(CookieName);
}

//This is General function to show or hide the object provided to it.
function ShowHideContent(objDiv){
	if(objDiv.style.display==''){
		objDiv.style.display='none';
	}else{
		objDiv.style.display='';
	}
}

//Trim function
function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

