/******************************************************************************

/*                                                                            

/*   Copyright (C) 2006  INTERBERRY SOLUTIONS                                 

/*   http://www.interberry.com                                                

/*                                                                            

/*   Date		:  24/06/2006

/*   Project	:  fsboz.com

/*   Release	:  1.0

/*   Comment	: script 

/* 

/*                                                                 

/******************************************************************************/

            var http_request = false;

			function searchzip()

			{

				if(trimSpaces(document.form2.listerCity.value)=="" && trimSpaces(document.form2.listerzip.value)=="")

				{

					alert("Please enter the city or zip");

					

					document.form2.listerCity.focus();

					return false;	

				}	

			}

			function checkPass()

			{

				if(document.frmpsd.oldpassword.value=="")

				{

					alert("Please enter your old passsword");

					document.frmpsd.oldpassword.value=="";

					document.frmpsd.oldpassword.focus();

					return false;	

				}	

				if(document.frmpsd.newpassword.value=="")

				{

					alert("Please enter your new passsword");

					document.frmpsd.newpassword.value=="";

					document.frmpsd.newpassword.focus();

					return false;	

				}	

				if(document.frmpsd.confirmpassword.value=="")

				{

					alert("Please confirm your new passsword");

					document.frmpsd.confirmpassword.value=="";

					document.frmpsd.confirmpassword.focus();

					return false;	

				}

				if(document.frmpsd.newpassword.value!=document.frmpsd.confirmpassword.value)

				{

					alert("Mismatch in password");

					document.frmpsd.confirmpassword.value=="";

					document.frmpsd.confirmpassword.focus();

					return false;

				}	

			}	

            function makeRequest(validatefields,fname,url,tablename,cVariable,dVariables) {

					

					getfields  =new Array;

					getvariable = new Array;

					displayvar=new Array;

					

				 	getfields = validatefields.split('|');

				 	disfields= dVariables.split('|');

				for (count=0; count<getfields.length; count++)

				{

			

					getvariable =	getfields[count].split('`');

					dispvariable=   disfields[count];

				

					//alert(getvariable);

					if(getvariable[1]=="text")

					{

							

					

						if(trimSpaces(eval("document."+fname+"."+getvariable[0]+".value"))=="")

						{

						

							alert("Please Enter "+dispvariable+ " Correctly");

							eval("document."+fname+"."+getvariable[0]+".focus()");

							return false;

						}

					}

					else if(getvariable[1]=="integer")

					{

						if(trimSpaces(eval("document."+fname+"."+getvariable[0]+".value"))=="")

						{

							alert("Please Enter "+dispvariable+ " Correctly");

							eval("document."+fname+"."+getvariable[0]+".focus()");

							return false;

						}

						else if(!checkAllowedChars(eval("document."+fname+"."+getvariable[0]+".value"), "N.,"))

						{

							alert("Please Enter "+dispvariable+ " Correctly");

							eval("document."+fname+"."+getvariable[0]+".focus()");

							return false;

						}

					}

					else if(getvariable[1]=="email")

					{

						if(!checkEmail(eval("document."+fname+"."+getvariable[0]+".value")))

						{

							//alert("Please Enter a valid email");

							eval("document."+fname+"."+getvariable[0]+".focus()");

							return false;

						}

					}

					else if(getvariable[1]=="zip")

					{		

			

					  var str = trimSpaces(eval("document."+fname+"."+getvariable[0]+".value"));

							if(str.length<5 || str.length>7)

						{ 

							alert("Please Enter "+dispvariable+ " Correctly");

							eval("document."+fname+"."+getvariable[0]+".focus()");

							return false;

						}

					}

						

				}

				if(tablename)

				{

					

                http_request = false;

				fieldvalue = eval("document."+fname+"."+cVariable+".value");

                if (window.XMLHttpRequest) { // Mozilla, Safari,...

                    http_request = new XMLHttpRequest();

                    if (http_request.overrideMimeType) {

                        http_request.overrideMimeType('text/xml');

                    }

                } else if (window.ActiveXObject) { // IE

                    try {

                        http_request = new ActiveXObject("Msxml2.XMLHTTP");

                    } catch (e) {

                        try {

                        http_request = new ActiveXObject("Microsoft.XMLHTTP");

                        } catch (e) {}

                    }

                }



                if (!http_request) {

                    alert('Giving up :( Cannot create an XMLHTTP instance');

                }

				

				url = url+"?tablename="+tablename+"&field="+cVariable+"&fieldvalue="+fieldvalue+"&formname="+fname;

			

				  http_request.onreadystatechange =  alertContents;

             	  http_request.open('GET', url, true);

                  http_request.send(null);

				}

            }



            function alertContents() {

				getres = new Array();

                if (http_request.readyState == 4) {

                    if (http_request.status == 200) {

						getres = http_request.responseText.split('/');

							if((getres[0]>0))

							{

								if(getres[2]){

									alert(getres[2]);

								}

								else

								{

                       			 alert("This user name already exists");

								}

								 return false;

							}

							else

							{

								//alert(getres[0]);

								//alert("document."+getres[1]+"submit()");

							eval("document."+getres[1]+".submit()");	

							//document.form1.submit();

							}

                       		

                    } else {

                        alert('There was a problem with the request.');

                    }

                }



            }

			

			/////////////////////////////////////////////////////////////////////////////////////////

