// JavaScript Document
ddaccordion.init({
	headerclass: "sendurl", //Shared CSS class name of headers group that are expandable
	contentclass: "mailform", //Shared CSS class name of contents group
	revealtype: "mouseover", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	collapseprev: false, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [1], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: false, //persist state of opened contents within browser session?
	toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "normal", //speed of animation: "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isclicked){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})
// Send URL Validations

function val_sendurl()
{

 if(isEmpty(document.getElementById('sender_name'),"Please enter your name")==false)
  {
	document.getElementById('sender_name').select();
	document.getElementById('sender_name').focus();
	return false;
  }
 if(echeck(document.getElementById('sender_mail').value)==false)
  {
	document.getElementById('sender_mail').select();
	document.getElementById('sender_mail').focus();
	return false;
  }
  if(echeck(document.getElementById('friend_mail').value)==false)
  {
	document.getElementById('friend_mail').select();
	document.getElementById('friend_mail').focus();
	return false;
  }
}

//Check empty validation						
function isEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	else
	{
		 return true;
	}
}
//Email Validation
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str=='')
			{
			alert("Please enter E-mail ID")
			return false;
			}
		if (str.indexOf(at)==-1)
		{
		   alert("Please enter valid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter valid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter valid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter valid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter valid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter valid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter valid E-mail ID")
		    return false
		 }
	}