function checkconfirm(){
	var lcheck='';
	var err=''
	lcheck=document.forms["frmInformation"].elements["chkConfirm"];		
	if(getoption()){
		if (lcheck[0].checked) return(true);
		else{alert('Please read all the "Terms and Conditions" \n and select YES if you agree and wish to \n continue.');return(false);}	 
	}else return false;
}

function attachphoto(){
	var width=260;
	var height=100;
	var left=(screen.availWidth/2)-(width/2);
	var top=(screen.availHeight/2)-(height/2);
	var lf="width="+width+",height="+height+",left="+left+",top="+top+",menubar=no,location=no,toolbar=no,status=yes,scrollbars=no,resizable=no";
	window.open("attachphoto.aspx","attachphoto",lf);
}

function viewphoto(Limage,nottemp){
	var theFeats = "height=290,width=465,scrollbars=yes,resizable=yes,menubar=yes,left=250,top=150";
	if(nottemp=='1') window.open("../files/Photos/" + Limage,"Image",theFeats);
	else window.open("../files/Photos/temp/" + Limage,"Image",theFeats);
}	

function showphotoicon(Lfilename){
	var lblphoto=document.getElementById('lblPhoto');
	lblphoto.innerHTML='<a href="javascript:viewphoto('+"'"+Lfilename+"'"+');"><img src="Images/view.gif" border="0" align="absmiddle" alt="View Photo"></a>' ;
}

function openterms(pagename){
	var width=500;
	var height=250;
	var left=(screen.availWidth/2)-(width/2);
	var top=(screen.availHeight/2)-(height/2);
	window.open(pagename+".aspx",pagename,"width="+width+",height="+height+",left="+left+",top="+top+",location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=no,status=yes");
}


function openconfirmation(type){
	var lwidth=500;
	var lheight=150;
	var lleft=(screen.availWidth/2)-(lwidth/2);
	var ltop=(screen.availHeight/2)-(lheight/2);
	var email=document.forms["frmInformation"].elements["txtEmail"].value;
	document.forms["frmInformation"].elements["hdnProceed"].value='1';
	if(type=='e')
		window.open("emailmatch.aspx?email="+email,"emailmatch","left="+lleft+",width="+lwidth+",top="+ltop+",height="+lheight+",toolbar=no,menubar=no,location=no,status=no,resizable=no");
	else if (type=='u')
		window.open("usermatch.aspx","usermatch","left="+lleft+",width="+lwidth+",top="+ltop+",height="+lheight+",toolbar=no,menubar=no,location=no,status=no,resizable=no");
	else
		window.open("proceed.aspx","proceed","left="+lleft+",width="+lwidth+",top="+ltop+",height="+lheight+",toolbar=no,menubar=no,location=no,status=no,resizable=no");
		
	
		
		
}

function resubmit(action){
	document.forms['frmInformation'].formaction.value=action;
	document.forms["frmInformation"].elements['txtPassword'].focus();
}

function redirect(){
	window.location.href="../logout.aspx"
}

function IntializeTextBoxes(){
	var frm=document.forms['frmInformation'].elements;
	document.getElementById("lblEId").style.display='none';
	document.getElementById("lblOther").style.display='none';
	if(frm['dropdownHF'].options[frm['dropdownHF'].selectedIndex].value=='FC Magazine'){
		disableid(frm['dropdownHF']);
	}
}

function disableid(that){
	document.getElementById("lblEId").style.display='none';
	document.getElementById("lblOther").style.display='none';
	if(!that){
		return;
	}
	if(that.value=='Attended a Seminar' || that.value=='Bookstore Member' || that.value=='FC Magazine'){
		document.getElementById("lblEId").style.display='block';
		document.getElementById("lblLink").style.display='none'
		if(that.selectedIndex==2){
			document.getElementById('lblCaption').innerHTML='Enter your e-mail address used to register for the bookstore';
		}else if(that.selectedIndex==3) {
			document.getElementById("lblLink").style.display='block'
			document.getElementById('lblCaption').innerHTML='Do you have an activation code?';
		}else{ 
			document.getElementById('lblCaption').innerHTML='Enter your e-mail address used to register for the seminar';
		}
		document.forms["frmInformation"].elements["txtSeminarID"].focus();
	}
	if(that.value=='Other'){
		document.getElementById("lblOther").style.display='block';
		document.forms["frmInformation"].elements["txtOther"].focus();
	}
}

