function checkAll(obj1,obj2)
{
	var login=document.getElementById(obj1);
	var pwd = document.getElementById(obj2);
	
	if (checkEmpty(login)==false && checkEmpty(pwd)==false)
	{
		login.focus();
		window.alert("-Please enter Email \n-Please enter Password");
		
		return false;
	}	
	/*else if ((checkEmpty(pwd)==false) && (!EvaluateMail(login)==false))
	{
		window.alert("-Please enter a valid e-mail address \n-Please enter Password");
		return false;
	}*/
	else if (checkEmpty(login)==false)	
	{
		login.focus();
		alert("-Please enter Email");
		return false;
	}
	else if (!EvaluateMail(login.value))
	{
		login.focus();
		login.select();
		alert("-Please enter a valid e-mail address");
		return false;
	}	
	else if (checkEmpty(pwd)==false)
	{
		pwd.focus();
		alert("-Please enter Password");
		return false;
	}
	
	return true;
}

function newUser(objEmail,ObjPasswd,ObjConfPasswd)
{
	var email=document.getElementById(objEmail);
	var passwd=document.getElementById(ObjPasswd);
	var confpasswd=document.getElementById(ObjConfPasswd);
	
	if(checkEmpty(email)==false && checkEmpty(passwd)==false && checkEmpty(confpasswd)==false)
	{
		email.focus();
		window.alert("-Please enter Email \n-Please enter Password \n-Please enter Confirmation Password"); 
		return false;
	}
	/*else if ((checkEmpty(passwd)==false) && (EvaluateMail(email.value)==false))
	{
		window.alert("-Please enter a valid e-mail address \n-Please enter Password");
		return false;
	}*/
	else if(checkEmpty(email)==false)
	{
		email.focus();
		window.alert("-Please enter e-mail address");
		return false;
	}	
	else if(!EvaluateMail(email.value))
	{
		email.focus();
		email.select();
		window.alert("-Please enter a valid e-mail address");
		return false;
	}
	else if(checkEmpty(passwd)==false)
	{
		passwd.focus();
		window.alert("-Please enter Password");
		return false;
	}
	else if(passwd.value.length < 6)
	{		
		passwd.focus();
		window.alert("Password Length should be minimum of 6 characters");
		return false;
	}
	else if(checkEmpty(confpasswd)==false)
	{
		confpasswd.focus();
		window.alert("-Please enter Confirmation Password");
		return false;
	}
	else if(confpasswd.value.length < 6)
	{		
		confpasswd.focus();
		window.alert("Confirmation Password Length should be minimum of 6 characters");
		return false;
	}
	else if(passwd.value != confpasswd.value)
	{
		confpasswd.focus();
		window.alert("-Password and Confirm password do not match. \n Please re-enter.");
		return false;
	}
	return true;
}

function FocusatStart(objtxtLogin)
{
	if (document.getElementById(objtxtLogin)!=null)
	{
		var login=document.getElementById(objtxtLogin);
		focus(login);
	}
}

//FromValidation.js

function focus(ctrl)
{
	document.getElementById(ctrl.id).focus();
}

function Fixfocus(objPwdMessage,objMsgLoginFailed,objSubmit,event) 
{
	var isNS4 = (navigator.appName=="Netscape")?1:0;
	if(document.getElementById(objPwdMessage) != null)
		document.getElementById(objPwdMessage).innerText="";
	if(document.getElementById(objMsgLoginFailed) != null)
		document.getElementById(objMsgLoginFailed).innerText="";
	
	if(!isNS4)
	{
	  
		if (event.keyCode==13)
		{
			document.getElementById(objSubmit).focus();
		}
	}
	else
	{
	  
		if (event.which==13)
		{			
			document.getElementById(objSubmit).focus();
		}
	}
}

function ClearLabel(objPwdMessage,objMsgLoginFailed,objLogin,event)
{	
	var isNS4 = (navigator.appName=="Netscape")?1:0;
	if(document.getElementById(objPwdMessage) != null)
		document.getElementById(objPwdMessage).innerText="";
	if(document.getElementById(objMsgLoginFailed) != null)
		document.getElementById(objMsgLoginFailed).innerText="";
	
	//alert(isNS4);
	
	if(!isNS4)
	{
		if (event.keyCode==13)
		{
			document.getElementById(objLogin).focus();
		}
	}
	else
	{
		if (event.which ==13)
		{
			document.getElementById(objLogin).focus();
		}
	}
}

