// Validator Used on ChooseUser.asp
function Username_Validator(theForm)
{
/*
  if (theForm.username.value == "")
  {
    alert("Please enter a value for the \"User Name\" field.");
    theForm.username.focus();
    return (false);
  }

  if (theForm.username.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"User Name\" field.");
    theForm.username.focus();
    return (false);
  }

  if (theForm.username.value.length > 30)
  {
    alert("Please enter at most 30 characters in the \"User Name\" field.");
    theForm.username.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
  var checkStr = theForm.username.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and digit characters in the \"User Name\" field.");
    theForm.username.focus();
    return (false);
  }
*/
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";	
  if (theForm.password.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }

  if (theForm.password.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }

  if (theForm.password.value.length > 30)
  {
    alert("Please enter at most 30 characters in the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }

  
  var checkStr = theForm.password.value;
  var allValid = true;

  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }

  }
  if (!allValid)
  {
    alert("Please enter only letter and digit characters in the \"Password\" field.");
    theForm.password.focus();
    return (false);
  }


  if (theForm.confirmpass.value == "")
  {
    alert("Please enter a value for the \"Confirm Password\" field.");
    theForm.confirmpass.focus();
    return (false);
  }

  if (theForm.confirmpass.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"Confirm Password\" field.");
    theForm.confirmpass.focus();
    return (false);
  }

  if (theForm.confirmpass.value.length > 30)
  {
    alert("Please enter at most 30 characters in the \"Confirm Password\" field.");
    theForm.confirmpass.focus();
    return (false);
  }

  if (theForm.confirmpass.value != theForm.password.value )
    {
      alert("Please re-enter your password correctly.");
      theForm.confirmpass.focus();
      return (false);
  }

  
  var checkStr = theForm.confirmpass.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and digit characters in the \"Confirm Password\" field.");
    theForm.confirmpass.focus();
    return (false);
  }

	  return (true);
}
//
function switchScreen(screenId) {
	var screens = new Array();
	screens[0] = "profile";
	screens[1] = "membership";
	screens[2] = "renew";
	screens[3] = "upgrade";
	screens[4] = "purchase";
	screens[5] = "pendingOrder";
	screens[6] = "customerService";
	
	for(i=0; i<screens.length; i++) {
		if(screens[i] == screenId)
			document.getElementById(screens[i]).style.display = "block";
		else
			document.getElementById(screens[i]).style.display = "none";
	}

	// document.getElementById('screen').className=screenClass;
}
// Email Validator
function Validate_Email(theForm)
{


  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
  var checkStr = theForm.email.value;
  var allValid = true;
  var bDotPresent = false;
  var bRatePresent = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
      	break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }

    if (j == checkOK.length - 1  )
	    {
	    	bDotPresent = true;

	    }

	    if (j == checkOK.length -2 )
	    {
	    	bRatePresent = true;
	    }

  }

  if (!allValid)
  {
    alert("Please enter only letter, digit and \"-_@.\" characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if ((!bDotPresent) || (!bRatePresent) )

    {
    	alert ("Please enter a valid email address");
    	theForm.email.focus();
    	return(false);
    }

	  return (true);
}

// Open PopUp Window
function openPopUp (winURL, winName, winFeatures){
	newWindow = window.open(winURL,winName,winFeatures);
	newWindow.focus();
}

// New Gallery Window
function newGalleryWindow(galleryURL, galleryWinName, galleryFeatures){
	window.open(galleryURL, galleryWinName, galleryFeatures);
}

// Display WIndow
function displayWindow (url, width, height){
		var Win = window.open (url,"displayWindow",'width=' + width + ',height=' +
		height + ',resizable=0,scrollbars=yes,menubar=no,status=yes');
		Win.focus();
}

// Form Validator
function validateIt(theForm)
 {
  if(theForm.categoryid.value != '')
	{
	theForm.submit()
	}
  else
     	{
     	return false
     	}
 }

// Clear Text
function doClear(theText) {
	if (theText.value == theText.defaultValue) {
	  theText.value = ""
	}
}

// Change Password (I think)
function password(){
	self.name = "Parent_Window"; 
	window.open('/portal/user/send_pass.asp','EmailLoginInfo','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=350,height=180');
}

// Button Over and Active states for IE

//startList = function() {
	//if (document.all&&document.getElementById) {
		// alert("function triggered");
		//inputArray = document.getElementsByTagName("Input");
		//for (i=0; i<inputArray.length; i++) {
			// alert("inside loop");
			//node = inputArray[i];
			//if (node.className=="button") {
				//node.onmouseover=function() {
					//this.className+=" over";
					// alert("if triggered");
				//}
				//node.onmousedown=function() {
					//this.className=this.className.replace(" over", " active");
				//}
				//node.onmouseout=function() {
					//this.className=this.className.replace(" over", "");
					//this.className=this.className.replace(" active", "");
				//}
			//}
		//}
	//}
//}
//window.onload=startList;

// Table row Over state for IE

startList = function() {
	if (document.all&&document.getElementById) {
		//alert("function triggered");
		inputArray = document.getElementsByTagName("TR");
		for (i=0; i<inputArray.length; i++) {
			// alert("inside loop");
			node = inputArray[i];
			if (node.className=="Row") {
				node.onmouseover=function() {
					this.className+=" over";
					// alert("if triggered");
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
			if (node.className=="altRow") {
				node.onmouseover=function() {
					this.className+=" altOver";
					// alert("if triggered");
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" altOver", "");
				}
			}
		}
	}
}
window.onload=startList;

function openInviteAFriend(winname, wintitle)
{					
	var win = window.open(winname,wintitle,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=740,height=380');
	//win.focus();
}




// RATE AND REVIEW FUNCTIONS STARTS HERE

function RateReview_Validate(objForm)
{
	var blnOutReturnVal;
	var blnInReturnVal;	
	blnOutReturnVal = RateReview_TextCheck(objForm.strRateDesc, "Comments");
	//alert(blnOutReturnVal);
	if (blnOutReturnVal)
	{		
		
		blnInReturnVal = RateReview_RadioCheck(objForm, "rating");
		//alert("Radio exists: " + blnInReturnVal)
			if (blnInReturnVal)	
			{
				//alert ("blnInReturnVal is true for RadioCheck")
				return true;
			}
			else
			{
				//alert ("blnInReturnVal is False for RadioCheck")
				return false;		
			}
	}
	else
	{
		//alert ("blnOutReturnVal is False for TextCheck")
		return false;
	}
}
	

function RateReview_TextCheck(objTextBox, objName)
{
	if (objTextBox.value == "")
	{
		alert("Please Ensure that you have Entered data under " + objName )
		return false;
	}  
	else
	{
		//alert("TextCheck is Done and textbox do have contents....!")
		return true;
	}
}
	
	
function RateReview_RadioCheck(objForm, objName)
{	
	
	var i=0;
	var obj;
	var intCheckCount=0;
	
	for (i=0;i<objForm.elements.length;i++)
	{
		obj = objForm.elements[i];
		//alert("inside for")
		//alert(obj.checked)
		//if ((obj.type == "radio") && (obj.checked == true))
		if ((obj.type == "radio") && (obj.checked))
		{
			intCheckCount++;
			//alert("intCheckCount is " +intCheckCount);	
		}		
		//alert(intCheckCount)
		
	}
	
	if (intCheckCount>0)
	{
		//alert("Thank You for your Ratings...!");
		return true;
	}
	else
	{
		alert("Please ensure you have selected " + objName + ".");
		return false;
	}	
}


function ValidateBlog(objForm)
{
	if(objForm.description.value=="")
	{
		alert("Description should not blank");	
		objForm.description.focus();
		return false;
	}
	else
	{
		return true;
	}

}

function ValidateBlogComment(objForm)

{

//      if(objForm.strTitle.value=="")
//      {
//            alert("Title can not be left blank");
//            objForm.strTitle.focus();     
//            return false;
//      }

      if(objForm.description.value=="")

      {

          alert("The Body can not be left blank");

          objForm.description.focus();

          return false;

      }

      else

      {

            return true;

      }

 

}


// RATE AND REVIEW FUNCTIONS ENDS HERE

//window.onload= function() {
//	if(document.getElementById("loginForm") && document.all) {
		//document.getElementById("MainNav").onmouseover = function () {
		//	document.getElementById("loginForm").style.visibility = "hidden";
			// document.getElementById("SignUpLink").style.visibility = "hidden";
	//	};
		//document.getElementById("MainNav").onmouseout = function () {
		//	document.getElementById("loginForm").style.visibility = "visible";
			// document.getElementById("SignUpLink").style.visibility = "visible";
		//};
//	
//	if(document.getElementById("SecondaryNav") && document.all) {
//		document.getElementById("MainNav").onmouseover = function () {
//			document.getElementById("SecondaryNav").style.visibility = "hidden";
//		};
//		//document.getElementById("MainNav").onmouseout = function () {
		//	document.getElementById("SecondaryNav").style.visibility = "visible";
		//};

//	}
//}


function FrontPage_Form1_Validator(theForm)
{


  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789--_@.";
  var checkStr = theForm.email.value;
  var allValid = true;
  var bDotPresent = false;
  var bRatePresent = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
      	break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }

    if (j == checkOK.length - 1  )
	    {
	    	bDotPresent = true;

	    }

	    if (j == checkOK.length -2 )
	    {
	    	bRatePresent = true;
	    }

  }

  if (!allValid)
  {
    alert("Please enter only letter, digit and \"-_@.\" characters in the \"Email Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if ((!bDotPresent) || (!bRatePresent) )

    {
    	alert ("Please enter a valid email address");
    	theForm.email.focus();
    	return(false);
    }

	  return (true);
}

function ValidateSearchForm()
{
	var objradiobutton = document.frmFindA.chkListType;
	//alert(objradiobutton);
	var blnChk = "TRUE";
				
	for (i = 0; i<objradiobutton.length; i++)
	{
		
		//alert(objradiobutton[i].type);
		//alert(objradiobutton[i].checked);
		if(objradiobutton[i].type == "radio" && objradiobutton[i].checked)
		{
				//alert("Test");				
				blnChk = "TRUE";
				//alert("blnChk=" + blnChk);
				
				break;
				
				
							
		}	
		else
		{
			blnChk = "FALSE";
			//alert(blnChk);
			
		}	
		
	}
	if (document.frmFindA.txtKeyword.value != '')
		{
			if(trimString(document.frmFindA.txtKeyword.value)== '')
			{
				alert("Keyword can not be blank spaces");
				document.frmFindA.txtKeyword.focus();
				return false;
			}
		}
	/*if (document.frmFindA.txtZip.value != '')
	{
		if(trimString(document.frmFindA.txtZip.value)== '')
		{
				alert("Zip can not be blank spaces");
				document.frmFindA.txtZip.focus();
				return false;
			}
	}*/
	//alert(document.frmFindA.txtState.value);	
	//alert(document.frmFindA.txtKeyword.value);
	//alert(document.frmFindA.txtZip.value);
	//if((trimString(document.frmFindA.txtKeyword.value)== '' || document.frmFindA.txtKeyword.value == 'Key word' )&& (trimString(document.frmFindA.txtZip.value) == ''|| document.frmFindA.txtZip.value == 'zip')&& document.frmFindA.txtState.value == '' && document.frmFindA.strCountry.value == '' && blnChk == "FALSE")
	if((trimString(document.frmFindA.txtKeyword.value)== '' || document.frmFindA.txtKeyword.value == 'Key word' )&& document.frmFindA.txtState.value == '' && document.frmFindA.strCountry.value == '' && blnChk == "FALSE")
	{
		alert("Please select atleast a single criteria for search");
		return false;
	}
	else
		return true;	
	
}
function trimString(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	
	return sString;
}

function ValidateMembershipForm()
{
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";	
  if (document.frmMembership.firstname.value == "")
  {
    alert("Please enter a value for the firstname.");
    document.frmMembership.firstname.focus();
    return (false);
  }
  
  if (document.frmMembership.lastname.value == "")
  {
    alert("Please enter a value for the lastname.");
    document.frmMembership.lastname.focus();
    return (false);
  }
  
  if (document.frmMembership.email.value == "")
  {
    alert("Please enter a value for the email address.");
    document.frmMembership.email.focus();
    return (false);
  }
  else
  {
	Validate_Email(document.frmMembership)
	
  }
  if (document.frmMembership.zip.value == "")
  {
    alert("Please enter a value for the zip.\nIf you live in a country without a zip code, please enter 'None'");
    document.frmMembership.zip.focus();
    return (false);
  }
  if (document.frmMembership.password.value == "")
  {
    alert("Please enter a value for the password.");
    document.frmMembership.password.focus();
    return (false);
  }
  if (document.frmMembership.repassword.value == "")
  {
    alert("Please enter a value for the confirm password.");
    document.frmMembership.repassword.focus();
    return (false);
  }
  
   if (document.frmMembership.password.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Password\" field.");
    document.frmMembership.password.focus();
    return (false);
  }

  if (document.frmMembership.password.value.length > 30)
  {
    alert("Please enter at most 30 characters in the \"Password\" field.");
    document.frmMembership.password.focus();
    return (false);
  }

  
  var checkStr = document.frmMembership.password.value;
  var allValid = true;

  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }

  }
  if (!allValid)
  {
    alert("Please enter only letter and digit characters in the \"Password\" field.");
    document.frmMembership.password.focus();
    return (false);
  }

if ( document.frmMembership.repassword.value.length < 6)
  {
    alert("Please enter at least 6 characters in the \"Confirm Password\" field.");
     document.frmMembership.repassword.focus();
    return (false);
  }

  if ( document.frmMembership.repassword.value.length > 30)
  {
    alert("Please enter at most 30 characters in the \"Confirm Password\" field.");
     document.frmMembership.repassword.focus();
    return (false);
  }

  if ( document.frmMembership.repassword.value !=  document.frmMembership.password.value )
    {
      alert("Please re-enter your confirm password correctly.");
       document.frmMembership.repassword.focus();
      return (false);
  }

  
  var checkStr =  document.frmMembership.repassword.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and digit characters in the \"Confirm Password\" field.");
     document.frmMembership.repassword.focus();
    return (false);
  }
    return true;
}

