// JavaScript Document
function poplinks(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function openPopup(){
	window.open('http://www.panamavultures.com','_blank');
	var livewindow = window.open('http://www.liveandinvestincroatia.com/index.php','Croatia','height=500,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {livewindow.focus()}
}

function openfourhourPopup(){
	window.open('http://www.fourhourworkweek.com','_blank');
	var livewindow = window.open('http://www.liveandinvestincroatia.com/index.php','Croatia','height=500,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {livewindow.focus()}
}

function opennicaraguaPopup(){
	window.open('http://www.liveandinvestinnicaragua.com','_blank');
	var livewindow = window.open('http://www.liveandinvestincroatia.com/index.php','Croatia','height=500,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {livewindow.focus()}
}

function order_validate(){
	if(document.frm_order.name.value == "")
	{
		alert("Please enter your full name.");
		document.frm_order.name.focus();
		return false;
	}
	if(document.frm_order.email.value == "")
	{
		alert("Please enter your email address.");
		document.frm_order.email.focus();
		return false;
	}
	if (!validateEmail(document.frm_order.email.value,1,1)) 
	{
		document.frm_order.email.focus();
		return false;
	}
	if (document.frm_order.phone.value == "")
		 {
			alert ("Please Enter The Phone Number");
			 document.frm_order.phone.focus();
			 return false; 
		 }

	/*if(isNaN(document.frm_order.phone.value)){
		alert("Please enter valid Phone Number");
		document.frm_order.phone.value="";
		document.frm_order.phone.focus();
		return false;
	}*/
		/*if (document.frm_order.phone.value=="")
				{
				alert("Please enter the phone number");
				document.frm_order.phone.focus();
				return false;
				}
				
		var phone = frm_order.phone.value;
		 if (phone == "" )
		 { 
			 alert ("Delivery Phone Number must be required");
			 frm_order.phone.focus();
			 return false;
		 }	
		 
	 if (checkInternationalPhone(phone)==false){
			alert("Please Enter a Valid Phone Number")
			document.frm_order.phone.value="";
			frm_order.phone.focus();
			return false
			}*/

	if(document.frm_order.address1.value == ""){
		alert("Please Enter the Address");
		document.frm_order.address1.focus();
		return false;
	}
	if(document.frm_order.city.value == ""){
		alert("Please Enter the City");
		document.frm_order.city.focus();
		return false;
	}
	if(document.frm_order.state.value == ""){
		alert("Please Enter the State");
		document.frm_order.state.focus();
		return false;
	}
	if(document.frm_order.zipcode.value == ""){
		alert("Please Enter the Zipcode");
		document.frm_order.zipcode.focus();
		return false;
	}
	if(document.frm_order.country.value == ""){
		alert("Please Enter the Country");
		document.frm_order.country.focus();
		return false;
	}
}

function sendreport_validate(theForm)
{
	if(theForm.txtname.value == '')
	{
		alert("Enter the name");
		theForm.txtname.focus();
		return false;
	}
	if(theForm.txtemail.value == '')
	{
		alert("Enter the email address.");
		theForm.txtemail.focus();
		return false;
	}
	if (!validateEmail(theForm.txtemail.value,1,1)) 
	{
		theForm.txtemail.focus();
		return false;
	}
	inputname = theForm.txtname.value;
	inputemail = theForm.txtemail.value;
	theForm.txtname.value = "";
	theForm.txtemail.value = "";
	window.open('freereportsend.php?Submit=yes&txtname='+inputname+'&txtemail='+inputemail,'welcome','width=500,height=400,menubar=no,status=no,resizable=yes,left=0,right=0,location=no,scrollbars=yes')
}

//Email Validation Script
function validateEmail(addr,man,db) {
	if (addr == '' && man) {
	   if (db) alert('Email address is mandatory');
	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (db) alert('Email address contains invalid characters');
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (db) alert("Email address contains non ascii characters.");
		  return false;
	   }
	}

	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   if (db) alert('Email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   if (db) alert('Email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   if (db) alert('Email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   if (db) alert('Email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   if (db) alert('period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   if (db) alert('period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	   if (db) alert('two periods must not be adjacent in email address');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   if (db) alert('invalid primary domain in email address');
	   return false;
	}
return true;
}


/*//Function phone validation Script
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-. ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 6;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not 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) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}*/