// Removes the leading and trailing spaces in a strings and returns the trimmed string

/////////////////////////////////////////////////////////////////////////////////////////

function trimSpaces(stringValue) {

	// Checks the first occurance of spaces and removes them

	for(i = 0; i < stringValue.length; i++) {

		if(stringValue.charAt(i) != " ") {

			break;

		}

	}

	if(i > 0) {

		stringValue = stringValue.substring(i);

	}

	

	// Checks the last occurance of spaces and removes them

	strLength = stringValue.length - 1;

	for(i = strLength; i >= 0; i--) {

		if(stringValue.charAt(i) != " ") {

			break;

		}

	}

	if(i < strLength) {

		stringValue = stringValue.substring(0, i + 1);

	}

	

	// Returns the string after removing leading and trailing spaces.

	return stringValue;

}





/////////////////////////////////////////////////////////////////////////////////////////

// Check whether a string contain permitted characters only

/////////////////////////////////////////////////////////////////////////////////////////

function checkAllowedChars(strToCheck, allowedChars)

{

     var acLen     = allowedChars.length;

     var stcLen     = strToCheck.length;

     strToCheck     = strToCheck.toLowerCase();

     var i;

     var j;

     var rightCount = 0;

     for(i = 0; i < acLen; i++)

     {

          switch(allowedChars.charAt(i))

          {

          case 'A':

               for(j = 0; j< stcLen; j++)

               {

                    rightCount += strToCheck.charAt(j) >= 'a' && strToCheck.charAt(j) <= 'z';

               }

               break;

          case 'N':

               for(j = 0; j< stcLen; j++)

               {

                    rightCount += strToCheck.charAt(j) >= '0' && strToCheck.charAt(j) <= '9';

					//rightCount += strToCheck.charAt(j) = '.';

               }

               break;

          default:

               for(j = -1; -1 != (j = strToCheck.indexOf(allowedChars.charAt(i), j + 1)); rightCount++);

               break;

          }

     }

     if(rightCount == stcLen)

     {

          return true;

     }

     return false;

}





/////////////////////////////////////////////////////////////////////////////////////////

// Checks whether a string is a valid email address.

/////////////////////////////////////////////////////////////////////////////////////////

function checkEmail(emailString) {

	splitVal = emailString.split('@');

	

	if(splitVal.length <= 1) {

		alert("Please enter a valid email address");

		return false;

	}

	if(splitVal[0].length <= 0 || splitVal[1].length <= 0) {

		alert("Please enter a valid email address");

		return false;

	}

	

	splitDomain = splitVal[1].split('.');

	if(splitDomain.length <= 1) {

		alert("Please enter a valid email address");

		return false;

	}

	if(splitDomain[0].length <= 0 || splitDomain[1].length <= 1) {

		alert("Please enter a valid email address");

		return false;

	}

	return true;

}





