function Validate()
{
	if(document.getElementById('personname').value == '') {
		alert('Please enter Name');
		document.getElementById('personname').focus();
		return false;
	}
	else if(document.getElementById('address').value == '') {
		alert('Please enter Address');
		document.getElementById('address').focus();
		return false;
	}
	else if(document.getElementById('country').value == 0) {
		alert('Please select Country');
		document.getElementById('country').focus();
		return false;
	}
	else if(document.getElementById('email').value == '') {
		alert('Please enter Email');
		document.getElementById('email').focus();
		return false;
	}
	else if(document.getElementById('ititles').value == '' && document.getElementById('ptitles').value == '') {
		alert('Please enter Number of Titles / Shelves to be Exhibited');
		document.getElementById('ititles').focus();
		return false;
	}
	else if(document.getElementById('terms').checked ==false){
		alert('Please read our Terms and Conditions.');
		return false;
	}
	else
	{
		if(!validateEmailv2(document.getElementById('email').value)) 
		{ 
			alert("Enter a valid Email address");
			document.getElementById('email').focus(); 
			return false;
		}
		else if(isNaN(document.getElementById('ititles').value)) {
			alert("Enter numbers only in Number of titles field. e.g. 1, 2");
			document.getElementById('ititles').focus(); 
			return false;
		}
		else if(isNaN(document.getElementById('ptitles').value)) {
			alert("Enter numbers only in Number of shelves field. e.g. 1, 2");
			document.getElementById('ptitles').focus(); 
			return false;
		}
		else {
			return true;
		}
	}
}


function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
	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 mypopup(){
	mywindow = window.open ("bea_popup_categories.php","mywindow","status=1,scrollbars=1,width=600,height=650");
	mywindow.moveTo(200,150);
}
function openWin(url)
{
var j=window.open(url,"jj","width=450,height=400,scrollbars=1")
}
var whitespace = " \t\n\r"
function isEmpty(s)
{
   return ((s == null) || (s.length == 0))
}
function isWhitespace (s)
{  var i;
	// Is s empty?
	if (isEmpty(s)) return true;

	 // Search through string's characters one by one
	 // until we find a non-whitespace character.
	 // When we do, return false; if we don't, return true.
	 for (i = 0; i < s.length; i++)
	 {   
		 // Check that current character isn't whitespace.
		 var c = s.charAt(i);
 
		 if (whitespace.indexOf(c) == -1) return false;
	 }
 
	 // All characters are whitespace.
	 return true;
}
function BuildStr(s, s1)
{
	  if (s.length> 0) s = s + "\n";
	  s = s + s1;
	  return s;
}

function isCharsInBag (s, bag)
{  
  var i;
  // Search through string's characters one by one.
  // If character is in bag, append to returnString.

  for (i = 0; i < s.length; i++)
  {   
	  // Check that current character isn't whitespace.
	  var c = s.charAt(i);
	  if (bag.indexOf(c) == -1) return false;
  }
  return true;
}


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 true;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			return true;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return true;
   		}

		 if (str.indexOf(at,(lat+1))!=-1){
			return true;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			return true;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			return true;
		 }
		
		 if (str.indexOf(" ")!=-1){
			return true;
		 }

 		 return false;					
	}
	function numeralsOnly1(evt)
{
    
	evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        alert("Enter numerals only in Quantity field.");
        return false;
	}
    return true;
}

function booth1()
{
	
	if(document.form1.booth.value==0 || document.form1.booth.value==2)
	{
		document.form1.booth_number.readOnly=true;
	}
	else
	{
		document.form1.booth_number.readOnly=false;
	}
}

function check()
{
	if(document.form1.ititles.value!="")
	{
		document.form1.ptitles.readOnly=true;
		if(isNaN(document.form1.ititles.value))
		{
			alert("Enter numerals only");
		}
		else
		{
			if(document.form1.ititles.value>50)
			{
				alert("Number of Titles to be exhibited should not be more than 50");
			}
		}
	}
	else
	{
		document.form1.ptitles.readOnly=false;
	}
}

function check1()
{
	if(document.form1.ptitles.value!="")
	{
		document.form1.ititles.readOnly=true;
		if(isNaN(document.form1.ptitles.value))
		{
			alert("Enter numerals only");
		}
		else
		{
			if(document.form1.ptitles.value>10)
			{
					alert("Number of Publisher Shelves should not be more than 10");
			}
		}
	}
	else
	{
		document.form1.ititles.readOnly=false;
	}
}
/*function checkbooth()
{
	if(document.form1.booth2[0].checked || document.form1.booth2[2].checked)
	{
		document.form1.booth_number.value="";
		document.form1.booth_number.readOnly=true;
	}
}*/

function checkinclude()
{
	
	if(document.form1.include[0].checked)
	{
		
		document.form1.name1.value=document.form1.personname.value;
		document.form1.ctitle1.value=document.form1.jobtitle.value;
		document.form1.email1.value=document.form1.email.value;
		document.form1.name1.readOnly=true;
		document.form1.ctitle1.readOnly=true;
		document.form1.email1.readOnly=true;
	}
	if(document.form1.include[1].checked)
	{
		document.form1.name1.value="";
		document.form1.ctitle1.value="";
		document.form1.email1.value="";
		document.form1.name1.readOnly=false;
		document.form1.ctitle1.readOnly=false;
		document.form1.email1.readOnly=false;
	}
}

