function delivery(obj,total_count_del) {
	var CountVarr = total_count_del;
	for(i=1;i<=CountVarr;i++)
	{
		if (obj.checked) 
		{
			document.getElementById('delivery_address_1_'+parseInt(i-1)).value = document.getElementById('address_1').value;
			document.getElementById('delivery_address_2_'+parseInt(i-1)).value = document.getElementById('address_2').value;
			document.getElementById('delivery_city_'+parseInt(i-1)).value = document.getElementById('city').value;
			document.getElementById('delivery_post_code_'+parseInt(i-1)).value = document.getElementById('post_code').value;
			document.getElementById('delivery_country_id_'+parseInt(i-1)).value = document.getElementById('country_id').value;
		}
	}
}


function agree_terms(obj) {
	if (obj.checked) document.getElementById('submit_btn').disabled = false;
	else document.getElementById('submit_btn').disabled = true;
}


	var con=0; 
	function addextraattribute1() 
	{ 
		
		var counter = document.getElementById('length').value;
		var total_count = document.getElementById('total_count').value;
		var con = total_count;
		counter=parseInt(counter)+1;
		document.getElementById('length').value=counter;
		con++;
		document.getElementById('parah').style.display=""; var content="<table border='0' cellpadding='0' cellspacing='0' align='left' style='padding:0px; margin:0px; margin-left:-20px;' id='attribtb_"+con+"'><tr><td align='left' width='160px'>E-mail*</td><td align='left' style='padding:0px; margin:0px;'><input type='text' id='mail_"+con+"' name='mail[]' value='' class='register_form'><br><a href='javascript:void(0)' style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#EC0000;' onClick='removelement("+con+")'>Remove</a></td></tr></table><div style='clear:both'></div>";
		var newPara = document.createElement("span"); 
		var bodyRef = document.getElementById('parah'); 
		bodyRef.appendChild(newPara); newPara.innerHTML = content;
		document.getElementById('total_count').value = parseInt(total_count)+1;
		document.getElementById('form_varr').value='0';
	}	

function removelement(eleid) 
{ 
	var total_count = document.getElementById('total_count').value;
	element=document.getElementById('attribtb_'+eleid); 
	element.removeChild(element.firstChild); 
	document.getElementById('total_count').value = parseInt(total_count)-1;
	document.getElementById('form_varr').value='0';
}




/*~####  start Delivery address  ###*/	
	var con_del=0; 
	function addextraattribute1_del() 
	{ 
		var counter_del = document.getElementById('length_del').value;
		var total_count_del = document.getElementById('total_count_del').value;
		counter_del=parseInt(counter_del)+1;
		document.getElementById('length_del').value=counter_del;
		con_del++;
		document.getElementById('parah_del').style.display=""; var content_del="<table border='0' width='100%' cellpadding='0' cellspacing='0' align='left' style='padding:0px; margin:0px; margin-left:-20px;' id='attribtb_del"+con_del+"'><tr height='8'><td width='130px;'><img src='/images/spacer.gif' width='1' height='8'></td></tr><tr height='24' class='cart_item'><td>Address Line 1</td><td><input type='text' id='delivery_address_1_"+con_del+"' name='delivery_address_1[]' value='' class='register_form'></td></tr><tr height='24' class='cart_item'><td>Address Line 2</td><td><input type='text' id='delivery_address_2_"+con_del+"' name='delivery_address_2[]' value='' class='register_form'></td></tr><tr height='24' class='cart_item'><td>City</td><td><input type='text' id='delivery_city_"+con_del+"' name='delivery_city[]' value='' class='register_form' style='width:150px;'></td></tr><tr height='24' class='cart_item'><td>Post Code</td><td><input type='text' id='delivery_post_code_"+con_del+"' value='' name='delivery_post_code[]' class='register_form' style='width:100px;'></td></tr><tr height='24' class='cart_item'><td>Country</td><td><select class='register_form' id='delivery_country_id_"+con_del+"' name='delivery_country_id[]' style='width:246px;'><option value=''>-- Select One --</option><option value='23' >Czech Republic</option><option value='19' >Denmark</option><option value='24' >Finland</option><option value='13' >France</option><option value='10' >Germany</option><option value='16' >Holland</option><option value='21' >Hungary</option><option value='8' >Ireland</option><option value='17' >Italy</option><option value='20' >Nigeria</option><option value='11' >Northern Ireland</option><option value='22' >Poland</option><option value='12' >Spain</option><option value='14' >Sweden</option><option value='18' >Switzerland</option><option value='3' >United Kingdom</option></select></td></tr><tr height='24' class='cart_item'><td colspan='2'><STRONG>POST CODES MUST BE IN FULL</STRONG> (Part Post Codes unacceptable)</td></tr><tr height='15'><td><img src='/images/spacer.gif' width='1' height='15'></td></tr><tr><td colspan='2' align='right' style='padding-right:20px;'><a href='javascript:void(0)' style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#EC0000;' onClick='removelement_del("+con_del+")'>Remove</a></td></tr><tr height='5' bgcolor='#640000' class='cart_header'><td colspan='2'><img src='/images/spacer.gif' width='1' height='5'></td></tr></table><div style='clear:both'></div>";
		var newPara = document.createElement("span"); 
		var bodyRef = document.getElementById('parah_del'); 
		bodyRef.appendChild(newPara); newPara.innerHTML = content_del;
		document.getElementById('total_count_del').value = parseInt(total_count_del)+1;
	}	
		
	

	function removelement_del(eleid) 
	{ 
		var total_count_del = document.getElementById('total_count_del').value;
		element=document.getElementById('attribtb_del'+eleid); 
		element.removeChild(element.firstChild); 
		document.getElementById('total_count_del').value = parseInt(total_count_del)-1;
	}

