function navTo(prefix, suffix, numnavs) {
	for(i=1; i<= numnavs; i++) {
		try {
			nav = ge(prefix+i);
			nav.className = (i == suffix) ? "selected" : "regular";
		} catch(e) {}	
	}
	return false;
}
function submitRequest(frm,btn,divid,whichone,urlvar) {
	if(whichone == 'register')
	 submitAjaxForm('/membership/loader.cfm?submitRequest',divid,frm,callLoadPage,btn,true);
	else if(whichone == 'freeuser')
	 submitAjaxForm('/membership/loader.cfm?freeuser',divid,frm,callLoadPage,btn,true);
	else if(whichone == 'trial')
	 submitAjaxForm('/membership/loader.cfm?request_trial' + urlvar,divid,frm,callLoadPage,btn,true);
	return false; 
}
function switchLogo(prod) {
	ge('imgZawyaLogo').src = '/images/' + (prod.toLowerCase() == 'zbd' || prod.toLowerCase() == 'zi' || prod.toLowerCase() == 'projects' ? prod.toLowerCase() + '_logo.jpg' : 'zawya_logo.gif');
	return false;
	//return submitAjaxForm('/membership/loader.cfm?submitRequest',divid,frm,callLoadPage,btn,true);
}
function loadRole(el,prod,prodnum,navnum,total) {
	loadUrl('/membership/loader.cfm?role='+escape(el.innerHTML)+'&prod='+prod+'&nav='+navnum,'mktrole_'+prodnum,true);
	navTo(prod,navnum,total);
}
function loadCat(role,prod,nav) {
	loadUrl('/membership/loader.cfm?categories='+prod+'&role='+escape(role)+'&nav='+nav,'mktbody',true);
	return false;
}
function loadTrial(product,divid) {
	loadUrl('/membership/loader.cfm?request_trial='+escape(product),divid,true);
	return false;
}
function loadTrialfree(product,divid) {
	loadUrl('/membership/loader.cfm?free&request_trial='+escape(product),divid,true);
	return false;
}
function loadSolution(sol,divid) {
	loadUrl('/membership/loader.cfm?solution=' + sol,divid,true);
	return false;
}
function loadMain(divid) {
	loadUrl('/membership/loader.cfm?main',divid,true);
	return false;
}
function loadUrl(url, divid, isloader) {
	if(isloader) {
		window.document.getElementById(divid).innerHTML = '<table class="ztable"><tr><td class="greytextsmall" style="padding: 60px 0px;text-align:center;"><img src="/images/loadingdata.gif" style="vertical-align:middle;"> Loading...</td></tr></table>';
	}
	ajaxCaller.getPlainText(url, callLoadPage, divid);
	return false;
}
function submitAjaxForm(url,divid,fObj,callBack,btnObj,isloader) {
	form_postForPlainText(url,fObj,callBack,null,btnObj,divid);
	if(typeof(isloader) != 'undefined' && typeof(isloader) != 'null'  && isloader)
		ge(divid).innerHTML = '<div class="loadimg greytextsmall"><img src="/images/loadingdata.gif" style="vertical-align:middle;"> Loading...</div>';
	return false;	
}
function callLoadPage(text,callingContext,headers,arrParams) {
	window.document.getElementById(callingContext).innerHTML = text;
	setJSFunctions(callingContext,text);		
}
function divslider(divid) { 
	var div = document.getElementById(divid); 
	div.id =  divid;
	div.ts = '';
	div.show = function() { this.className = 'notgone'; };
	div.hide = function() {	this.className = 'gone'; };
	div.slide = function() { winSlide(div.id); return false; };
	div.setTimer = function(divid,ms) { div.tmr = setTimeout(function(){ document.getElementById(divid).className = 'gone';},ms); };
	div.setSlideTimer = function(ms) { div.tmr = setTimeout('winSlide(\'' + div.id + '\')',ms); };
	div.clearTimer = function(divid) { if(div.tmr) clearTimeout(div.tmr); }
	return div; 
}
function posAbsolute (divid,relativeDiv,align,offset) {
	innerdiv = document.getElementById(divid);
	outerdiv = document.getElementById(relativeDiv);
	innerdivwidth = innerdiv.offsetWidth;
	innerdivheight = innerdiv.offsetHeight;
	outerdivwidth = outerdiv.offsetWidth;
	outerdivheight = outerdiv.offsetHeight;
	if(align == 'right') 
		innerdiv.style.left = (outerdivwidth - innerdivwidth) + 'px';
	if(align == 'left')
		innerdiv.style.left = '0px';	
	if(align == 'bottom')
		innerdiv.style.top = (innerdiv.offsetHeight * -1) + offset + 'px';	
}

function winSlide(elid) {
	try {
		Spry.Effect.Slide(elid, {duration: 500, from: '0px', to: '100%', toggle: true});
	} catch(e) {}	
		return false;
}
		
