function EvaluateMail(ctrl)
{
	var rx = new RegExp("([\ ]*)([0-9a-zA-Z._]([-.\w]*[0-9a-zA-Z._])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})([\ ]*)$");
	var matches = rx.exec(ctrl);
	return (matches != null && ctrl == matches[0]);
}

function EvaluateName(ctrl)
{	
	var rx = new RegExp("([\ ]*)([a-zA-Z]([-.\w]*[a-zA-Z])*)([\ ]*)$");
	var matches = rx.exec(ctrl);
	return (matches != null && ctrl == matches[0]); 
}

function EvaluatePhone(ctrl)
{	
	var rx = new RegExp("([\ ]*)(^([ +\(\)]|[0-9])*.{5,20})([\ ]*)$");
	var matches = rx.exec(ctrl);
	return (matches != null && ctrl == matches[0]); 
}

function EvaluateExtension(ctrl)
{	
	var rx = new RegExp("([\ ]*)(^([ +\(\)]|[0-9])*)([\ ]*)$");
	var matches = rx.exec(ctrl);
	return (matches != null && ctrl == matches[0]); 
}

function checkEmpty(ctrl)
{
	if (ctrl !=null && ctrl.value == "")
	{
		return false;
	}
}

//FUNCTION TO CHECK FOR THE BROWSER AND DISPLAY ALERT MSG IF ITS OTHER THAN IE
function CheckBrowser()
{
	var agt = navigator.userAgent.toLowerCase();
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

	if (is_ie != true)
	{
		window.open('../Includes/BrowserMessage.htm','BrowserMessage','height=200,width=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,left=200,top=100');
	}
}

//FUNCTION TO CHANGE BUTTON APPEARANCE
function ChangeButton(ctrl,newclass)
{
	ctrl.className = newclass;
}		
//FUNCTION TO CHANGE BUTTON APPEARANCE

function LostPassword(strRole,objSiteUrl)
{
	var SiteUrl = document.getElementById(objSiteUrl);
	window.open(SiteUrl.value + 'login/forgotpassword.aspx?user='+strRole,'LostPassword','height=600,width=800,status=no,toolbar=no,menubar=no,location=no,resizable=yes');
}

function ShowTerms()
{
	window.open('../Advertiser/TermsCondtions.aspx','Terms','height=550,width=620,status=no,toolbar=no,menubar=no,location=no,left=100,top=25,scrollbars=yes');
}

function ShowTermsAdv()
{
	window.open('../Advertiser/AdvertiserTermsCondtions.aspx','Terms','height=550,width=620,status=no,toolbar=no,menubar=no,location=no,left=100,top=25,scrollbars=yes');
}

function ShowTermsAff()
{
	window.open('../Affiliate/AffiliateTermsCondtions.aspx','Terms','height=550,width=620,status=no,toolbar=no,menubar=no,location=no,left=100,top=25,scrollbars=yes');
}


function ShowPrivacy()
{
	window.open('../Advertiser/PrivacyPolicy.aspx','Terms','height=570,width=620,status=no,toolbar=no,menubar=no,location=no,left=100,top=25,scrollbars=yes');
}

//For Terms and Conditions page
function Accept(objForm,objChk)
{
	var strFormName;
	strFormName=document.getElementById(objForm);
	if(document.getElementById(objChk)!=null)
	{
		if (document.getElementById(objChk).checked==true)
		{
			document.getElementById('hdnAccept').value='accept';
			//alert(document.getElementById('hdnAccept').value);
			strFormName.submit();
			return true;
		}
		else
		{
			return false;
		}
	}
}

function Reject(objChk)
{
	if (document.getElementById(objChk).checked==false)
	{
		if (confirm("Registration will terminate unless you accept the Terms and Conditions.\nPlease click on OK to terminate the registration. \nPlease click on CANCEL to continue registration.")==true)
		{					
			window.location.href="../Login/CustomerLogin.aspx";
		}
	}
}

function Print()
{
	window.print();
}






