function ShowImage(file,wd,ht)
{
  if(wd==null) { wd = 260;}
  if(ht==null) { ht = 200;}
	  prop="top=2,left=2,width="+wd+",height="+ht;
	  newWin=window.open(file,"ShowImage",prop);
	  newWin.focus();
}

function MM_preloadImages() 
{ //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function toggle(elID,elImage,navID)
{
	//alert(navID);
	var clickedElement = document.getElementById('s'+elID);
	// If the child of an LI has display none, when it's clicked
	if(clickedElement.style.display == 'none')
	{
		clickedElement.style.display='block';
		elImage.src='/images/sitemap-contract.gif';
	}
	else
	{
		clickedElement.style.display='none';
		elImage.src= '/images/sitemap-expand.gif';
	}
}

function qwerty(elID,navID)
{
	event.cancelBubble = true;
	el = elID.parentNode.parentNode.id;
}

function checkrequired(reqfields, reqalert) 
{
	var pass=true;
	var i;
	if(reqalert == '')
		reqalert = "Please make sure all required fields are properly completed."
		
	for(i=0; i < reqfields.length; i++)
	{
		if(document.getElementById(reqfields[i]).value == "" || document.getElementById(reqfields[i]).value == 0)
		{
			pass=false;
			break;
 		}
	}
	
	if (!pass) 
	{
		alert(reqalert);
		return false;
	}
	else
	return true;
}

function checkempty(reqfields, reqalert) 
{
	var pass=true;
	var i;
	var notFilled=0;
	
	if(reqalert == '')
		reqalert = "Please make sure all required fields are properly completed."
		
	for(i=0; i < reqfields.length; i++)
	{
		if (notFilled == 0)
		{
			if ( document.getElementById(reqfields[i]).value != 0 )			
				notFilled = 1;
			if ( !IsNumeric(document.getElementById(reqfields[i]).value, 1) )
			{
				alert('Number required in this field(s)!');
				return false;
			}
		}
	}
	
	if (notFilled == 0) 
	{
		alert(reqalert);
		return false;
	}
	else
	return true;
}

function bars_pubs_details_Submit()
{
	var reqfields = new Array;
		
	reqfields[0] = 'bp_name';
	reqfields[1] = 'address';
	reqfields[2] = 'cont_id';
	reqfields[3] = 'cntr_id';
	reqfields[4] = 'city';
	
	if (checkrequired(reqfields, ''))
		return true;
	else
		return false;
}

function search_Submit()
{
	var reqfields = new Array;
		
	reqfields[0] = 'q';
	
	if (checkrequired(reqfields, 'Please make sure SEARCH field is filled out properly.'))
		return true;
	else
		return false;
}

function contact_Submit()
{
	var emailID=document.contact.email
	var reqfields = new Array;
	
	reqfields[0] = 'email';
	reqfields[1] = 'msg';
	reqfields[2] = 'name';
	
	if (echeck(emailID.value)==false)
	{
		emailID.value=""
		emailID.focus()
		return false;
	}
		
	if (checkrequired(reqfields, ''))
		return true;
	else
		return false;
}

// check if the string is number
function IsNumeric(sText, integerX)
{
	var IsNumber=true;
	var Char;
	
	if (sText == '')
		IsNumber = false;
	else
	{
		// take minus sign off, if exists
		if (sText.substring(0,1) == "-")
			sText = 0 - (parseFloat(sText) * 1)
		
		//alert(sText);
		
		// integer
		if (integerX == 1)
			var ValidChars = "0123456789";
		// float
		else
			var ValidChars = "0123456789.";
		
		for (i = 0; i < sText.length && IsNumber == true; i++) 
		{ 
			Char = sText.charAt(i); 
			if (ValidChars.indexOf(Char) == -1) 
			{
				 IsNumber = false;
			}
		}
	}
	return IsNumber;
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var alertE = "Invalid Email Address";
		
		if (str.indexOf(at)==-1){
		   alert(alertE);
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert(alertE);
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert(alertE);
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert(alertE);
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(alertE);
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert(alertE);
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert(alertE);
		    return false
		 }

 		 return true					
	}
	
function spamstop(addname,domain,ext)
{ 
	//window.location.replace('mailto:' +a+ '@' +d+ '.' +e); 
	window.location.replace('mailto:' +addname+ '@' +domain+ '.' +ext+ '?subject=Feedback from Website'); 
}