/*~####  end Delivery address  ###*/	

/*~####check user availabilty~####*/	
var xmlhttpCat;
var str="";
function loadXMLCat(url)
{
// code for Mozilla, etc.

	if (window.XMLHttpRequest)
	  {
		  xmlhttpCat=new XMLHttpRequest();
		  xmlhttpCat.open("GET",url,false);
		  xmlhttpCat.send(null);
		  
		  if (xmlhttpCat.readyState==4 && xmlhttpCat.status==200)
		  str = xmlhttpCat.responseText;
	  }
// code for IE
	else if (window.ActiveXObject)
	  {
	  	xmlhttpCat=new ActiveXObject("Microsoft.XMLHTTP");
		if (xmlhttpCat)
		{
		    xmlhttpCat.open("GET",url,false);
		    xmlhttpCat.send();
		    
		    if (xmlhttpCat.readyState==4 && xmlhttpCat.status==200)
		    str = xmlhttpCat.responseText;
		}
	  } 
	  return str;
	  
}  // end function

function validEmailJS(email)
{
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}


function availablity(totalCount)
{
	for(i=0; i<=totalCount;i++)	
	{
		var Email=document.getElementById('mail_'+i).value;
		if(Email=='')
		{
			alert("Please enter email address.")
			document.getElementById('mail_'+i).focus();
			return false;
		}			
		else if(!validEmailJS(Email))
		{
			alert("Please enter the valid email address.");
			document.getElementById('mail_'+i).focus();
			return false;
		}	
		else
		{
			if(loadXMLCat("/availability_user.php?usrname=" + Email)==0)
			{			
				alert("Congratulation, the email address available.");
				document.getElementById('mail_'+i).focus();
			}
			else
			{	
				alert("Sorry, the same email address already exists.");
				document.getElementById('mail_'+i).focus();
				return false;
			}
		}	
	}	
	document.getElementById('form_varr').value='1';
}
function availablity_edit(user_edit_id,totalCount)
{	
	for(i=1; i<=totalCount; i++)	
	{
		var Email=document.getElementById('mail_'+i).value;
		
		if(Email=='')
		{
			alert("Please enter email address.")
			document.getElementById('mail_'+i).focus();
			return false;
		}			
		else if(!validEmailJS(Email))
		{
			alert("Please enter the valid email address.");
			document.getElementById('mail_'+i).focus();
			return false;
		}	
		else
		{
			var varr_with_id = "/availability_user.php?user_edit_id="+user_edit_id+"&usrname=" + Email;
			//alert(varr_with_id);
			if(loadXMLCat(varr_with_id) == 0)
			{			
				alert("Congratulation, the email address available.");
				document.getElementById('mail_'+i).focus();
			}
			else
			{	
				alert("Sorry, the same email address already exists.");
				document.getElementById('mail_'+i).focus();
				return false;
			}
		}	
	}	
	document.getElementById('form_varr').value='1';
}
function submitFrm()
{	
	if(document.getElementById('form_varr').value!='1')
	{
	alert("Please check the email address availabilty first clicking `Check Availablity`");
	return false;
	}
	else
	{
		return true;
	}
}