function popup2(mylink, windowname)

	{

	if (! window.focus)return true;

	var href;

	if (typeof(mylink) == 'string')

	   href=mylink;

	else

	 {

	   href=mylink.href;

	   window.open(href, windowname, 'width=500,height=700,scrollbars=yes top=50 left=200');

	   return false;

	 }  

	}

	function popup4(mylink, windowname)

	{

	if (! window.focus)return true;

	var href;

	if (typeof(mylink) == 'string')

	   href=mylink;

	else

	 {

	   href=mylink.href;

	   window.open(href, windowname, 'width=600,height=700,scrollbars=yes top=50 left=200');

	   return false;

	 }  

	}

	function popup3(mylink, windowname)

	{

	if (! window.focus)return true;

	var href;

	if (typeof(mylink) == 'string')

	   href=mylink;

	else

	 {

	   href=mylink.href;

	   window.open(href, windowname, 'width=600,height=600,scrollbars=yes top=50 left=200');

	   return false;

	 }  

	}

	

	function extrapop(mylink, windowname)

	{

	if (! window.focus)return true;

	var href;

	if (typeof(mylink) == 'string')

	   href=mylink;

	else

	 {

	   href=mylink.href;

	   window.open(href, windowname, 'width=300,height=400,scrollbars=yes top=50 left=200');

	   return false;

	 }  

	}

	

	function notepop(mylink, windowname)

	{

	if (! window.focus)return true;

	var href;

	if (typeof(mylink) == 'string')

	   href=mylink;

	else

	 {

	   href=mylink.href;

	   window.open(href, windowname, 'width=500,height=400,scrollbars=yes top=50 left=200');

	   return false;

	 }  

	}

	function subcheck()

	{

		if(document.frm_forgot.txtemail.value=="")

		{

			alert("Please enter your email");	

			return false;

		}

		if(!checkEmail(eval("document.frm_forgot.txtemail.value")))

		{

			//alert("Please Enter a valid email");

			return false;

		}		

	}

	function listcheck()

	{

		

		if(document.frmlist.listmail.value=="")

		{

			alert("Please enter your email");	

			return false;

		}

		if(!checkEmail(eval("document.frmlist.listmail.value")))

		{

			//alert("Please Enter a valid email");

			return false;

		}

		if(document.frmlist.elist.checked == false)

		{

			alert("Please subscribe or unsubscribe");

			return false;

		}			

	}

	function subcheck1()

	{

		if(document.frm_mail.txtsub.value=="")

		{

			rt = confirm("Are you sure sending mail without subject?");	

			if(rt==false){

				return false;

			}

		}

				

	}

	function checkpass()

	{

		if(document.frmreg.upassword.value != document.frmreg.conpassword.value)

		{

			alert("Please confirm your password");

			document.frmreg.upassword.value="";

			document.frmreg.conpassword.value="";

			document.frmreg.upassword.focus();

			return false;

		}	

	}	

	function checklevel()

	{

		

			itemLength = document.form1.elements["lister_level"].length;

		if(itemLength > 0) {

			for(newItems = 0; newItems < itemLength; newItems ++) {

				itemValue = trimSpaces(document.form1.elements["lister_level"][newItems].value);

				if(document.form1.elements["lister_level"][newItems].checked==true) {

					var anyContents = true;

				}

			}

		}

		else {

			itemValue = trimSpaces(document.form1.elements["lister_level"].value);

			if(ocument.form1.lister_level.checked==true) {

				var anyContents = true;

			}

		}

	

	

	if(!anyContents) {

		alert("Please select one Level");

		return false;

	}

	

	}

	function checkservicelevel()

	{

		

			itemLength = document.form1.elements["service_level"].length;

		if(itemLength > 0) {

			for(newItems = 0; newItems < itemLength; newItems ++) {

				itemValue = trimSpaces(document.form1.elements["service_level"][newItems].value);

				if(document.form1.elements["service_level"][newItems].checked==true) {

					var anyContents = true;

				}

			}

		}

		else {

			itemValue = trimSpaces(document.form1.elements["service_level"].value);

			if(document.form1.service_level.checked==true) {

				var anyContents = true;

			}

		}

	

	

	if(!anyContents) {

		alert("Please select one Level");

		return false;

	}

	

	}

	function errorm()

	{

	alert("You have already logged in an account other than lister,please logout and try again!");	

	}

	function errorm1()

	{

	alert("You have already logged in an account other than Service,please logout and try again!");	

	}

	

	function popup(mylink, windowname)

	{

	if (! window.focus)return true;

	var href;

	if (typeof(mylink) == 'string')

	   href=mylink;

	else

	 {

	   href=mylink.href;

	   window.open(href, windowname, 'width=500,height=600,scrollbars=no top=50 left=200');

	   return false;

	 }  

	}

	function chkfrnd()

	{

		if(document.frmfrn.txtmail.value=="")

		{

			alert("Please enter your email");	

			return false;

		}

		if(!checkEmail(eval("document.frmfrn.txtmail.value")))

		{

			//alert("Please Enter a valid email");

			return false;

		}

		if(document.frmfrn.txtfmail.value=="")

		{

			alert("Please enter email");	

			return false;

		}

		if(!checkEmail(eval("document.frmfrn.txtfmail.value")))

		{

			//alert("Please Enter a valid email");

			return false;

		}

		

		if(document.frmfrn.seccode.value=="")

		{

			alert("Please enter security code");	

			return false;

		}			

	}
	
	function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}