function chkFormFields(frm,whichOne) {
	with(frm) {
		switch(whichOne) {
			case 'Request Trial 1' :
				if(trim(name.value) == '') {
					alert('Please enter your name');
					name.focus();
					return false;
				}
				if(trim(company_name.value) == '') {
					alert('Please enter your company name');
					company_name.focus();
					return false;
				}
				if(trim(position.options[position.selectedIndex].value) == '') {
					alert('Please select your position');
					position.focus();
					return false;
				}
				if(trim(position.options[position.selectedIndex].value) == 'Other' && trim(job_title.value) == '') {
					alert('Please enter your position');
					job_title.focus();
					return false;
				}
				if(trim(s_business_segment.options[s_business_segment.selectedIndex].value) == '') {
					alert('Please select your business segment');
					s_business_segment.focus();
					return false;
				}
				if(trim(s_business_segment.options[s_business_segment.selectedIndex].value) == 'Other' && trim(business_segment.value) == '') {
					alert('Please enter your business segment');
					business_segment.focus();
					return false;
				}
				if(trim(s_industry.options[s_industry.selectedIndex].value) == '') {
					alert('Please select your sector');
					s_industry.focus();
					return false;
				}
				if(trim(s_industry.options[s_industry.selectedIndex].value) == 'Other' && trim(industry.value) == '') {
					alert('Please enter your sector');
					industry.focus();
					return false;
				}
				if(trim(country.options[country.selectedIndex].value) == '') {
					alert('Please select your country');
					country.focus();
					return false;
				}
				if(trim(email.value) == '') {
					alert('Please enter your email');
					email.focus();
					return false;
				}
				if(!checkEmail(email.value)) {
					alert('Email is not valid');
					email.focus();
					return false;
				}
				if(trim(telephone.value) == '') {
					alert('Please enter your phone number');
					telephone.focus();
					return false;
				}
				break;
			case 'Request Trial 2' :
				if(!selinfo.options.length) {
					alert('Please select the information you are looking for.');
					selselect_info.focus();
					return false;
				}
				if(!selsector.options.length) {
					alert('Please select the industry / sector you are interested in.');
					selselect_sector.focus();
					return false;
				}
				if(!selcountry.options.length) {
					alert('Please select the country information you are looking for.');
					selselect_country.focus();
					return false;
				}
				if(trim(employees.value) == '') {
					alert('Please enter the number of employees in your organizaion.');
					employees.focus();
					return false;
				}
				break;
			case 'Login' :
				if(trim(username.value) == '') {
					alert('Please enter your username');
					username.focus();
					return false;
				}
				if(trim(password.value) == '') {
					alert('Please enter your password');
					password.focus();
					return false;
				}
				break;	
			case 'FreeUser' :
				if(trim(email.value) == '') {
					alert('Please enter your email');
					email.focus();
					return false;
				}
				if(!checkEmail(email.value)) {
					alert('Email is not valid');
					email.focus();
					return false;
				}
				break;		
			case 'survey' :
				for(i=0;i<reference_source.length;i++) {
					if(reference_source[i].checked) return true;
				}
				alert('Please select one or more checkboxes on the options above.');
				return false;
				break;	
			case 'Register' :
				if(typeof(radBusinessSegment) != 'undefined') {
					chked = false;
					for(i=0;i<radBusinessSegment.length;i++) {
						if(!chked && radBusinessSegment[i].checked) {
							chked = true;
						}
					}
					if(!chked) {
						alert('Please select your business segment');
						radBusinessSegment[0].focus();
						return false;
					}	
				}
				/*if(trim(title.options[title.selectedIndex].value) == '') {
					alert('Please select your title');
					title.focus();
					return false;
				}*/
				if(trim(first_name.value) == '') {
					alert('Please enter your first name');
					first_name.focus();
					return false;
				}
				if(trim(last_name.value) == '') {
					alert('Please enter your last name');
					last_name.focus();
					return false;
				}
				if(typeof(birth_year) != 'undefined' && trim(birth_year.options[birth_year.selectedIndex].value) == '') {
					alert('Please select your year of birth');
					birth_year.focus();
					return false;
				}
				if(typeof(gender) != 'undefined' && trim(gender.options[gender.selectedIndex].value) == '') {
					alert('Please select your gender');
					gender.focus();
					return false;
				}
				if(typeof(cde_country_origin) != 'undefined' && trim(cde_country_origin.options[cde_country_origin.selectedIndex].value) == '') {
					alert('Please select your country of origin');
					cde_country_origin.focus();
					return false;
				}
				
				if(typeof(cde_country) != 'undefined' && trim(cde_country.options[cde_country.selectedIndex].value) == '') {
					alert('Please select your country of residence');
					cde_country.focus();
					return false;
				}
				if(trim(email.value) == '') {
					alert('Please enter your email');
					email.focus();
					return false;
				}
				if(!checkEmail(email.value)) {
					alert('Email is not valid');
					email.focus();
					return false;
				}
				
				if(typeof(username) != 'undefined') {
					if(trim(username.value) == '') {
						alert('Please enter your username');
						username.focus();
						return false;
					}
					if(trim(password.value) == '') {
						alert('Please enter your password');
						password.focus();
						return false;
					}
					try {
						if(trim(confirm_password.value) == '') {
							alert('Please confirm your password');
							confirm_password.focus();
							return false;
						}
						if(password.value != confirm_password.value) {
							alert('Passwords do not match');
							password.focus();
							return false;
						}
					} catch(e) {}	
				}
		
				/*try {
					if(radAccount[2].checked && trim(sel_cde_acount.options[sel_cde_acount.selectedIndex].value) == '') {
						alert('Please select existing account');
						sel_cde_acount.focus();
						return false;	
					}
				} catch(e) {}
				*/					
				if(trim(company_name.value) == '') {
					alert('Please enter your company name');
					company_name.focus();
					return false;
				}				
				if(typeof(s_business_segment) != 'undefined') {
					if(trim(s_business_segment.value) == '') {
						alert('Please select your business segment');
						s_business_segment.focus();
						return false;
					}
					if(trim(s_business_segment.options[s_business_segment.selectedIndex].value) == 'Other' && trim(business_segment.value) == '') {
						alert('Please enter your business segment');
						business_segment.focus();
						return false;
					}
				}					
				if(typeof(position) != 'undefined' && trim(position.value) == '') {
					alert('Please enter your position');
					position.focus();
					return false;
				}				
				if(typeof(job_title) != 'undefined' &&trim(job_title.value) == '') {
					alert('Please enter your closest role description');
					job_title.focus();
					return false;
				}				
				if(typeof(s_industry) != 'undefined' && trim(s_industry.options[s_industry.selectedIndex].value) == '') {
					alert('Please select your sector');
					s_industry.focus();
					return false;
				}				
				if(typeof(s_industry) != 'undefined' && trim(s_industry.options[s_industry.selectedIndex].value) == 'Other' && trim(industry.value) == '') {
					alert('Please enter your sector');
					industry.focus();
					return false;
				}
				if(typeof(phone) == 'object' ) {
					if(trim(phone.value) == '') {
						alert('Please enter your phone number');
						telephone_number.focus();
						return false;
					}					  					
				}
				if(typeof(role) == 'object'){
					if(!checkRadCheck('role')){
						alert('Please select a role in the funds industry');
						return false;
					}
				}
				if(typeof(region) == 'object'){
					if(!checkRadCheck('region')){
						alert('Please countries/regions that you focus on');
						return false;
					}
				} 
				if(typeof(asset) == 'object'){
					if(!checkRadCheck('asset')){
						alert('Please select asset type[s] that you focus on');
						return false;
					}
				}				 
			break;
			case 'PE GVCA Registration':
				if(trim(first_name.value) == ''){
					alert('Please enter your first name');
					first_name.focus();
					return false;
				}
				if(trim(last_name.value) == ''){
					alert('Please enter your last name');
					last_name.focus();
					return false;
				}
				if(trim(company_name.value) == ''){
					alert('Please enter your company name');
					company_name.focus();
					return false;
				}
				if(typeof(s_industry) != 'undefined' && trim(s_industry.value) == ''){
					alert('Please enter your sector');
					s_industry.focus();
					return false;
				}
				if(typeof(position) != 'undefined' && trim(position.value) == ''){
					alert('Please enter your title/position');
					position.focus();
					return false;
				}
				if(typeof(s_business_segment) != 'undefined') {
					if(trim(s_business_segment.value) == '') {
						alert('Please select your business segment');
						s_business_segment.focus();
						return false;
					}
					if(trim(s_business_segment.options[s_business_segment.selectedIndex].value) == 'Other' && trim(business_segment.value) == '') {
						alert('Please enter your business segment');
						business_segment.focus();
						return false;
					}
				}
				if (trim(telephone.value) == '') {
					alert('Invalid Telephone !');
					telephone.focus();
					return false;
				}
				if(trim(email.value) == '') {
					alert('Please enter your email');
					email.focus();
					return false;
				}
				if(!checkEmail(email.value)) {
					alert('Email is not valid');
					email.focus();
					return false;
				}
				if(!checkRadCheck('role')){
					alert('Please select your role in the Private Equity Industry');
					return false;
				}
				if(!checkRadCheck('geo_focus')){
					alert('Please select countries/regions do you focus on');
					return false;
				}
				if(!checkRadCheck('pe_inv')){					
					alert('Please select how do you execute Private Equity investments');
					return false;
				}
				else if(!checkRadCheck('pe_inv_details') && document.getElementsByName('pe_inv')[3].checked == false){
					alert('Please select how do you execute Private Equity investments');
					return false;
				}
			break;
			case 'IPREO':
				if(trim(first_name.value) == ''){
					alert('Please enter your first name');
					first_name.focus();
					return false;
				}
				if(trim(last_name.value) == ''){
					alert('Please enter your last name');
					last_name.focus();
					return false;
				}
				if(trim(company_name.value) == ''){
					alert('Please enter your company name');
					company_name.focus();
					return false;
				}
				if(typeof(s_industry) != 'undefined' && trim(s_industry.value) == ''){
					alert('Please enter your sector');
					s_industry.focus();
					return false;
				}
				if(typeof(position) != 'undefined' && trim(position.value) == ''){
					alert('Please enter your title/position');
					position.focus();
					return false;
				}
				if(typeof(s_business_segment) != 'undefined') {
					if(trim(s_business_segment.value) == '') {
						alert('Please select your business segment');
						s_business_segment.focus();
						return false;
					}
					if(trim(s_business_segment.options[s_business_segment.selectedIndex].value) == 'Other' && trim(business_segment.value) == '') {
						alert('Please enter your business segment');
						business_segment.focus();
						return false;
					}
				}
				if (trim(telephone.value) == '') {
					alert('Invalid Telephone !');
					telephone.focus();
					return false;
				}
				if (trim(country.value) == '') {
					alert('Please select country!');
					country.focus();
					return false;
				}
				if(trim(email.value) == '') {
					alert('Please enter your email');
					email.focus();
					return false;
				}
				if(!checkEmail(email.value)) {
					alert('Email is not valid');
					email.focus();
					return false;
				}				
			break;
			case 'ZNGROUP':
				if(trim(first_name.value) == ''){
					alert('Please enter your first name');
					first_name.focus();
					return false;
				}
				if(trim(last_name.value) == ''){
					alert('Please enter your last name');
					last_name.focus();
					return false;
				}
				try {
					if (trim(phone.value) == '') {
						alert('Please enter your telephone number');
						phone.focus();
						return false;
					}
				}catch(e){}
				if(trim(company_name.value) == ''){
					alert('Please enter your company name');
					company_name.focus();
					return false;
				}
				if(typeof(s_industry) != 'undefined' && trim(s_industry.value) == ''){
					alert('Please enter your sector');
					s_industry.focus();
					return false;
				}
				if(typeof(position) != 'undefined' && trim(position.value) == ''){
					alert('Please enter your title/position');
					position.focus();
					return false;
				}
				if (typeof(country) != 'undefined' && trim(country.value) == '') {
					alert('Please select country!');
					country.focus();
					return false;
				}
				if (typeof(specialization) != 'undefined' && trim(specialization.value) == '') {
					alert('Please select specialization!');
					specialization.focus();
					return false;
				}
				if (typeof(interest) != 'undefined' && trim(interest.value) == '') {
					alert('Please select interest!');
					interest.focus();
					return false;
				}
				if(trim(email.value) == '') {
					alert('Please enter your email');
					email.focus();
					return false;
				}
				if(!checkEmail(email.value)) {
					alert('Email is not valid');
					email.focus();
					return false;
				}				
			break;
		}
	}
	return true;
}
function checkRadCheck(nm){	
	objArr = document.getElementsByName(nm);
	if (objArr.length > 0) {		
  	for (var i = 0; i < objArr.length; i++) 
  		if (objArr[i].checked == true) 
  			return true;
  	try {
  		objArr[0].focus();
  	} 
  	catch (e) {
  	}
  }
	return false;
}