function dropDown() {
	if(document.all&&document.getElementById&&document.getElementsByTagName) {
		if (document.getElementById("Mast-Nav")) {
			var x = document.getElementById("Mast-Nav").getElementsByTagName("li");
			for (var i=0; i<x.length; i++) {
				x[i].onmouseover = function() {
					if (this.timeout) {
						clearTimeout(this.timeout);
					}
					if (this.className != "hover") {
						this.className = "hover";
					}
				}
				x[i].onmouseout = function() {
					if(!this.getAttribute("id")) {
						this.setAttribute("id", "mnli-"+i);
						this.timeout = setTimeout("document.getElementById('mnli-"+i+"').className = document.getElementById('mnli-"+i+"').className.replace('hover', '')", 100);
					} else {
						this.timeout = setTimeout("document.getElementById('"+this.getAttribute('id')+"').className = document.getElementById('"+this.getAttribute('id')+"').className.replace('hover', '')", 100);
					}
				}
			}
		}
		if (document.getElementById("SLI")) {
			var y = document.getElementById("SLI");
			y.onmouseover = function() {
				if (this.timeout) {
					clearTimeout(this.timeout);
				}
				if (this.className != "hover") {
					this.className = "hover";
				}
			}
			y.onmouseout = function() {
				this.timeout = setTimeout("document.getElementById('SLI').className = ''", 100);
			}
		}
	}
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}
//-->
