var AccordionMenu =(function()
{
	var YUD = YAHOO.util.Dom;
	var YUE = YAHOO.util.Event;
	var oMenuSetting = {};
	var oMenuCache = {};
	var dLastHoverTitle ;
	YUD.addClass(document.documentElement,'accordion-menu-js');
	
	function getDT(e)
	{
		var dEl = YUE.getTarget(e);
		if(	(e.tagName + '').toUpperCase()=='DD' )
		{	
			var dt = e.previousSibling ;
			while(dt)
			{
				if(dt.tagName &&  dt.tagName.toUpperCase() == 'DT'){break;};
				dt = dt.previousSibling
			};
			
			if(!dt || dt.tagName.toUpperCase() != 'DT'){return;}
			else{return (dt.tagName==='DT')?dt:null};
		}
		else if(e.clientX)
		{
			var found = false;
			while( dEl.parentNode)
			{
				if(YUD.hasClass(dEl,'a-m-t')){found  = true ; break;};
				
				//
				dEl = dEl.parentNode;
			};
			if(!found){return null}
			else{return (dEl.tagName==='DT')?dEl:null };	
		};		
	};
	
	
	
	function getDD(dt)
	{
		if(!dt){return null;};
		var dd = dt.nextSibling ;
	
		while(dd)
		{	
			if(dd.tagName && dd.tagName.toUpperCase() == 'DD'){break;};
			dd = dd.nextSibling;
			
		};
		if(!dd || dd.tagName.toUpperCase() != 'DD'){return;}
		else{return dd};
	};
	
	function expand(dl,dt,dd)
	{
		dl.hasAnimation +=1;
		YUD.addClass(dd,'a-m-d-before-expand');		
		var oAttr = {height:{from:0,to:dd.offsetHeight }};
		
		YUD.removeClass(dd,'a-m-d-before-expand');
		
		var onComplete = function()
		{	
			oAnim.onComplete.unsubscribe(onComplete);
			oAnim.stop();
			YUD.removeClass(dd,'a-m-d-anim');
			YUD.addClass(dd,'a-m-d-expand');
			onComplete = null;	
			dl.hasAnimation -=1;
			var dt = getDT(dd);	
			YUD.addClass(dt,'a-m-t-expand');
			if( oMenuCache[ dl.id ] &&  oMenuCache[ dl.id ].onOpen && dd.style.height!='' )
			{	
				oMenuCache[ dl.id ].onOpen(	 {dl:dl,dt:dt,dd:dd} );								
			};	
			dd.style.height = '';
		
		};
		
		var onTween = function()
		{
			if(dd.style.height)
			{	
				YUD.addClass(dd,'a-m-d-anim');				
				oAnim.onTween.unsubscribe(onTween);
				onTween = null;
				dd.oAnim = null;
			};
			
		};
		
		if(dd.oAnim)
		{
			dd.oAnim.stop();
			dd.oAnim = null;
			dl.hasAnimation -=1;	
		};
		var oEaseType = YAHOO.util.Easing.easeOut;
		var seconds = 0.5;

		if(oMenuCache[ dl.id ] )
		{
			oEaseType = oMenuCache[ dl.id ]['easeOut']?oEaseType:YAHOO.util.Easing.easeIn;
			seconds =  oMenuCache[ dl.id ]['seconds'];
			
			if( !oMenuCache[ dl.id ]['animation'] )
			{
				var oAnim = {onComplete:{unsubscribe:function(){}},stop:function(){}};
				onComplete();
				return;
			};
		};
		
		
		var oAnim = new YAHOO.util.Anim(dd,oAttr,seconds ,oEaseType);
		oAnim.onComplete.subscribe(onComplete);	
		oAnim.onTween.subscribe(onTween);
		oAnim.animate();
		dd.oAnim = oAnim ;
	
	};
	
	function collapse(dl,dt,dd)
	{
		dl.hasAnimation +=1;
		YUD.addClass(dd,'a-m-d-anim');
		var oAttr = {height:{from:dd.offsetHeight,to:0}};
		
		
		var onComplete = function()
		{
			oAnim.onComplete.unsubscribe(onComplete);
			YUD.removeClass(dd,'a-m-d-anim');
			YUD.removeClass(dd,'a-m-d-expand');
			dd.style.height = '';
			dd.oAnim = null;
			onComplete = null;	
			dl.hasAnimation -=1;	
			var dt = getDT(dd);	
			YUD.removeClass(dt,'a-m-t-expand');	
			if( oMenuCache[ dl.id ] &&  oMenuCache[ dl.id ].onOpen )
			{				
				oMenuCache[ dl.id ].onClose(	 {dl:dl,dt:dt,dd:dd} );
			};			
			
		};
		
		if(dd.oAnim)
		{
			dd.oAnim.stop();
			dd.oAnim = null;
			dl.hasAnimation -=1;	
		};
		
		var oEaseType = YAHOO.util.Easing.easeOut;
		var seconds = 0.5;
		if(oMenuCache[ dl.id ] )
		{
			oEaseType = oMenuCache[ dl.id ]['easeOut']?oEaseType:YAHOO.util.Easing.easeIn;
			seconds =  oMenuCache[ dl.id ]['seconds'];
			if( !oMenuCache[ dl.id ]['animation'] )
			{
				var oAnim = {onComplete:{unsubscribe:function(){}},stop:function(){}};
				onComplete();
				return;
			};	
		};
		
		var oAnim = new YAHOO.util.Anim(dd,oAttr,seconds ,oEaseType);	
		oAnim.onComplete.subscribe(onComplete);	
		oAnim.animate();
		dd.oAnim = oAnim ;
	};
	
	function collapseAll(dl,dt,dd)
	{
		var aOtherDD = YUD.getElementsByClassName('a-m-d-expand','dd',dl);
		for(var i=0;i<aOtherDD.length;i++)
		{
			var otherDD = aOtherDD[i] ;
			if( otherDD !=dd )
			{
				collapse(dl,null,otherDD);
			};				
		};
	}
	
	
	var onMenuMouseover = function(e)
	{
		var dMenuTitle = getDT(e);
		if(!dMenuTitle){return;};
		if(dLastHoverTitle)
		{
			YUD.removeClass(dLastHoverTitle,'a-m-t-hover');
		};		
		YUD.addClass(dMenuTitle,'a-m-t-hover');
		dLastHoverTitle = dMenuTitle ;
		YUE.preventDefault(e);
		return false;		
	};
	
	var onMenuMouseout = function(e)
	{
		var dMenuTitle = getDT(e);
		if(!dMenuTitle){return;};
		if(dLastHoverTitle && dLastHoverTitle!=dMenuTitle)
		{
			YUD.removeClass(dLastHoverTitle,'a-m-t-hover');
			YUD.removeClass(dLastHoverTitle,'a-m-t-down');
		};	
		YUD.removeClass(dMenuTitle,'a-m-t-down');	
		YUD.removeClass(dMenuTitle,'a-m-t-hover');
		dLastHoverTitle = null ;
		YUE.preventDefault(e);
		return false;		
	};
	
	var onMenuMousedown = function(e)
	{
		var dMenuTitle = getDT(e);
		if(!dMenuTitle){return;};	
		YUD.addClass(dMenuTitle,'a-m-t-down');
		YUE.preventDefault(e);
		return false;	
	};
	
	//var onMenuClick = function(e){
	
	var onMenuClick1 = function(e)
	{
		
		var dt = getDT(e);
		if(!dt){return;};
		
		click_id=document.Form1.dtid.value;
		
		click_id='dt_'+click_id;
		if(click_id!='dt_1')
		{
		errs='';
		errs=ValidateStep1();
		if(errs!="")
		{
			document.Form1.md.value=1;
			//MakeActiveClass('dt_1');
			return;
			
		}
		else
		{	if(click_id=='dt_3')
			{
				if(document.Form1.friend.value=='0' && document.Form1.partner.value=='0'  && document.Form1.children.value=='0')
				{
					//ejpAlert("You must select either number of friends/partners/children to go to this step");
					click_id='dt_4';
					AccordionMenu.openDtById('4');
					//return;
				}
				else
				{
					MakeActiveClass(click_id);
				}
			}
			if(click_id=='dt_4')
			{
				errs='';
				if(document.Form1.friend.value!='0' || document.Form1.partner.value!='0'  || document.Form1.children.value!='0')
				{
					errs=ValidateStep3();	
					if(errs!="")
					{	
						document.Form1.md.value=3;
						//MakeActiveClass('dt_3');
						return;
					}
				}
				MakeActiveClass('dt_4');
				var friends;
				var partners;
				var childrens;
				var sign_fees;
				var cost;
				var discount;
				var total;
								
				friends=document.Form1.friend.value;
				partners=document.Form1.partner.value;
				childrens=document.Form1.children.value;
				sign_fees=document.Form1.signup_fee.value;				
			
				member_cost=document.Form1.member_cost.value;
				friend_cost=document.Form1.friend_cost.value*friends;
				partner_cost=document.Form1.partner_cost.value*partners;
				children_cost=document.Form1.children_cost.value*childrens;

/*				partner_cost=parseFloat((parseFloat(document.Form1.partner_cost.value)*partners);
				children_cost=parseFloat((parseFloat(document.Form1.children_cost.value)*childrens);
*/																				
				cost=parseFloat(member_cost)+parseFloat(friend_cost)+parseFloat(partner_cost)+parseFloat(children_cost);

				var disc=document.Form1.discount_hidden.value;							
			
				discount=cost * (parseFloat(disc.substr(0,disc.length-1) / 100));
				document.Form1.cost.value=euro_symbol+" "+ parseFloat(cost);				
				document.Form1.sign_fee.value=euro_symbol+" "+ parseFloat(sign_fees);
				document.Form1.discount.value=euro_symbol+" "+ parseFloat(discount);
				
				document.Form1.total.value=euro_symbol+" "+ parseFloat(cost-discount)+parseFloat(sign_fees);
			

			}
			else
			{
				MakeActiveClass(click_id);
				
			}
			
		}
		// My Code End
		}
		else
		{
			MakeActiveClass(click_id);
		}
		
		var dd = getDD(dt);
		
		if(!dd){return;};
		var dl = dt.parentNode;
		
		
		if(dl.hasAnimation==null)
		{
			dl.hasAnimation = 0;
		}	
		if(dl.hasAnimation > 0 ){return;};
		YUD.removeClass(dt,'a-m-t-down');
		
		if(YUD.hasClass(dd,'a-m-d-expand'))
		{	
			collapse(dl,dt,dd);
		}
		else
		{			
			if( oMenuCache[ dl.id ] &&  oMenuCache[ dl.id ].dependent == false ){}
			else{collapseAll(dl,dt,dd);}
			expand(dl,dt,dd);
		};		
		YUE.preventDefault(e);
		return false;
	};
	
	
	YUE.on( document,'mouseover',onMenuMouseover);
	YUE.on( document,'mouseout',onMenuMouseout);
	YUE.on( document,'mousedown',onMenuMousedown);
	//YUE.on( document,'click',onMenuClick);
	
  var oApi = {
  
	getDT_Cust : function(e)
	{
		var dEl = YUE.getTarget(e);
		if(	(e.tagName + '').toUpperCase()=='DD' )
		{	
			var dt = e.previousSibling ;
			while(dt)
			{
				if(dt.tagName &&  dt.tagName.toUpperCase() == 'DT'){break;};
				dt = dt.previousSibling
			};
			
			if(!dt || dt.tagName.toUpperCase() != 'DT'){return;}
			else{return (dt.tagName==='DT')?dt:null};
		}
		else if(e.clientX)
		{
			var found = false;
			while( dEl.parentNode)
			{
				if(YUD.hasClass(dEl,'a-m-t')){found  = true ; break;};
				
				//
				dEl = dEl.parentNode;
			};
			if(!found){return null}
			else{return (dEl.tagName==='DT')?dEl:null };	
		};		
	},
	openDtById : function(sId)
	{
		var dt = document.getElementById(sId);
		
		if(!dt){return;};
		if(!YUD.hasClass(dt,'a-m-t')){return;};
		var dl = dt.parentNode;
		var dd = getDD(dt);
		if(dl.hasAnimation==null){dl.hasAnimation = 0;};
		
		if(dl.hasAnimation > 0 ){return;};
		if(YUD.hasClass(dd,'a-m-d-expand')){return;};
		if( oMenuCache[ dl.id ] &&  oMenuCache[ dl.id ].dependent == false ){}
		else{collapseAll(dl,dt,dd);}
		expand(dl,dt,dd);
	},
	
	closeDtById : function(sId)
	{
		var dt = document.getElementById(sId);
		if(!dt){return;};
		if(!YUD.hasClass(dt,'a-m-t')){return;};
		var dl = dt.parentNode;
		var dd = getDD(dt);
		if(dl.hasAnimation==null){dl.hasAnimation = 0;};
		if(dl.hasAnimation > 0 ){return;};
		if(!YUD.hasClass(dd,'a-m-d-expand')){return;};
		collapse(dl,dt,dd);
	},
	
	
	setting : function(id,oOptions)
	{	
		if( !oOptions ){return;};
	
		if( typeof(id)!='string' ){return;};
	
		var setMunu = function(dl)
		{	
			dl = dl || this;
			dl.hasAnimation = 0;
			oMenuCache[ dl.id ] = 
			{
				element:dl,
				dependent:true,
				onOpen:function(){},
				onClose:function(){},
				seconds:0.5,
				easeOut:true,
				openedIds:[],
				animation:true
			};
			oMenu =  oMenuCache[ dl.id ] ;
			
			if(typeof(oOptions['animation'])=='boolean')
			{
				oMenu['animation'] = !!oOptions['animation']; 
				
			};
			
			
			if(typeof(oOptions['dependent'])=='boolean')
			{
				oMenu['dependent'] = !!oOptions['dependent']; 
			};
			
			if(typeof(oOptions['easeOut'])=='boolean')
			{
				oMenu['easeOut'] = !!oOptions['easeOut']; 
			};
			
			if(typeof(oOptions['seconds'])=='number')
			{
				oMenu['seconds'] = Math.max(0 , oOptions['seconds'] ); 
			};
			
			if(typeof(oOptions['onOpen'])=='function')
			{
				oMenu['onOpen'] = oOptions['onOpen'];
			};
			
			if(typeof(oOptions['onClose'])=='function')
			{
				oMenu['onClose'] = oOptions['onClose'];
			};
		
			if(oOptions['openedIds'].shift)
			{
				oMenu['openedIds'] = oOptions['openedIds'];
			};
			
			
			for(var i=0;i<oMenu['openedIds'].length;i++)
			{
				var sId = oMenu['openedIds'][i];
				var dt = document.getElementById( sId  );
				
				if(dt && dt.tagName.toUpperCase() == 'DT')
				{
					var dl = dt.parentNode;
					var dd = getDD(dt);
					expand(dl,dt,dd);
				}
				else if(!dt)
				{
					function onDtAvailable()
					{
						var dt = this;
						if(dt.tagName.toUpperCase() == 'DT')
						{
							var dl = dt.parentNode;
							var dd = getDD(dt);
							expand(dl,dt,dd);
						};	
					};
					
					YUE.onAvailable(sId,onDtAvailable);
				}			
			};
			
			
		};
		
		if(document.getElementById(id))
		{
			setMunu(document.getElementById(id))
		}
		else
		{	
			YUE.onAvailable(id,setMunu);	
		};	
	}
 };//endof api
 
 return oApi;
 
})();
function onMenuClick(){
	var errs;
	p_err='';
	//var dt = AccordionMenu.getDT_Cust(e);
	//if(!dt){return;};
	
	if(document.Form1.process.value!='YES'){return;};
	//document.Form1.discount_hidden.value='0%';
	click_id=document.Form1.dtid.value;
	click_id='dt_'+click_id;
	if(click_id=='dt_4')
	{
		createForm();
		special_discount();
	}
	para=trim(document.Form1.coupon_code.value);
	/*if(para!='')
	{*/
		
		/*XMLHTTP = createXmlHttpObj();
		if(XMLHTTP == null)
		{
			ejpAlert(JSalert_xmlhttp);
			return false;
		}
		var url = "chkemail.php";
		q='';
		if(document.Form1.email.value!="")
		{
			if((validateEmail(document.Form1.email)==true) && (document.Form1.email.value==document.Form1.cemail.value))
			{
				q = "?e=" + document.Form1.email.value;	
			}
		}
		if(q!='')
		{
			url=url + q;
		}
		XMLHTTP.onreadystatechange = stateChanged;
		XMLHTTP.open("GET",url,true);
		XMLHTTP.send(null);*/
		
		ValidateAllValues('dt_'+document.Form1.dtid.value);
		
/*	}*/
	/*else
	{
		ValidateAllValues(click_id);
	}*/
	
	document.Form1.process.value='NO';
	//calculateTotal();
	special_discount();
	return;
	}