function get_radio_value(nm){
	var rad_val = '';
	for (var i=0; i < document.getElementsByName(nm).length; i++){
  	if (document.getElementsByName(nm)[i].checked){
   		rad_val = document.getElementsByName(nm)[i].value;
    }
  }
	return rad_val;
}

/* JS from subscribe.js */
function popthisdiv(divid) {
		//try {
			document.getElementById(divid).className='notgone';
			centerThis(divid);
		//} catch(e) {}
		return false;
	}
function proceed(from,to) {
	if (from == "bar_personal")
	{
		if (lastuser==0)
			checkValid("email");
		else
			checkValid("email",lastuser);	
		if (to == 'bar_payment' && lastuser != window.document.getElementById("additionalusers").value)
		{
			showHideAdditional(lastuser,lastuser+1);
			window.document.getElementById("additionalUsersHTML").style.display = (lastuser != 0?"":"none");
			to = 'bar_personal';
		}
		else if (to == 'bar_choose' && lastuser != 0)
		{
			showHideAdditional(lastuser,lastuser-1);
			window.document.getElementById("additionalUsersHTML").style.display = (lastuser != 0?"":"none");
			to = 'bar_personal';
		}
	}
	divFrom = document.getElementById(from);
	divTo = document.getElementById(to);
	divFrom.className = 'bar_inactive';
	divTo.className = 'bar_active';
}
function showHideAdditional(num1,num2)
{
	window.document.getElementById("bar_personal_box"+(num1==0?'':num1)).className = "bar_box_inactive";
	window.document.getElementById("bar_personal_box"+(num2==0?'':num2)).className = "bar_box";
	lastuser = num2;
}
function toggle_cards(tohide, toshow) {
	document.getElementById(tohide).className = 'gone';
	document.getElementById(toshow).className = 'notgone';
} 
function calc(target, baseprice, price, num) {
	var val;
	val = formatnum(baseprice + (price * num),2);
	document.getElementById(target).innerHTML = '$' + val;
	window.document.getElementById("additionalUsersHTML").innerHTML = "";
	for(var i=1;i<=num;i++)
		doClone(i);
}