function ClearFields(objPwdMessage)
{
	//document.getElementById("lblPwdMessage").innerHTML="";
	if (document.getElementById(objPwdMessage)!=null)
		document.getElementById(objPwdMessage).innerText="";
}

function register(objEmail,ObjPasswd,ObjConfPasswd,objForm)
{
	var strFormName;
	if (newUser(objEmail,ObjPasswd,ObjConfPasswd)==true)
	{
	    if(document.getElementById('hdnLogin') != null)
			document.getElementById('hdnLogin').value='register';
		//alert(document.getElementById('hdnLogin').value);
		strFormName=document.getElementById(objForm);
		//alert(strFormName);
		strFormName.submit();
	}
}

function login(obj1,obj2,objForm)
{
	var strFormName;
	if (checkAll(obj1,obj2)==true)
	{
	    if(document.getElementById('hdnLogin') != null)
			document.getElementById('hdnLogin').value='login';
		//alert(document.getElementById('hdnLogin').value);
		strFormName=document.getElementById(objForm);
		//alert(strFormName);
		strFormName.submit();
	}
}

function openMail()
{
	window.open("http://www.hotmail.com");
}

function changePassword(objOldPasswd,ObjPasswd,ObjConfPasswd)
{
	var oldpasswd=document.getElementById(objOldPasswd);
	var newpasswd=document.getElementById(ObjPasswd);
	var confpasswd=document.getElementById(ObjConfPasswd);
	
	if(checkEmpty(oldpasswd)==false && checkEmpty(newpasswd)==false && checkEmpty(confpasswd)==false)
	{
		oldpasswd.focus();
		window.alert("-Please enter Old Password \n-Please enter New Password \n-Please enter Confirmation Password"); 
		return false;
	}
	else if(checkEmpty(oldpasswd)==false)
	{
		oldpasswd.focus();
		window.alert("-Please enter Old Password");
		return false;
	}
	else if(oldpasswd.value.length < 6 || oldpasswd.value.length >15)
	{		
		oldpasswd.focus();
		window.alert("Password Length must be between 6 and 15 characters long");
		return false;
	}
	else if(checkEmpty(newpasswd)==false)
	{
		newpasswd.focus();
		window.alert("-Please enter New Password");
		return false;
	}
	else if(newpasswd.value.length < 6 || newpasswd.value.length >15)
	{		
		newpasswd.focus();
		window.alert("Password Length must be between 6 and 15 characters long");
		return false;
	}
	else if(oldpasswd.value==newpasswd.value)
	{
		newpasswd.focus();
		window.alert("-Old Password and New password are the same. \n Please re-enter.");
		return false;		
	}
	else if(checkEmpty(confpasswd)==false)
	{
		confpasswd.focus();
		window.alert("-Please enter Confirmation Password");
		return false;
	}
	else if(confpasswd.value.length < 6 || confpasswd.value.length >15)
	{		
		confpasswd.focus();
		window.alert("Password Length must be between 6 and 15 characters long");
		return false;
	}
	else if(newpasswd.value != confpasswd.value)
	{
		confpasswd.focus();
		window.alert("-Password and Confirm password do not match. \n Please re-enter.");
		return false;
	}
	return true;
}

function checkPassword(objOldPasswd,ObjPasswd,ObjConfPasswd,objForm)
{
	var strFormName;
	if (changePassword(objOldPasswd,ObjPasswd,ObjConfPasswd)==true)
	{
		document.getElementById('hdnChangePassword').value='changed';
		//alert(document.getElementById('hdnLogin').value);
		strFormName=document.getElementById(objForm);
		//alert(strFormName);
		strFormName.submit();
	}
}

//FUNCTION TO FILL THE REGISTRATION FIELDS FROM CUSTOMERHOMEPAGE
function FillRegisterFields(objEmail,ObjPassword,objConfirmPassword, objHdnEmail, objHdnPassword)
{
	var Email = document.getElementById(objEmail);
	var Password = document.getElementById(ObjPassword);
	var ConfirmPassword = document.getElementById(objConfirmPassword);
	var HomePageEmail = document.getElementById(objHdnEmail);
	var HomePagePassword = document.getElementById(objHdnPassword);
	if(HomePageEmail != null && HomePagePassword != null && HomePageEmail.value != null && HomePagePassword.value != null && HomePageEmail.value != "" && HomePagePassword.value != "")
	{
		Email.value = HomePageEmail.value;
		Password.value = HomePagePassword.value;
		ConfirmPassword.focus();
		HomePageEmail.value = "";
		HomePagePassword.value = "";
	}
	
}