function special_discount()
{
	var total_friend=0;
	total_friend=document.Form1.friend.value;
	var total_partner=0;
	total_partner=document.Form1.partner.value;
	var total_children=0; 
	total_children=document.Form1.children.value;
	
	XMLHTTP = createXmlHttpObj();
	if(XMLHTTP == null)
	{
		ejpAlert("Sorry!,Your Browser doen't have support for XmlHttp object");
		return false;
	}
	//creare URL for Call to AJAX Server 
	var url = "special_discount.php";
	q='?nofrnd='+total_friend+'&nopart='+total_partner+'&nochld='+total_children;
	url=url + q;
	XMLHTTP.onreadystatechange = stateChanged_spdiscount;
	XMLHTTP.open("GET",url,true);
	XMLHTTP.send(null);
}
function stateChanged_spdiscount(){
	if( XMLHTTP.readyState == 4 )
	{
		document.Form1.frst_1000_memdiscount.value='OFF';
		document.Form1.family_memdiscount.value='OFF';
		document.Form1.couples_memdiscount.value='OFF';
		document.Form1.business_memdiscount.value='OFF';
		document.Form1.onetoonefree_memdiscount.value='OFF';
		var response_val=XMLHTTP.responseText;
		if(response_val!='')
		{
			var col_array=response_val.split(",");
			for(i=0;i<col_array.length;i++)
			{
				var colarray1=col_array[i];
				//ejpAlert(colarray1);
				var frmarray=colarray1.split('=');
				var frmarray1=frmarray[0];
				//ejpAlert(frmarray[0]);
				var frmvariable=eval('document.Form1.' + frmarray1);
				frmvariable.value=frmarray[1];
				//ejpAlert(frmvariable.value);
			}
		calculateTotal();
		}
		//ejpAlert(document.getElementById('specialdiscount').innerHTML);
	}
}