function changeAcceptClass(objChk,disabledclass,ctrl,enableclass,ctrlDecline,enabledecline,disabledecline)
{
	if(objChk=="chkAccept")
	{
		if(document.getElementById(objChk)!=null)
		{	
			var TopCheck = document.getElementById("chkAcceptTop");
			if (document.getElementById(objChk).checked==true)
			{
				TopCheck.checked = true;
				document.getElementById("btnAccepttop").className=enableclass;
				document.getElementById("btnDeclinetop").className=disabledecline;
				
				document.getElementById(ctrl).className=enableclass;
				document.getElementById(ctrlDecline).className=disabledecline;
				
				
			}
			else
			{	
				TopCheck.checked = false;
				document.getElementById("btnAccepttop").className=disabledclass;
				document.getElementById("btnDeclinetop").className=enabledecline;
			
				document.getElementById(ctrl).className=disabledclass;
				document.getElementById(ctrlDecline).className=enabledecline;
				
			}
		}
	}
	else
	{
		if(document.getElementById(objChk)!=null)
		{
			var BottomCheck = document.getElementById("chkAccept");
			if (document.getElementById(objChk).checked==true)
			{	
				BottomCheck.checked = true;
				document.getElementById("btnAccept").className=enableclass;
				document.getElementById("btnDecline").className=disabledecline;
				
				document.getElementById(ctrl).className=enableclass;
				document.getElementById(ctrlDecline).className=disabledecline;
				
			}
			else
			{	
				BottomCheck.checked = false;
				document.getElementById("btnAccept").className=disabledclass;
				document.getElementById("btnDecline").className=enabledecline;
			
				document.getElementById(ctrl).className=disabledclass;
				document.getElementById(ctrlDecline).className=enabledecline;
				
			}
		}
	}
}


function GotoLocation(strUrl)
{
	window.location.href=strUrl;
}

//For Error Page

function goToURL(objSubmit,objForm)
{
	var strFormName;
	if(document.getElementById(objSubmit)!=null)
	{
		document.getElementById(objSubmit).value='submit';
		strFormName=document.getElementById(objForm);
		strFormName.submit();
	}
}

//For Forgot Password
function winclose()
{
	window.close();
}

function checkMail(objEmail)
{
	var email=document.getElementById(objEmail);
	if (checkEmpty(email)==false)
	{
		email.focus();
		window.alert("-Please enter Email");
		return false;
	}
	else if (!EvaluateMail(email.value))
	{
		email.focus();
		email.select();
		alert("-Please enter a valid e-mail address");
		return false;
	}	
	return true;
}

function emailSubmit(objEmail,objForm)
{
	var strFormName;
	if (checkMail(objEmail)==true)
	{
		document.getElementById('hdnForgotPassword').value='emailsubmitted';
		strFormName=document.getElementById(objForm);
		strFormName.submit();
	}
}

function checkAnswer(objAnswer)
{
	var answer=document.getElementById(objAnswer);
	if (checkEmpty(answer)==false)
	{
		answer.focus();
		window.alert("-Please enter your secret answer");
		return false;
	}
	return true;
}

function answerSubmit(objAnswer,objForm)
{
	var strFormName;
	if (checkAnswer(objAnswer)==true)
	{
		document.getElementById('hdnForgotPassword').value='answersubmitted';
		strFormName=document.getElementById(objForm);
		strFormName.submit();
	}
}

function setFocus(objEmail,objAnswer)
{
	if (document.getElementById(objEmail)!=null)
	{
		var email=document.getElementById(objEmail);
		focus(email);
	}
	if (document.getElementById(objAnswer)!=null)
	{
		var answer=document.getElementById(objAnswer);
		focus(answer);
	}
}

function goBack()
{
	var pagename;
	if(window.location.href.toUpperCase().indexOf("CUSTOMER/INFOPAGE.ASPX") > -1)
	{
		if(document.getElementById('hdnSiteUrl').value != "" && document.getElementById('hdnSiteUrl').value != null )
			pagename = document.getElementById('hdnSiteUrl').value;
		else
		{
			pagename = Get_Cookie("pagename");
		}
	}
	else
	{
		pagename = Get_Cookie("pagename");
	}
	self.location.href = pagename;		
}

function Get_Cookie( name ) {
	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
//For Optin Page
function popupMessage()
{

	// SET MESSAGE VALUES
	var to = "support@bluroute.biz";
	var subject = "Request for a meeting with Partner Management Team";

	// BUILD MAIL MESSAGE COMPONENTS 
	var doc = "mailto:" + to + "?subject=" + escape(subject);

	// POP UP EMAIL MESSAGE WINDOW
	window.location = doc;
}