var ModalDialogWindow;
var ModalDialogInterval;
var ModalDialog = new Object;

ModalDialog.value = '';
ModalDialog.eventhandler = '';

function ModalDialogMaintainFocus()
{
try
{
	if (ModalDialogWindow.closed)
	{
		window.clearInterval(ModalDialogInterval);
		eval(ModalDialog.eventhandler);
		return;
	}
	ModalDialogWindow.focus();
}
catch (everything) {   }
}

function ModalDialogRemoveWatch()
{
	ModalDialog.value = '';
	ModalDialog.eventhandler = '';
}

function CloseForm(strResult,objFrm)
{
 
  if(document.getElementById('hdnRoleFor') != null )
  {
	if(document.getElementById('hdnRoleFor').value != 'lost')
    {
      if(strResult != 'CANCEL')
       {
		document.getElementById('hdnRoleFor').value = strResult;
		document.getElementById(objFrm).submit(); 
	   }
	  else
	   {
	   document.getElementById('loginpanel').className = 'logboxinnerh6c';
	   document.getElementById('rolepanel').className = 'hide';
	   return false;
	   }	    	
     }
     else
      {
        var role="";
        if(strResult == 'AFFAGENT')
           role="agt";
        else if(strResult == 'AFFILIATE')   
          role="aff";
        else if(strResult == 'CANCEL')     
         {
           document.getElementById('loginpanel').className = 'logboxinnerh6c';
		   document.getElementById('rolepanel').className = 'hide';
		   document.getElementById('hdnRoleFor').value ="";
           return false;
         } 
        document.getElementById('loginpanel').className = 'logboxinnerh6c';
		document.getElementById('rolepanel').className = 'hide';
		document.getElementById('hdnRoleFor').value=""; 
        LostPassword(role,'hdnSiteUrl');     
      }
   }
}

function YesNoCancel(BodyText,EventHandler,objResult, objForm)
{
	var Buttons='';
	Buttons = '<a  class="affiliate" href=javascript:CloseForm("AFFILIATE","'+ objResult +'","'+ objForm + '");></a>  ';
	Buttons += '<a  class="affiliateagent" href=javascript:CloseForm("AFFAGENT","'+ objResult +'","'+ objForm + '");></a>  ';
	Buttons += '<a class="cancel" href=javascript:CloseForm("CANCEL","'+ objResult +'","'+ objForm + '");></a>  ';
	ModalDialogShow("SelectRole",BodyText,Buttons,EventHandler);
}

function YesNoCancelReturnMethod()
{
	ModalDialogRemoveWatch();
}

function loginForAffiliate(obj1,obj2,objForm,objResult)
{
	document.getElementById('hdnLogin').value='login';
	if (checkAll(obj1,obj2)==true)
	{
		if(document.getElementById('loginpanel') != null )
		 {
		   document.getElementById('loginpanel').className = 'hide';
		   if(document.getElementById('rolepanel') != null )
			document.getElementById('rolepanel').className = 'rolepanel';
		 }
	}
}



function GoToLostPassword(objSaver,objAdvertiser,objAffiliate,objResult)
{
	var Saver = document.getElementById(objSaver);
	var Advertiser = document.getElementById(objAdvertiser);
	var Affiliate = document.getElementById(objAffiliate);
	
	if(Saver.checked)
	{
		LostPassword('cust');		
	}
	if(Advertiser.checked)
	{
		LostPassword('adv');
	}
	if(Affiliate.checked)
	{
		AffiliateLostPassword();
	}
}

function AffiliateLostPassword()
{
	if(document.getElementById('loginpanel') != null )
		 {
		   document.getElementById('loginpanel').className = 'hide';
		   if(document.getElementById('rolepanel') != null )
				document.getElementById('rolepanel').className = 'rolepanel';
		   document.getElementById('hdnRoleFor').value ='lost'; 	
		 }
	
}