function MakeActiveClass(act_id)
{
	if(act_id=='dt_1')
	{
    
        
		document.getElementById('dt_1').className='head_12sign_act';
		document.getElementById('dt_2').className='head_12sign';
		document.getElementById('dt_3').className='head_12sign';
		document.getElementById('dt_4').className='head_12sign';
		
		document.getElementById('i_1').innerHTML='<img src="images/orangeman.png" border="0" />';
		document.getElementById('i_2').innerHTML='<img src="images/greyman.png" border="0" />';
		document.getElementById('i_3').innerHTML='<img src="images/greyman.png" border="0" />';
		document.getElementById('i_4').innerHTML='<img src="images/greyman.png" border="0" />';
		
		


	}
	else if(act_id=='dt_2')
	{
		document.getElementById('dt_1').className='head_12sign';
		document.getElementById('dt_2').className='head_12sign_act';
		document.getElementById('dt_3').className='head_12sign';
		document.getElementById('dt_4').className='head_12sign';
		
		document.getElementById('i_1').innerHTML='<img src="images/greyman.png" border="0" />';
		document.getElementById('i_2').innerHTML='<img src="images/orangeman.png" border="0" />';
		document.getElementById('i_3').innerHTML='<img src="images/greyman.png" border="0" />';
		document.getElementById('i_4').innerHTML='<img src="images/greyman.png" border="0" />';
		
		
		
	}
	else if(act_id=='dt_3')
	{
		createForm();
		document.getElementById('dt_1').className='head_12sign';
		document.getElementById('dt_2').className='head_12sign';
		document.getElementById('dt_3').className='head_12sign_act';
		document.getElementById('dt_4').className='head_12sign';
		
		document.getElementById('i_1').innerHTML='<img src="images/greyman.png" border="0" />';
		document.getElementById('i_2').innerHTML='<img src="images/greyman.png" border="0" />';
		document.getElementById('i_3').innerHTML='<img src="images/orangeman.png" border="0" />';
		document.getElementById('i_4').innerHTML='<img src="images/greyman.png" border="0" />';
		
		

	}
	else if(act_id=='dt_4')
	{
		document.getElementById('dt_1').className='head_12sign';
		document.getElementById('dt_2').className='head_12sign';
		document.getElementById('dt_3').className='head_12sign';
		document.getElementById('dt_4').className='head_12sign_act';
		
		document.getElementById('i_1').innerHTML='<img src="images/greyman.png" border="0" />';
		document.getElementById('i_2').innerHTML='<img src="images/greyman.png" border="0" />';
		document.getElementById('i_3').innerHTML='<img src="images/greyman.png" border="0" />';
		document.getElementById('i_4').innerHTML='<img src="images/orangeman.png" border="0" />';
		
	
		
	}
}