function chkFormSteps(whichone,userno) {
	with(document.subscriptionForm) {
		switch(whichone) {
			case 'bar_choose': 
				if(typeof(radPackage) != 'undefined'  && typeof(radPackage) != null) {
					if(radPackage[1].checked) {
						chkd = 0;
						for(i=0;i<chkSectors.length;i++) {
							if(chkSectors[i].checked) chkd++;
						}
						if(!chkd) {
							alert('Please select 1 sector for this package.');
							return false;
						}
					}
					else if(radPackage[2].checked) {
						chkd = 0;
						for(i=0;i<chkMarkets.length;i++) {
							if(chkMarkets[i].checked) chkd++;
						}
						if(!chkd) {
							alert('Please select 1 market for this package.');
							return false;
						}
					}
				}
				return true;
				break;
			case 'bar_personal':
				if(typeof(userno) == 'undefined') {	
					if (trim(title.value) == '') {
						alert('Invalid Prefix !');
						title.focus();
						return false;
					}	else if (trim(first_name.value) == '') {
							alert('Invalid First Name !');
							first_name.focus();
							return false;
					}	else if (trim(last_name.value) == '') {
							alert('Invalid Last Name !');
							last_name.focus();
							return false;
					}	else if (trim(position.value) == '') {
							alert('Invalid Position !');
							position.focus();
							return false;
					}	else if (trim(company_name.value) == '') {
							alert('Invalid Company Name !');
							return false;
					}	else if (trim(industry.value) == '') {
							alert('Invalid Sector !');
							industry.focus();
							return false;
					}	else if (trim(city.value) == '') {
							alert('Invalid City !');
							city.focus();
							return false;
					}
					else if (trim(cde_country.value) == '') {
							alert('Invalid Country !');
							cde_country.focus();
							return false;
					}
					else if (trim(phone.value) == '') {
							alert('Invalid Telephone !');
							phone.focus();
							return false;
					}
					else if (trim(fax.value) == '') {
							alert('Invalid Fax !');
							fax.focus();
							return false;
					}	else if (!checkEmail(email.value)) {
							alert('Invalid email address !');
							email.select();
							email.focus();
							return false;
					} else if(parseInt(additionalusers.options[additionalusers.selectedIndex].value)) {
						// check for duplicate emailssssss
						if(typeof(userno) != 'undefined' && userno && ge("email"+userno)) {
							eml = trim(eval("email"+userno).value.toLowerCase());
							if(eml == trim(email.value)) {
								alert('Please use different email addresses for each member.');
								eval("email"+userno).select();
								eval("email"+userno).focus();
								return false;
							}
							for(i=1;i<=parseInt(additionalusers.options[additionalusers.selectedIndex].value);i++) {
								if(i != userno && eml == trim(eval("email"+i).value.toLowerCase())) {
									alert('Please use different email addresses for each member.');
									eval("email"+userno).select();
									eval("email"+userno).focus();
									return false;
								}
							}
						} else {
							eml = trim(email.value.toLowerCase());
							for(i=1;i<=parseInt(additionalusers.options[additionalusers.selectedIndex].value);i++) {
								if(ge("email"+i) && eml == trim(eval("email"+i).value.toLowerCase())) {
									alert('Please use different email addresses for each member.');
									email.select();
									email.focus();
									return false;
								}
							}
						}
					}
				} else {
					// additional users testing
					if (trim(eval('title'+userno).value) == '') {
						alert('Invalid Prefix !');
						eval('title'+userno).focus();
						return false;
					}	else if (trim(eval('first_name'+userno).value) == '') {
							alert('Invalid First Name !');
							eval('first_name'+userno).focus();
							return false;
					}	else if (trim(eval('last_name'+userno).value) == '') {
							alert('Invalid Last Name !');
							eval('last_name'+userno).focus();
							return false;
					}	else if (trim(eval('position'+userno).value) == '') {
							alert('Invalid Position !');
							eval('position'+userno).focus();
							return false;
					}	else if (trim(eval('phone'+userno).value) == '') {
							alert('Invalid Telephone !');
							eval('phone'+userno).focus();
							return false;
					}	else if (!checkEmail(eval('email'+userno).value)) {
							alert('Invalid email address !');
							eval('email'+userno).select();
							eval('email'+userno).focus();
							return false;
					} else if(parseInt(additionalusers.options[additionalusers.selectedIndex].value)) {
							eml = trim(eval("email"+userno).value.toLowerCase());
							if(eml == trim(email.value)) {
								alert('Please use different email addresses for each member.');
								eval("email"+userno).select();
								eval("email"+userno).focus();
								return false;
							}
							for(i=1;i<=parseInt(additionalusers.options[additionalusers.selectedIndex].value);i++) {
								if(i != userno && eml == trim(eval("email"+i).value.toLowerCase())) {
									alert('Please use different email addresses for each member.');
									eval("email"+userno).select();
									eval("email"+userno).focus();
									return false;
								}
							}
						}
					}
					/*else if (parseInt(eval("validEmail").value)) {
						email.select();
						email.focus();
						alert("Email already exists\nIf this is your email, please sign in first or contact your account manager");
						return false;
				}*/
				return true;
				break;
		}
	}
}

