var count=1;
  var countries="";
  function multi_country(){
  for(var i=1;i<count+1;i++){
  var optname="countrynames"+i; 
  countries=countries+document.getElementById(optname).value+",";}  
  }
  function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}
	function validateRequestForm()
	{
		if(document.getElementById('infname').value == "")
		{
			alert("Enter your first name.");
			document.getElementById('infname').focus();
			return false;
		}
		/*
		if(document.getElementById('inphno').value == "")
		{
			alert("Enter your day time phone number.");
			document.getElementById('inphno').focus();
			return false;
		}*/
		if(document.getElementById('inemail').value == "")
		{
			alert("Enter your email address.");

			document.getElementById('inemail').focus();
			return false;
		}
		if(!echeck(document.getElementById('inemail').value))
		{
			alert("Enter proper email address.");
			document.getElementById('inemail').focus();
			return false;
		}
		return true;
	}
   function submitinformation(){  	
	if(validateRequestForm())
	   {
		   $.ajax({
		   type: "POST",
		   url: "requestinfo-mail.php",
		   data: "Name= "+document.getElementById('infname').value+"&Phone="+document.getElementById('inphno').value+"&Email="+document.getElementById('inemail').value+"&Msg="+document.getElementById('inquirymsg').value+"&countrynames="+document.getElementById('countrynames').value+"&countrynames1="+document.getElementById('countrynames1').value+"&whenleaving="+document.getElementById('datepicker').value+"&howlong="+document.getElementById('howlong').value+"&nooftra="+document.getElementById('nooftra').value+"&optname="+countries,
		   success: function(html){   	   
			   document.getElementById('contactinquiry').innerHTML='<center><img src="<?=getlinkhost()?>/images/loading.gif" border="0"></center>';
			   document.getElementById('contactinquiry').innerHTML=html;
		   }
		   });
	   }
   }
   
   function addOption(){
	/*var table = document.getElementById('editAttOption');
 	var rowCount = table.rows.length;
	var row = table.insertRow(rowCount); 	
 	var cell2 = row.insertCell(0); 					
	 	var element1 = document.createElement("input");
		element1.type = "text";
		element1.name = "optname";
		element1.id = "optname"+count;
		cell2.appendChild(element1); 
		count++;*/
	if(count < 9){
	var element1d = "optname"+count;
	document.getElementById(element1d).style.display="block";
	count++;}
	else{}
}
$(function() {
										$("#datepicker").datepicker({ showOn: 'button', buttonImage: '/images/calendar.gif', buttonImageOnly: true });
									});
									
ddaccordion.init({
	headerclass: "mypets", //Shared CSS class name of headers group
	contentclass: "main_thepet", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: true, //Should contents open by default be animated into view?
	persiststate: false, //persist state of opened contents within browser session?
	toggleclass: ["", "openpet"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "slow", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})									