var p_err;
p_err='';
function ValidateStep1()
{
	if(document.Form1.title.value=="")
	{
		p_err+="* " + JSalert_title + '\n';
	}
	if(document.Form1.fname.value=="")
	{
		p_err+="* "+JSalert_firstname+'\n';
	}
	else if(document.Form1.fname.value.length<2)
	{
		p_err+="* "+JSalert_firstnameminimum+'\n';
	}
	if(document.Form1.lname.value=="")
	{
		p_err+="* "+JSalert_lastname+'\n';
	}
	/*if(document.Form1.dob.value=="")
	{
		p_err+="* "+JSalert_dob+'\n';
	}*/
	if(document.Form1.date.value=="" || document.Form1.date.value=="0")
	{
		p_err+="* "+JSalert_dob+'\n';
	}
	if(document.Form1.month.value=="" || document.Form1.month.value=="0")
	{
		p_err+="* "+JSalert_mob+'\n';
	}
	if(document.Form1.year.value=="" || document.Form1.year.value=="0")
	{
		p_err+="* "+JSalert_yob+'\n';
	}
	if(document.Form1.address.value=="")
	{
		p_err+="* "+JSalert_address+'\n';
	}
	if(document.Form1.city.value=="")
	{
		p_err+="* "+JSalert_city+'\n';
	}
	if(document.Form1.country.value=="")
	{
		p_err+="* "+JSalert_country+'\n';
	}
	
	if(document.Form1.postcode.value=="")
	{
		p_err+="* "+JSalert_postcode+'\n';
	}
	
	if(document.Form1.postcode.value.match('[^a-zA-Z0-9 -]'))
	{
		p_err+="* "+JSalert_postcode+'\n';
	}
		
	
	
	if(document.Form1.country.value=="223")
		{
		var st=	document.Form1.address3.value.toUpperCase();
		if(!checkstate(trim(st))){ 
		p_err+="* "+JSalert_invalidstate+'\n';
		}
	}
	

	
	
	
	if(document.Form1.email.value=="")
	{
		p_err+="* "+JSalert_email+'\n';
	}
	if(document.Form1.email.value!="")
	{
		if(validateEmail(document.Form1.email)==false)
		{
			p_err+="* "+JSalert_validemail+'\n';
		}
		if(document.Form1.email.value!=document.Form1.cemail.value)
		{
			p_err+="* "+JSalert_matchemail+'\n';
		}
	}
	if(document.Form1.coupon_code.value!="")
	{
		//callToAJAX(document.Form1.coupon_code.value);	
	}
	else
	{
		document.Form1.discount_hidden.value='0%';
	}
	if(p_err!='')
	{
		p_err="" + p_err;
		//ejpAlert(p_err);
		ejpAlert(p_err);
		err_find='YES';
	}
	else
	{
		err_find='';	
	}
	return err_find;
}
function validateEmail(email) {//passing controlas a argument
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if (!re_mail.test(email.value)) {
		//ejpAlert("Error");
		//email.focus();
		//email.select();
		return false;
	}

	return true;
}