function validate_form() {
with (document.subscriptionForm)
{
	if(typeof(radPackage) != 'undefined'  && typeof(radPackage) != null) {
		if(radPackage[1].checked) {
			chkd = 0;
			for(i=0;i<chkSectors.length;i++) {
				if(chkSectors[i].checked) chkd++;
			}
			if(!chkd) {
				alert('Please select 1 sector for this package.');
				showHideAdditional(lastuser,0);
				proceed('bar_payment','bar_choose');
				return false;
			}
		}
		else if(radPackage[2].checked) {
			chkd = 0;
			for(i=0;i<chkMarkets.length;i++) {
				if(chkMarkets[i].checked) chkd++;
			}
			if(!chkd) {
				alert('Please select 1 market for this package.');
				showHideAdditional(lastuser,0);
				proceed('bar_payment','bar_choose');
				return false;
			}
		}
	}
	if (title.value == '') {
		alert('Invalid Prefix !');
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		title.focus();
		return false;
		}
	else if (first_name.value == '') {
		alert('Invalid First Name !');
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		first_name.focus();
		return false;
		}
	else if (last_name.value == '') {
		alert('Invalid Last Name !');
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		last_name.focus();
		return false;
		}
	else if (company_name.value == '') {
		alert('Invalid Company Name !');
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		company_name.focus();
		return false;
		}
	else if (email.value.indexOf('@',0)==-1 ||
			 email.value.indexOf('@',0)== 0 ||
		 email.value.indexOf('/',0)>-1 ||
		 email.value.indexOf(':',0)>-1 ||
		 email.value.indexOf(',',0)>-1 ||
		 email.value.indexOf(';',0)>-1 ||
		 email.value.indexOf(' ',0)>-1 ||
			 email.value.indexOf('.',0)==-1) {
		alert('Invalid email address !');
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		email.select();
		email.focus();
		return false;
		}
	else if (parseInt(eval("validEmail").value)) {
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		email.select();
		email.focus();
		alert("Email already exists\nIf this is your email, please sign in first or contact your account manager");
		return false;
		}		
	else if (city.value == '') {
		alert('Invalid City !');
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		city.focus();
		return false;
		}
	else if (cde_country.value == '') {
		alert('Invalid Country !');
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		cde_country.focus();
		return false;
		}
	else if (phone.value == '') {
		alert('Invalid Telephone !');
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		phone.focus();
		return false;
		}
	else if (fax.value == '') {
		alert('Invalid Fax !');
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		fax.focus();
		return false;
		}
	else if (position.value == '') {
		alert('Invalid Position !');
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		position.focus();
		return false;
		}
	else if (industry.value == '') {
		alert('Invalid Sector !');
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		industry.focus();
		return false;
		}
	/*else if (username.value == '') {
		alert('Invalid Username !');
		showHideAdditional(lastuser,0);
		proceed('bar_info','bar_personal');
		username.focus();
		return false;
		}
	else if (password.value == '') {
		alert('Invalid Password !');
		showHideAdditional(lastuser,0);
		proceed('bar_info','bar_personal');
		password.focus();
		return false;
		}
	else if (password.value != passwordConfirm.value) {
		alert('Passwords do not match !');
		showHideAdditional(lastuser,0);
		proceed('bar_info','bar_personal');
		password.focus();
		return false;
		}*/
	else if (ccnumber.value == '' || isNaN(ccnumber.value)) {
		alert('Invalid Card Number !');
		proceed('bar_payment','bar_payment');
		ccnumber.focus();
		return false;
		}
	else if (ccname.value == '') {
		alert('Invalid Cardholder\'s Name !');
		proceed('bar_payment','bar_payment');
		ccname.focus();
		return false;
	}	else if (ccmonth.value == '') {
		alert('Please select month of expiry');
		proceed('bar_payment','bar_payment');
		ccmonth.focus();
		return false;
	}	else if (ccyear.value == '') {
		alert('Please select year of expiry');
		proceed('bar_payment','bar_payment');
		ccyear.focus();
		return false;
	} else if (address.value == '') {
		alert('Invalid Billing Address !');
		proceed('bar_payment','bar_payment');
		address.focus();
		return false;
		}
		if((productcd.value != 'ZBD') || (productcd.value == 'ZBD' && radTerm[0].checked)) { 
			totBCL = parseInt(bcldownload.options[bcldownload.selectedIndex].value); 
			if(totBCL) {
				totUsers = parseInt(additionalusers.options[additionalusers.selectedIndex].value);
				if(totUsers && bclChk.length) {
					bclchkCtr = 0;
					for(i=0;i<bclChk.length;i++) 
						if(bclChk[i].checked) 
							bclchkCtr++;
					if(bclchkCtr < totBCL) {
						showHideAdditional(lastuser,0);
						proceed('bar_payment','bar_personal');
						alert('Download companies checkbox is incomplete.');
						return false;
					}	
				}
				else if (!bclChk.checked) {
					alert(bclChk.value);
					showHideAdditional(lastuser,0);
					proceed('bar_payment','bar_personal');
					alert('Download companies checkbox was left unchecked.');
					return false;
				}
			}
		}	
	}
	if (!validateAdditional())
		return false;
	if (!validateUsernamePwd())
		return false;
	if (!document.subscriptionForm.readAgreement.checked) {
		alert('Please read and approve the Membership Agreement');
		showHideAdditional(lastuser,lastuser);
		proceed('bar_personal','bar_payment');
		return false;
	}
	window.document.getElementById("SubmitSubscription").style.display = "none";
	submitAjaxForm('/membership/loader.cfm?join=' + document.subscriptionForm.productcd.value,'mktbody',document.subscriptionForm,callLoadPage,document.subscriptionForm.SubmitSubscription,true);
	return false;
}
function loadSnapshot(elid,src,width) {
	ge(elid).className = 'popsnapshot';
	if(typeof(width) != 'undefined' && width != null)
		ge(elid).style.width = width + "px";
	ge(elid).innerHTML = "<div class='close'><a href='#' onclick=\"ge(\'" + elid + "').className='gone'; return false;\" class='moretext'>close x</a></div><img src='" + src + "' border:0px'>";
	centerThis(elid);
	return false;
}
function validateAdditional()
{
	for (var i=1;i<=window.document.getElementById("additionalusers").value;i++)
	{
		msg = "Additional User "+i+"\n";
		with (document.subscriptionForm)
		{
			if (eval("title"+i).value == '') {
				alert(msg+'Invalid Prefix !');
				showHideAdditional(lastuser,i);
				proceed('bar_payment','bar_personal');
				eval("title"+i).focus();
				return false;
				break;
				}
			else if (eval("first_name"+i).value == '') {
				alert(msg+'Invalid First Name !');
				showHideAdditional(lastuser,i);
				proceed('bar_payment','bar_personal');
				eval("first_name"+i).focus();
				return false;
				break;
				}
			else if (eval("last_name"+i).value == '') {
				alert(msg+'Invalid  Last Name  !');
				showHideAdditional(lastuser,i);
				proceed('bar_payment','bar_personal');
				eval("last_name"+i).focus();
				return false;
				break;
				}
			else if (eval("email"+i).value.indexOf('@',0)==-1 ||
				 eval("email"+i).value.indexOf('@',0)== 0 ||
				 eval("email"+i).value.indexOf('/',0)>-1 ||
				 eval("email"+i).value.indexOf(':',0)>-1 ||
				 eval("email"+i).value.indexOf(',',0)>-1 ||
				 eval("email"+i).value.indexOf(';',0)>-1 ||
				 eval("email"+i).value.indexOf(' ',0)>-1 ||
				 eval("email"+i).value.indexOf('.',0)==-1) {
				alert(msg+'Invalid email address !');
				showHideAdditional(lastuser,i);
				proceed('bar_payment','bar_personal');
				eval("email"+i).select();
				eval("email"+i).focus();
				return false;
				break;
				}
			else if (parseInt(eval("validEmail"+i).value)) {
				showHideAdditional(lastuser,i);
				proceed('bar_payment','bar_personal');
				eval("email"+i).select();
				eval("email"+i).focus();
				alert("Email already exists\nIf this is your email, please sign in first or contact your account manager");
				return false;
				break;
				}	
			/*else if (eval("city"+i).value == '') {
				alert(msg+'Invalid City !');
				showHideAdditional(lastuser,i);
				proceed('bar_info','bar_personal');
				eval("city"+i).focus();
				return false;
				break;
				}
			else if (eval("cde_country"+i).value == '') {
				alert(msg+'Invalid Country !');
				showHideAdditional(lastuser,i);
				proceed('bar_info','bar_personal');
				eval("cde_country"+i).focus();
				return false;
				break;
				}*/
			else if (eval("phone"+i).value == '') {
				alert(msg+'Invalid Telephone !');
				showHideAdditional(lastuser,i);
				proceed('bar_payment','bar_personal');
				eval("phone"+i).focus();
				return false;
				break;
				}
			/*else if (eval("fax"+i).value == '') {
				alert(msg+'Invalid Fax !');
				showHideAdditional(lastuser,i);
				proceed('bar_info','bar_personal');
				eval("fax"+i).focus();
				return false;
				break;
				}*/
			else if (eval("position"+i).value == '') {
				alert(msg+'Invalid Position !');
				showHideAdditional(lastuser,i);
				proceed('bar_payment','bar_personal');
				eval("position"+i).focus();
				return false;
				break;
				}
			/*else if (eval("industry"+i).value == '') {
				alert(msg+'Invalid Sector !');
				showHideAdditional(lastuser,i);
				proceed('bar_info','bar_personal');
				eval("industry"+i).focus();
				return false;
				break;
				}*/
		}
	}
	return true;
}
function validateUsernamePwd()
{
	if(window.document.getElementById("validEmail").value == 0 ||
			window.document.getElementById("validEmail").value == "")
		return true;
	else
	{
		if(parseInt(window.document.getElementById("validEmail").value) > 0)
			alert("Email already exists\nIf this is your email, please sign in first or contact your account manager");
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		try { ge('email').focus(); } catch(e) {}
		return false;
	}
	/*if((window.document.getElementById("validEmail").value == 0 && window.document.getElementById("validUsername").value == 0)||
			(window.document.getElementById("validEmail").value == "" && window.document.getElementById("validUsername").value =="")||
			(window.document.getElementById("validEmail").value == 0 && window.document.getElementById("validUsername").value =="")||
			(window.document.getElementById("validEmail").value == "" && window.document.getElementById("validUsername").value ==0))
		return true;
	else
	{
		if(parseInt(window.document.getElementById("validEmail").value) > 0)
			alert("Email already exists\nIf this is your email, please sign in first or contact your account manager");
		else if(parseInt(window.document.getElementById("validUsername").value) > 0)
			alert("Username already exists\nIf this is your username, please sign in or contact your account manager");
		showHideAdditional(lastuser,0);
		proceed('bar_payment','bar_personal');
		return false;
	}
	*/
}
function checkValid(str,ctr)
{
	switch(str)
	{
		case "email":
			if(typeof(ctr) != 'undefined' && typeof(ctr) != 'null'  && ctr) {
				obj = ge('email'+ctr);
				if (obj.value!="")
					ajaxValid("/membership/ajax.cfm?email="+obj.value,"validEmail"+ctr);
			} else {
				obj = window.document.subscriptionForm.email;
				if (obj.value!="") {
					ajaxValid("/membership/ajax.cfm?email="+obj.value,"validEmail");
					synchAdditional('email');
				}
			}	
			break;
		case "username":
			obj = window.document.subscriptionForm.username;
			if (obj.value!="")
				ajaxValid("/membership/ajax.cfm?username="+obj.value,"validUsername");
			break;
		break;	
	}
}
function ajaxValid(urlstr,obj)
{
	ajaxCaller.getPlainText(urlstr, validReturn, obj);
	return false;
}
function validReturn(text,callingContext,headers,arrParams)
{
	window.document.getElementById(callingContext).value = text.replace(/ /g,"");
}
function doClone(num)
{
	var cloneObj = window.document.getElementById("bar_personal_boxUSERNUM").cloneNode(true);
	cloneObj.innerHTML = cloneObj.innerHTML.replace(/USERNUM/g,num);
	cloneObj.id = cloneObj.id.replace(/USERNUM/g,num);
	window.document.getElementById("additionalUsersHTML").appendChild(cloneObj);
}
function synchAdditional(str)
{
	for (var i=1;i<=window.document.getElementById("additionalusers").value;i++)
	{
		if (window.document.getElementById(str+i).value.replace(/ /g,"") == "")
		window.document.getElementById(str+i).value = str=="email"?window.document.getElementById(str).value.substr(window.document.getElementById(str).value.indexOf("@")):window.document.getElementById(str).value;
	}
}
function winOpen(num)
{
	strUrl = num==1?"https://www.comtrust.co.ae/SecureSeal/ValidateCert.asp?id=0132":"cvc.cfm";
	window.open(strUrl,'cvc','toolbar=no,statusbar=no,scrollbars=yes,width=542,height=541');
	return false;
}