function getoption(){
	var opt=document.forms["frmInformation"].elements["dropdownHF"];
	var lcheck=document.forms["frmInformation"].elements["chkConfirm"];
	var i;
	for(i=0;i<opt.length;i++){
		if(opt[i].selected){
			document.forms["frmInformation"].elements["hdnHear"].value=opt[i].value;
			break;
		}
	}
	//alert('hdnHear:'+document.forms["frmInformation"].elements["hdnHear"].value);
	if(document.forms["frmInformation"].elements["hdnHear"].value!=''){
		if(document.forms["frmInformation"].elements["hdnHear"].value=='Attended a Seminar' || document.forms["frmInformation"].elements["hdnHear"].value=='Bookstore Member'){
			if(document.forms["frmInformation"].elements["txtSeminarID"].value==''){
				alert('Email Address is required!');
				return false;
			}
			else{
				if (document.forms["frmInformation"].elements["txtSeminarID"].value.indexOf('@')==-1 || document.forms["frmInformation"].elements["txtSeminarID"].value.indexOf('.')==-1 ){
					alert('Invalid Email Address!');
					return false;
				}
			}
		}
		if(document.forms["frmInformation"].elements["hdnHear"].value=='FC Magazine'){
			if(document.forms["frmInformation"].elements["txtSeminarID"].value==''){
				alert('Activation Code is required!');
				return false;
			}
		}
		if(document.forms["frmInformation"].elements["hdnHear"].value=='O'){
			if(document.forms["frmInformation"].elements["txtOther"].value==''){
				alert('Other detail is required!');
				return false;
			}
		}
	}
	else{alert("Please fill out the required fields before submitting your application!");return false;}	
	if (document.getElementById("drpCountry").selectedIndex==1) {
		if (document.getElementById("ddlCanadaState").selectedIndex==0){
			alert("State is required!");
			return false;}
	}
	else if (document.getElementById("drpCountry").selectedIndex==2) {
		if (document.getElementById("ddlState").selectedIndex==0){
			alert("State is required!");
			return false;}
	}	
	if(document.forms['frmInformation'].elements['submitExists'].value!='Y'){
		if (!lcheck[0].checked)
		{alert('Please read all the "Terms and Conditions" \n and select YES if you agree and wish to \n continue.');return(false);}
	}
	return true;
}
function change_country(obj)
{		
	if(obj.options[obj.selectedIndex].value=="USA") {
		document.getElementById("divUsaState").style.display="block";
		document.getElementById("divCanadaState").style.display="none"; }
	else if(obj.options[obj.selectedIndex].value=="Canada"){
		document.getElementById("divCanadaState").style.display="block";
		document.getElementById("divUsaState").style.display="none"; }
	else {
		document.getElementById("divCanadaState").style.display="none";
		document.getElementById("divUsaState").style.display="block"; }
}
		
function doresend(){
	var lwidth=450;
	var lheight=250;
	var lleft=(screen.availWidth/2)-(lwidth/2);
	var ltop=(screen.availHeight/2)-(lheight/2);
	window.open("getactivationcode.aspx","Forgotpassword","left="+lleft+",width="+lwidth+",top="+ltop+",height="+lheight+",toolbar=no,menubar=no,location=no,status=no,resizable=no");
}

function showforgotpassword(){
	var lwidth=500;
	var lheight=150;
	var lleft=(screen.availWidth/2)-(lwidth/2);
	var ltop=(screen.availHeight/2)-(lheight/2);
	window.open("../forgotpassword.aspx","Forgotpassword","left="+lleft+",width="+lwidth+",top="+ltop+",height="+lheight+",toolbar=no,menubar=no,location=no,status=no,resizable=no");
}

function dosubmit() {	
	document.forms['frmInformation'].elements['submitExists'].value='Y'		
	if(getoption()){
		document.forms['frmInformation'].elements['formaction'].value='hearoption';
		document.forms['frmInformation'].submit();
	}
}

function clearpreformat(obj){
	if(obj.value!=''){
		if(obj.value=="(   )   -"){
			obj.value="";
		}
	}
}

function setpreformat(obj){
	if(obj.value==''){
		obj.value="(   )   -";
	}
}

function validatespouseemail(obj){
	var invalidemail=false;
	if(obj.value!=""){
		var email = obj.value.indexOf('@')
		if (email<1 || email==(obj.value.length-1)) 
			invalidemail=true;									
	}
	if(obj.value!="" && !invalidemail)
		alert('Please be aware that all Producer Revolution emails sent to your primary email will also be sent to your "Spouse" email.')
}

function readmembername(id){
	
	if(id!=''){
		var idindex='',randomid='',arr='';
		idindex=id.indexOf("(");
		if(idindex > 0){
			arr=id.split("(")
			randomid = arr[0];
		}
		else
			randomid=id;
		var ajax=new AJAX();
		ajax.setEventHandler('setmembername');
		ajax.getAJAX('ReadReferrerName.aspx?memberid='+randomid);
	}
}

function setmembername(res,success){
	if(success){			
		var idindex='';
		idindex=res.response.indexOf("invalid");
		if(idindex > 0){
			document.getElementById("txtMemberId").style.color="red";
			document.getElementById("txtMemberId").innerText=res.response;
		}else{
			document.getElementById("txtMemberId").style.color="black";
			document.getElementById("txtMemberId").innerText=res.response;
		}
	}
}

function changecolor(){
	if(document.getElementById("txtMemberId").style.color=="red")
		document.getElementById("txtMemberId").style.color="black";
}