var XMLHTTP = null;

function ValidateAllValues(click_id)
{
	if(ValidateStep1()=='')
		{
			if(click_id=='dt_3')
			{
				if(document.Form1.friend.value=='0' && document.Form1.partner.value=='0'  && document.Form1.children.value=='0')
				{
					if(document.Form1.cur_for_3.value=='2')
					{
						document.Form1.dtid.value=2;
						document.Form1.cur_for_3.value='4';
					}
					else
					{
						document.Form1.dtid.value=4;
					}
					
				}
				
			}
			if(document.Form1.dtid.value=='4')
			{
				errs='';
				if(document.Form1.friend.value!='0' || document.Form1.partner.value!='0'  || document.Form1.children.value!='0')
				{
					errs=ValidateStep3();	
					if(errs!="")
					{	
						document.Form1.dtid.value=3;
					}
				}
				calculateTotal();
				//document.Form1.total.value=(parseFloat(cost-discount)+parseFloat(sign_fees));
			}
		}
		else
		{
			document.Form1.dtid.value=1;
		}
		document.Form1.md.value=document.Form1.dtid.value;
		MakeActiveClass('dt_'+document.Form1.dtid.value);
		AccordionMenu.openDtById(document.Form1.dtid.value);
}
function calculateTotal()
{
				var friends;
				var partners;
				var childrens;
				var cost;
				var discount;
				var total;
			
				var purch_list='<table  class="ordersummarytable" style="border-collapse: separate;" border="0" width="100%" cellpadding="0" cellspacing="5">';
				
				
				purch_list+='<tr>';
				purch_list+='<th colspan="2">'+JSpurchaseditems+'</th>';
				purch_list+='<th style="text-align:right">'+JSamount+'</th>';

				purch_list+='</tr>';


				friends=document.Form1.friend.value;
				partners=document.Form1.partner.value;
				childrens=document.Form1.children.value;
				sign_fees=document.Form1.signup_fee.value;
				euro_symbol=document.Form1.euro_symbol.value;
				
				//member_cost=document.Form1.member_cost.value;
				friend_cost=document.Form1.friend_cost.value*friends;
				//partner_cost=document.Form1.partner_cost.value*partners;
				//children_cost=document.Form1.children_cost.value*childrens;
				//ejpAlert(document.Form1.frst_1000_memdiscount.value);
				
/* CHANGE FIRST 1000 SIGNUP FEES FREE SPECIAL DISCOUNT START */	
				if(document.Form1.frst_1000_memdiscount.value=='ON')
				{
					//sign_fees=0;
					document.Form1.signup_fee.value=parseFloat(document.Form1.signupfeesfrst100mem_config.value) + parseFloat(document.Form1.recorded.value); 
					document.Form1.sign_fee.value=parseFloat(document.Form1.signupfeesfrst100mem_config.value) + parseFloat(document.Form1.recorded.value); 
				}else
				{
					document.Form1.signup_fee.value=parseFloat(document.Form1.signup_fee_org.value) + parseFloat(document.Form1.recorded.value);
					document.Form1.sign_fee.value=parseFloat(document.Form1.signup_fee_org.value) + parseFloat(document.Form1.recorded.value);
				}
				sign_fees=document.Form1.signup_fee.value;	
				//ejpAlert(sign_fees);
				document.getElementById('sp_sign_fee').innerHTML=parseFloat(sign_fees).toFixed(2);
/* CHANGE FAMILY SPECIAL DISCOUNT START */				
				if(document.Form1.family_memdiscount.value=='ON')
				{
					var total_child=childrens;
					var special_discount_child_num=document.Form1.noofchild_config.value;
					if(total_child>=special_discount_child_num) /*HERE 2 CHECKING FOR NO OF CHILDREN */
					{
						var childrens=total_child-special_discount_child_num; /* HERE "2" INDICATES NO OF CHILDREN */
						var special_discount_child_cost=special_discount_child_num*document.Form1.childcost_config.value
						children_cost=document.Form1.children_cost.value*childrens + special_discount_child_cost; //SPECIAL DISCOUNT PRICE FOR TWO CHILDREN=20
					}else
					{
						var childrens=total_child;	
						children_cost=document.Form1.children_cost.value*childrens;
					}
/* CHANGE FAMILY SPECIAL DISCOUNT END */					
				}else
				{
					children_cost=document.Form1.children_cost.value*childrens;	
				}
/* CHANGE COUPLE SPECIAL DISCOUNT START */
				if(document.Form1.couples_memdiscount.value=='ON')
				{
					partner_cost=document.Form1.partner_cost.value*partners;
					partner_cost=partner_cost-document.Form1.partnercost_config.value; /* HERE '15' IS THE DEDUCT AMOUNT FROM PARTNER  */
				}else
				{
					partner_cost=document.Form1.partner_cost.value*partners;	
				}
/* CHANGE COUPLE SPECIAL DISCOUNT END */
/* CHANGE BUSINESS SPECIAL DISCOUNT START */
				if(document.Form1.business_memdiscount.value=='ON')
				{
					member_cost=document.Form1.member_cost.value;
					frnd_cost_config=document.Form1.frnddiscountcost_config.value;
					member_cost=parseFloat(parseFloat(member_cost)-parseFloat(((member_cost*frnd_cost_config)/100))); /* HERE parseFloat(((member_cost*10)/100)) IS USED FOR 10% OFF FORM PRIMARY MEMBER */
				}else
				{
					member_cost=document.Form1.member_cost.value;	
				}
/* CHANGE BUSINESS SPECIAL DISCOUNT END */
				/*if(document.Form1.onetoonefree_memdiscount.value=='ON')
				{
					ejpAlert("onetoonefree_memdiscount exist");	
				}*/
				cost=parseFloat(member_cost)+parseFloat(friend_cost)+parseFloat(partner_cost)+parseFloat(children_cost);
				if(document.Form1.onetoonefree_memdiscount.value=='ON')
				{
					friend_cost=document.Form1.friend_cost.value;
					partner_cost=document.Form1.partner_cost.value
					children_cost=document.Form1.children_cost.value;
					var maxvalue=Math.max(friend_cost,partner_cost);
					maxvalue=Math.max(maxvalue,children_cost);
					if(maxvalue=friend_cost)
					{
						maxvaluemem=friends;	
					}else if(maxvalue=partner_cost)
					{
						maxvaluemem=partner;	
					}else if(maxvalue=partner_cost)
					{
						maxvaluemem=partner;	
					}
				}
				var disc=document.Form1.discount_hidden.value;
				
				partners=document.Form1.partner.value;
				childrens=document.Form1.children.value;
				sign_fees=document.Form1.signup_fee.value;
				friend_cost=document.Form1.friend_cost.value;
				
				
				purch_list+='<tr>';
				purch_list+='<th colspan="3"  >'+JSprimarymember+'</th>';
				purch_list+='</tr>';
				purch_list+='<tr>';
				purch_list+='<td  >'+JSname+'</td>';
				purch_list+='<td class="black">'+ document.Form1.title.value+'&nbsp;'+document.Form1.fname.value+'&nbsp;'+document.Form1.lname.value + '</td>';
				purch_list+='<td class="black" style="text-align:right">'+ euro_symbol+' '+parseFloat(member_cost).toFixed(2)+'</td>';
				purch_list+='</tr>';				
				if(friends>0)
				{
					friends=document.Form1.friend.value;
					purch_list+='</tr>';
					purch_list+='<tr>';
					purch_list+='<th colspan="3" >'+JSsn6+'</th>';
					purch_list+='</tr>';
					for(i=1;i<=friends;i++)
					{
						var e=eval('document.Form1.fri_title_'+i);
						var e1=eval('document.Form1.fri_fname_'+i);
						var e2=eval('document.Form1.fri_lname_'+i);
						if(e && e1 && e2)
						{
							purch_list+='<tr >';
							purch_list+='<td >'+JSname+'</td>';
							purch_list+='<td class="black">'+e.value+'&nbsp;'+e1.value+'&nbsp;'+e2.value+'</td>';
							purch_list+='<td class="black" style="text-align:right">'+euro_symbol+' '+parseFloat(friend_cost).toFixed(2)+'</td>';
							purch_list+='</tr>';
						}
					}
				}
				if(partners>0)
				{
					purch_list+='</tr>';
					purch_list+='<tr>';
					purch_list+='<th colspan="3">'+JSpartner+':</th>';
					purch_list+='</tr>';
					for(i=1;i<=partners;i++)
					{
						var e=eval('document.Form1.par_title_'+i);
						var e1=eval('document.Form1.par_fname_'+i);
						var e2=eval('document.Form1.par_lname_'+i);
						if(e && e1 && e2)
						{
							purch_list+='<tr >';
							purch_list+='<td  >'+JSname+'</td>';
							purch_list+='<td class="black">'+e.value+'&nbsp;'+e1.value+'&nbsp;'+e2.value+'</td>';
							purch_list+='<td class="black" style="text-align:right">'+euro_symbol+' '+parseFloat(partner_cost).toFixed(2)+'</td>';
							purch_list+='</tr>';
						}
					}
				}
				if(childrens>0)
				{
					purch_list+='</tr>';
					purch_list+='<tr>';
					purch_list+='<th colspan="3" >'+JSchildren+':</th>';
					purch_list+='</tr>';
					for(i=1;i<=childrens;i++)
					{
						var e=eval('document.Form1.child_title_'+i);
						var e1=eval('document.Form1.child_fname_'+i);
						var e2=eval('document.Form1.child_lname_'+i);
						if(e && e1 && e2)
						{
							purch_list+='<tr >';
							purch_list+='<td >'+JSname+'</td>';
							special_discount_child_num=document.Form1.noofchild_config.value;
							if(i<=special_discount_child_num && document.Form1.family_memdiscount.value=='ON')
							{
								children_cost=document.Form1.childcost_config.value;
							}else
							{
								children_cost=document.Form1.children_cost.value;		
							}
							purch_list+='<td  class="black">'+e.value+'&nbsp;'+e1.value+'&nbsp;'+e2.value+'</td>';
							purch_list+='<td  class="black" style="text-align:right">'+euro_symbol+' '+parseFloat(children_cost).toFixed(2)+'</td>';
							purch_list+='</tr>';
						}
					}
				}

				purch_list+='</table>';
				
				document.getElementById('purchased_list').innerHTML=purch_list;	

				//ejpAlert(purch_list) ;
				
				var disc=document.Form1.discount_hidden.value;
				
				if(disc.indexOf("%") > 0){
				discount=(parseFloat(cost)) * (parseFloat(disc.substr(0,disc.length-1) / 100));
				}else{
				discount=parseFloat(disc);
				}	
				
				
				document.Form1.cost.value=parseFloat(cost).toFixed(2);				
				document.getElementById('sp_cost').innerHTML=document.Form1.cost.value;
				document.Form1.discount.value=parseFloat(discount).toFixed(2);
				document.getElementById('sp_discount').innerHTML=document.Form1.discount.value;
				document.Form1.total.value=((parseFloat(cost)+parseFloat(sign_fees))-parseFloat(discount)).toFixed(2);
				document.getElementById('sp_total').innerHTML=document.Form1.total.value;
				
				//document.getElementById('sp_summary').innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;'+JSsn5;;
}
function createXmlHttpObj(){
	var XmlHttpObj=null;
		try{		//Main Try Block
			//Firefox, Opera 8+, Safari
			XmlHttpObj = new XMLHttpRequest();
			return XmlHttpObj;
		}catch(e){
			//Internet Explorer 5+
			try{	//Inner Try Block
				XmlHttpObj=new ActiveXObject("Msxml2.XMLHTTP");
				return XmlHttpObj;
			}catch(e){
				try{
					XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
					return XmlHttpObj;
				}catch(e){						
					//Redirect User to Site/Page That Doen't have Support for AJAX
					return XmlHttpObj;
				}
			 }//end of Inner Try Block
		 }//end of Main Try Block
}
function stateChanged(){

	if( XMLHTTP.readyState == 4 ){
		if(XMLHTTP.responseText!='')
		{
			/*if(XMLHTTP.responseText=='C_NO')
			{
				p_err+='* Invalid Voucher Code'+'\n';
				document.Form1.discount_hidden.value='0%';
				document.Form1.discount.value='0';
				//ValidateAllValues('dt_1');
				return;
			}
			else*/ if(XMLHTTP.responseText=='E_NO')
			{
				p_err+='* Email Already Exist.Please choose different one.'+'\n';
				ValidateAllValues('dt_1');
				return;
			}
			/*else if(XMLHTTP.responseText=='C_E_NO')
			{
				p_err+='* Invalid Voucher Code'+'\n';
				p_err+='* Email Already Exist.Please choose different one.'+'\n';
				document.Form1.discount_hidden.value='0%';
				ValidateAllValues('dt_1');
				return;
			}*/
			else
			{
				//document.Form1.discount_hidden.value=XMLHTTP.responseText;
				ValidateAllValues('dt_'+document.Form1.dtid.value);
				return XMLHTTP.responseText;
			}
		}
		else
		{
			ValidateAllValues('dt_'+document.Form1.dtid.value)
			return;
		}
			
	}
}
function getRedeem(cu,la)
{
	p_err='';
	document.Form1.discount_hidden.value='0%';
	document.Form1.discount.value='0.00';
	calculateTotal();
				
				
	if(document.Form1.coupon_code.value=='')
	{
		ejpAlert("* "+JSalert_vouchercode);
		return;
	}
	
	para=trim(document.Form1.coupon_code.value);
	em=trim(document.Form1.email.value);
	
	/*if(para!='')
	{*/
	XMLHTTP = createXmlHttpObj();
	if(XMLHTTP == null)
	{
		ejpAlert(JSalert_xmlhttp);
		return false;
	}
	//creare URL for Call to AJAX Server 
	var url = "chkvoucher.php";
	q='';
	q = "?c=" + para + "&e=" + em + "&currency=" + cu + "&language=" + la ;  
	if(para!='')
	{
		url=url + q;
		XMLHTTP.onreadystatechange = stateChanged_V;
		/*while(XMLHTTP.readyState != 4){}*/
		XMLHTTP.open("GET",url,true);
		XMLHTTP.send(null);
	}
}