function multiply(n1, n2) {
	return parseFloat(n1) * parseFloat(n2);
}
function updateBCLSelect(frm) {
	with(frm) {
		selIdx = bcldownload.selectedIndex;
		bcldownload.options.length = 0;
		for(i=0;i<=parseInt(additionalusers.options[additionalusers.selectedIndex].value)+1;i++) {
		 	bcldownload.options[i] = new Option(i,i);
			if(i>1) doClone(i-1);
		}	
		if(bcldownload.options.length > selIdx) 
			bcldownload.selectedIndex = selIdx;
		addBCLCheckboxes(frm);
	}
}
function addBCLCheckboxes(frm) {
	with(frm) {
		totUsers = parseInt(additionalusers.options[additionalusers.selectedIndex].value);
		totBCL = parseInt(bcldownload.options[bcldownload.selectedIndex].value);
		for(i=0; i<=totUsers;i++) {
			span = ge('span_bcldownload' + (i ? i:''));
			span.className = totBCL ? 'notgone' : 'gone';
			if(totBCL && totBCL==totUsers+1) {
				if(bclChk.length) {
					bclChk[i].checked=true;
				} else 
					bclChk.checked=true;
			}	
		}	
	}	
}
function validateBCLCheckBoxes(chk) {
	if(!chk.checked) return false;
	frm = chk.form;
	with(frm) {
		totUsers = parseInt(additionalusers.options[additionalusers.selectedIndex].value) + 1;
		if(totUsers > 1 && bclChk.length) {
			bclchkCtr = 0;
			for(i=0;i<bclChk.length;i++) 
				if(bclChk[i].checked) 
					bclchkCtr++;
			totBCL = parseInt(bcldownload.options[bcldownload.selectedIndex].value);
			if(bclchkCtr > totBCL) {
				chk.checked = false;
				alert('Download Companies is limited for ' + totBCL + ' member' + (totBCL>1?'s':'') + ' only.\nPlease click the back button to add more.');
				return false;
			}	
		}
	}
	return false;
}
function calcTotal(whichOne,frm,sel) {
	ge("additionalUsersHTML").innerHTML = ""; // reset the cloned users
	with (frm) {
		switch (whichOne) {
			case 'ZBD':
				if(radTerm[0].checked || radTerm[1].checked) {
					// Yearly
					updateBCLSelect(frm);
					addusers = parseInt(additionalusers.options[additionalusers.selectedIndex].value);
					totalAdd = addusers ? addusers * productAddPrice.value : addusers;
					ge('addusertotal').innerHTML = '$' + formatnum(totalAdd,0);	
					bclDownload = parseInt(bcldownload.options[bcldownload.selectedIndex].value);
					totalBCL = bclDownload ? bclDownload * productBCLPrice.value : bclDownload;
					ge('bcldownloadtotal').innerHTML = '$' + formatnum(totalBCL,0);	
					tot = parseFloat(productPrice.value) + parseFloat(totalAdd) + parseFloat(totalBCL);
				} else {
					// Monthly
					addusers = parseInt(additionalusers.options[additionalusers.selectedIndex].value) + 1;
					tot = addusers ? addusers * productMonthPrice.value : addusers;
					ge('zbdmonthlytotal').innerHTML = '$' + formatnum(tot,0);	
					if(parseInt(additionalusers.options[additionalusers.selectedIndex].value)) {
						ge('span_bcldownload').className='gone';
						for(i=1;i<=parseInt(additionalusers.options[additionalusers.selectedIndex].value);i++) doClone(i);
					}	
				}	
				break;
			default: 
				updateBCLSelect(frm);
				addusers = parseInt(additionalusers.options[additionalusers.selectedIndex].value);
				totalAdd = addusers ? addusers * productAddPrice.value : addusers;
				ge('addusertotal').innerHTML = '$' + formatnum(totalAdd,0);	
				bclDownload = parseInt(bcldownload.options[bcldownload.selectedIndex].value);
				totalBCL = bclDownload ? bclDownload * productBCLPrice.value : bclDownload;
				ge('bcldownloadtotal').innerHTML = '$' + formatnum(totalBCL,0);	
				tot = parseFloat(productPrice.value) + parseFloat(totalAdd) + parseFloat(totalBCL);
				break;
		}
		ge('total').innerHTML = '$' + formatnum(tot,0);
	}
}