function change1()
{
	if(document.form1.personname.value!="")
	{
		if(document.form1.include[0].checked)
		{
			document.form1.name1.value=document.form1.personname.value;
			document.form1.name1.readOnly=true;
		}
	}
	else
	{
			document.form1.name1.value="";
			document.form1.name1.readOnly=false;
	}
	
	
}

function change2()
{
	if(document.form1.jobtitle.value!="")
	{
		if(document.form1.include[0].checked)
		{
			document.form1.ctitle1.value=document.form1.jobtitle.value;
			document.form1.ctitle1.readOnly=true;
		}
	}
	else
	{
			document.form1.ctitle1.value="";
			document.form1.ctitle1.readOnly=false;
	}
	
	
}

function change3()
{
	if(document.form1.email.value!="")
	{
		if(document.form1.include[0].checked)
		{
			document.form1.email1.value=document.form1.email.value;
			document.form1.email1.readOnly=true;
		}
	}
	else
	{
			document.form1.email1.value="";
			document.form1.email1.readOnly=false;
	}

}function mypopup(){
	mywindow = window.open ("bea_popup_categories.php","mywindow","status=1,scrollbars=1,width=600,height=650");
	mywindow.moveTo(200,150);
}
function openWin(url)
{
var j=window.open(url,"jj","width=450,height=400,scrollbars=1")
}
var whitespace = " \t\n\r"
function isEmpty(s)
{
   return ((s == null) || (s.length == 0))
}
function isWhitespace (s)
{  var i;
	// Is s empty?
	if (isEmpty(s)) return true;

	 // Search through string's characters one by one
	 // until we find a non-whitespace character.
	 // When we do, return false; if we don't, return true.
	 for (i = 0; i < s.length; i++)
	 {   
		 // Check that current character isn't whitespace.
		 var c = s.charAt(i);
 
		 if (whitespace.indexOf(c) == -1) return false;
	 }
 
	 // All characters are whitespace.
	 return true;
}
function BuildStr(s, s1)
{
	  if (s.length> 0) s = s + "\n";
	  s = s + s1;
	  return s;
}

function isCharsInBag (s, bag)
{  
  var i;
  // Search through string's characters one by one.
  // If character is in bag, append to returnString.

  for (i = 0; i < s.length; i++)
  {   
	  // Check that current character isn't whitespace.
	  var c = s.charAt(i);
	  if (bag.indexOf(c) == -1) return false;
  }
  return true;
}
	
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 true;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			return true;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return true;
   		}

		 if (str.indexOf(at,(lat+1))!=-1){
			return true;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			return true;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			return true;
		 }
		
		 if (str.indexOf(" ")!=-1){
			return true;
		 }

 		 return false;					
	}
	function numeralsOnly1(evt)
{
    
	evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        alert("Enter numerals only in Quantity field.");
        return false;
	}
    return true;
}

function booth1()
{
	
	if(document.form1.booth.value==0 || document.form1.booth.value==2)
	{
		document.form1.booth_number.readOnly=true;
	}
	else
	{
		document.form1.booth_number.readOnly=false;
	}
}

function check()
{
	if(document.form1.ititles.value!="")
	{
		document.form1.ptitles.readOnly=true;
		if(isNaN(document.form1.ititles.value))
		{
			alert("Enter numerals only");
		}
		else
		{
			if(document.form1.ititles.value>50)
			{
				alert("Number of Titles to be exhibited should not be more than 50");
			}
		}
	}
	else
	{
		document.form1.ptitles.readOnly=false;
	}
}

function check1()
{
	if(document.form1.ptitles.value!="")
	{
		document.form1.ititles.readOnly=true;
		if(isNaN(document.form1.ptitles.value))
		{
			alert("Enter numerals only");
		}
		else
		{
			if(document.form1.ptitles.value>10)
			{
					alert("Number of Publisher Shelves should not be more than 10");
			}
		}
	}
	else
	{
		document.form1.ititles.readOnly=false;
	}
}

function checkinclude()
{
	
	if(document.form1.include[0].checked)
	{
		
		document.form1.name1.value=document.form1.personname.value;
		document.form1.ctitle1.value=document.form1.jobtitle.value;
		document.form1.email1.value=document.form1.email.value;
		document.form1.name1.readOnly=true;
		document.form1.ctitle1.readOnly=true;
		document.form1.email1.readOnly=true;
	}
	if(document.form1.include[1].checked)
	{
		document.form1.name1.value="";
		document.form1.ctitle1.value="";
		document.form1.email1.value="";
		document.form1.name1.readOnly=false;
		document.form1.ctitle1.readOnly=false;
		document.form1.email1.readOnly=false;
	}
}

function change1()
{
	if(document.form1.personname.value!="")
	{
		if(document.form1.include[0].checked)
		{
			document.form1.name1.value=document.form1.personname.value;
			document.form1.name1.readOnly=true;
		}
	}
	else
	{
			document.form1.name1.value="";
			document.form1.name1.readOnly=false;
	}
	
	
}

function change2()
{
	if(document.form1.jobtitle.value!="")
	{
		if(document.form1.include[0].checked)
		{
			document.form1.ctitle1.value=document.form1.jobtitle.value;
			document.form1.ctitle1.readOnly=true;
		}
	}
	else
	{
			document.form1.ctitle1.value="";
			document.form1.ctitle1.readOnly=false;
	}
	
	
}

function change3()
{
	if(document.form1.email.value!="")
	{
		if(document.form1.include[0].checked)
		{
			document.form1.email1.value=document.form1.email.value;
			document.form1.email1.readOnly=true;
		}
	}
	else
	{
			document.form1.email1.value="";
			document.form1.email1.readOnly=false;
	}

}