function stateChanged_V(){
	if( XMLHTTP.readyState == 4 ){
		if(XMLHTTP.responseText!='')
		{
			if(XMLHTTP.responseText=='C_NO')
			{
				ejpAlert('* '+JSalert_noteligible+'\n'); 
                document.Form1.discount_hidden.value='0%';
				document.Form1.discount.value='0.00';
				return;
			}
			else
			{
				document.Form1.discount_hidden.value=XMLHTTP.responseText;
				calculateTotal();
				return;
			}
		}
		else
		{
			//ValidateAllValues('dt_'+document.Form1.dtid.value)
			document.Form1.discount_hidden.value='0%';
			document.Form1.discount.value='0.00';
			return;
		}
			
	}
}
function ValidateStep3()
 {
 	var total_friends=document.Form1.hid_friend.value;
	var total_partner=document.Form1.hid_partner.value;
	var total_children=document.Form1.hid_children.value;
 	//ejpAlert(document.Form1.hid_friend.value);
	//ejpAlert(document.Form1.hid_partner.value);
	//ejpAlert(document.Form1.hid_children.value);
	var error_string='';
	var error_flag=false;
	for(i=1;i<=total_friends;i++)
	{
		if(trim(eval("document.Form1.fri_title_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_title_additional+' [' + i +']. \n';
		}
		if(trim(eval("document.Form1.fri_fname_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_firstname_additional+' [' + i +']. \n';
		}
		else if(eval("document.Form1.fri_fname_"+i+".value.length")<2)
		{
			error_flag=true;
			error_string+='* '+JSalert_firstnameminimum_additional+' [' + i +']. \n';
		}
		if(trim(eval("document.Form1.fri_lname_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_lastname_additional+' [' + i +']. \n';
		}
	
		if(trim(eval("document.Form1.fri_date_"+i+".value"))=="" || trim(eval("document.Form1.fri_date_"+i+".value"))=="0")
		{
			error_flag=true;
			error_string += '* '+JSalert_dob_additional+' [' + i +']. \n';
		}
		if(trim(eval("document.Form1.fri_month_"+i+".value"))=="" || trim(eval("document.Form1.fri_month_"+i+".value"))=="0")
		{
			error_flag=true;
			error_string += '* '+JSalert_mob_additional+' [' + i +']. \n';
		}
		if(trim(eval("document.Form1.fri_year_"+i+".value"))=="" || trim(eval("document.Form1.fri_year_"+i+".value"))=="0")
		{
			error_flag=true;
			error_string += '* '+JSalert_yob_additional+' [' + i +']. \n';
		}
		
		if(trim(eval("document.Form1.fri_address_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_address_additional+' [' + i +']. \n';
		}
		if(trim(eval("document.Form1.fri_town_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_city_additional+' [' + i +']. \n';
		}
		if(trim(eval("document.Form1.fri_country_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_country_additional+' [' + i +']. \n';
		}
		

		if(trim(eval("document.Form1.fri_country_"+i+".value"))=="223")
			{
			
			var st=	eval("document.Form1.fri_address3_"+i+".value").toUpperCase();
			if(!checkstate(trim(st))){ 
			error_string += '* '+JSalert_invalidstate+' [' + i +']. \n';
			}
		}

		
		
		
		if(trim(eval("document.Form1.fri_postcode_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_postcode_additional+' [' + i +']. \n';
		}
		
		var pc = eval("document.Form1.fri_postcode_"+i+".value") ;
		if(pc.match('[^a-zA-Z0-9 -]'))
		{
			error_flag=true;
			error_string += '* '+JSalert_postcode_additional+' [' + i +']. \n';
		}
		
		if(trim(eval("document.Form1.fri_email_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_email_additional+' [' + i +']. \n';
		}
		if(trim(eval("document.Form1.fri_email_"+i+".value"))!="")
		{
			if(validateEmail(eval("document.Form1.fri_email_"+i))==false)
			{
				error_flag=true;
				error_string += '* '+JSalert_validemail_additional+' [' + i +']. \n';
			}
			if(trim(eval("document.Form1.fri_email_"+i+".value"))!=trim(eval("document.Form1.fri_remail_"+i+".value")))
			{
				error_flag=true;
				error_string += '* '+JSalert_matchemail_additional+' [' + i +']. \n';				
			}
		}
								
	}
	for(i=1;i<=total_partner;i++)
	{
		if(trim(eval("document.Form1.par_title_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_title_partner+' \n';
		}
		if(trim(eval("document.Form1.par_fname_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_firstname_partner+'\n';
		}
		else if(eval("document.Form1.par_fname_"+i+".value.length")<2)
		{
			error_flag=true;
			error_string+='* '+JSalert_firstnameminimum_partner+' \n';
		}
		if(trim(eval("document.Form1.par_lname_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_lastname_partner+' \n';
		}
	
		if(trim(eval("document.Form1.par_date_"+i+".value"))=="" || trim(eval("document.Form1.par_date_"+i+".value"))=="0")
		{
			error_flag=true;
			error_string += '* '+JSalert_dob_partner+' \n';
		}
		if(trim(eval("document.Form1.par_month_"+i+".value"))=="" || trim(eval("document.Form1.par_month_"+i+".value"))=="0")
		{
			error_flag=true;
			error_string += '* '+JSalert_mob_partner+' \n';
		}
		if(trim(eval("document.Form1.par_year_"+i+".value"))=="" || trim(eval("document.Form1.par_year_"+i+".value"))=="0")
		{
			error_flag=true;
			error_string += '* '+JSalert_yob_partner+'\n';
		}
		if(trim(eval("document.Form1.par_email_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_email_partner+' \n';
		}
		if(trim(eval("document.Form1.par_email_"+i+".value"))!="")
		{
			if(validateEmail(eval("document.Form1.par_email_"+i))==false)
			{
				error_flag=true;
				error_string += '* '+JSalert_validemail_partner+' \n';
			}
			if(trim(eval("document.Form1.par_email_"+i+".value"))!=trim(eval("document.Form1.par_remail_"+i+".value")))
			{
				error_flag=true;
				error_string += '* '+JSalert_matchemail_partner+' \n';				
			}
		}
		
	}
	for(i=1;i<=total_children;i++)
	{
		if(trim(eval("document.Form1.child_title_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_title_child+' [' + i +']. \n';
		}
		if(trim(eval("document.Form1.child_fname_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_firstname_child+' [' + i +']. \n';
		}
		else if(eval("document.Form1.child_fname_"+i+".value.length")<2)
		{
			error_flag=true;
			error_string+='* '+JSalert_firstnameminimum_child+' [' + i +']. \n';
		}
		if(trim(eval("document.Form1.child_lname_"+i+".value"))=="")
		{
			error_flag=true;
			error_string += '* '+JSalert_lastname_child+' [' + i +']. \n';
		}
	
		if(trim(eval("document.Form1.child_date_"+i+".value"))=="" || trim(eval("document.Form1.child_date_"+i+".value"))=="0")
		{
			error_flag=true;
			error_string += '* '+JSalert_dob_child+' [' + i +']. \n';
		}
		if(trim(eval("document.Form1.child_month_"+i+".value"))=="" || trim(eval("document.Form1.child_month_"+i+".value"))=="0")
		{
			error_flag=true;
			error_string += '* '+JSalert_mob_child+' [' + i +']. \n';
		}
		if(trim(eval("document.Form1.child_year_"+i+".value"))=="" || trim(eval("document.Form1.child_year_"+i+".value"))=="0")
		{
			error_flag=true;
			error_string += '* '+JSalert_yob_child+' [' + i +']. \n';
		}
		if((trim(eval("document.Form1.child_date_"+i+".value"))!="" && trim(eval("document.Form1.child_date_"+i+".value"))!="0") && (trim(eval("document.Form1.child_month_"+i+".value"))!="" && trim(eval("document.Form1.child_month_"+i+".value"))!="0") && (trim(eval("document.Form1.child_year_"+i+".value"))!="" && trim(eval("document.Form1.child_year_"+i+".value"))!="0"))
		{
				var y=eval("document.Form1.child_year_"+i);
				year=y.value;
				var m=eval("document.Form1.child_month_"+i);
				month=m.value;
				var d=eval("document.Form1.child_date_"+i);
				day=d.value;
				var startingdate=new Date(year + "/" + month + "/" + day);
				if(!DateDiff(startingdate))
				{
					error_flag=true;
					error_string += '* '+JSalert_age_child+' [' + i +']. \n';
				}
		}
		
	}
	if(error_string!='')
	{
		error_string="" + error_string;
		//ejpAlert(error_string);
		ejpAlert(error_string);
		err_find='YES';
	}
	else
	{
		err_find='';	
	}
	return err_find;
 }
function DateDiff(startingdate)
{	
	var one_day=1000*60*60*24;
	var today=new Date();
	var valid_date=new Date(today.getYear()-18, today.getMonth(), today.getDate());
	var valid_days=Math.ceil((today.getTime()-valid_date.getTime())/(one_day));
	//var startingdate=new Date(1990,1,14) //Month is 0-11 in JavaScript
	var present_days=Math.ceil((today.getTime()-startingdate.getTime())/(one_day));
	if(parseInt(present_days)>=parseInt(valid_days))
	{
		return false;
	}
	else
	{
		return true;
	}
}


function isNumberOnly(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=9)
	{ //if the key isn't the backspace key (which we should allow)
		if ((unicode<48||unicode>57) && unicode!=13) //if not a number
		return false //disable key press
	}
}