function insertFrame(divid) {
	if(typeof document.body.style.maxHeight == "undefined") {
  	div = ge(divid);
		par = div.parentNode;
		if(par.lastChild.tagName != 'IFRAME') {
			var iframeEl = document.createElement('iframe');
			iframeEl.style.position = 'absolute' ;
			iframeEl.style.zIndex = 0;
			iframeEl.frameBorder = "none";
		 	iframeEl.style.top= div.offsetTop+'px';
		 	iframeEl.style.left= div.offsetLeft+'px';
		 	iframeEl.style.width= div.offsetWidth + 'px';
		 	iframeEl.style.height= div.offsetHeight + 'px';
	 	  par.appendChild(iframeEl);
		}
	}
	//else it's ok	
}

function matchheights(divid,ctr) {
	var arDivs = new Array();
	var maxheight = 0;
	for(i=0;i<ctr;i++) {
		arDivs[i] = ge(divid+(i+1));
		if(arDivs[i].offsetHeight)
			divheight=arDivs[i].offsetHeight;
		else if(arDivs[i].style.pixelHeight)
			divheight=arDivs[i].style.pixelHeight;
		maxheight = Math.max(maxheight,divheight);
	}
	for(i=0;i<ctr;i++) {
		arDivs[i].style.height = maxheight + 'px';
	}
	return false;
}

/* end of JS from subscribe.js */