

function isEmail (s) {
	var	i="@";	
	var c = s.indexOf(i);
	var d = s.indexOf(".");
	if (c > 0 && d > 0 ) {
	 	return true;
	}
	else return false;
}
function isNumber(s)

{   var i;
    var defaultEmptyOK=false;
	
    if (isEmpty(s)) 
       if (isNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isNumber.arguments[1] == true);
	   
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (!isDigit(c)) return false;
    }

    return true;
}


function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isIllegal(s,p)
{	   var c=s.indexOf(p);
	   return (c > 0)
}
/**/
function isLength(s,l)
{   return ((s.length == l))
}


// function for setting a cookie.
function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) + 
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

// function for deleting a cookie.
function delCookie (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function validatePaymentInfo(myForm){
/*
	if (isEmpty(myForm.cardName.value)) {
		alert("Please enter your name as it appears on your Credit Card");
		myForm.cardName.focus();
		return (false);
	}
	*/
	if (!isNumber(myForm.cardNumber.value)) {
		alert("Please enter a valid credit card number with no spaces");
		return (false);
	}

	if ((!myForm.terms.checked)){
		alert("Please check the box next to Conditions to indicate that you agree with the Terms and Conditions of service.");
	
		return (false);
	}
	
		idx=myForm.expMonth.selectedIndex;
		mon=myForm.expMonth.options[idx].text;
		/*
	if (!isNumber(mon)) {
		alert("Please select your card Expiry Month");
		return (false);
	}
		idx=myForm.expYear.selectedIndex;
		yr=myForm.expYear.options[idx].text;

	
	if (!isNumber(yr)) {
		alert("Please select your card Expiry Year");
		return (false);
	} */
	
	//warning=window.open("https://www.basewireless.com/pub/warning.html","warning","width=350,height=150,left=300,top=300,resizable,no,no");
	warning=window.open("/pub/warning.html","warning","width=350,height=150,left=300,top=300,resizable,no,no");
	myForm.submit();
	
	}

function validateClientInfo(myForm){
		if (isEmpty(myForm.firstName.value)) {
		alert("Please enter your First Name");
		myForm.firstName.focus();
		return (false);
	}
	if (isEmpty(myForm.lastName.value)) {
		alert("Please enter your Last Name");
		myForm.lastName.focus();
		return (false);
	}
	
	if (!isEmail(myForm.emailAddress.value)){
		alert("Please enter a valid Email Address");
		myForm.emailAddress.focus();
		return (false);
	}
	if (isEmpty(myForm.phoneNumber.value)) {
		alert("Please enter a contact Phone Number");
		myForm.phoneNumber.focus();
		return (false);
	}
	if (isEmpty(myForm.postAddress.value)) {
		alert("Please enter a Billing Address");
		myForm.postAddress.focus();
		return (false);
	}
	if (isEmpty(myForm.city.value)) {
		alert("Please enter a City");
		myForm.city.focus();
		return (false);
	}
		idx=myForm.state.selectedIndex;
		st=myForm.state.options[idx].value;
		
	if (isEmpty(st)) {
		alert("Please Select a State or Province");
		myForm.state.focus();
		return (false);
	}
	if (isEmpty(myForm.postCode.value)) {
		alert("Please enter a zip/postal code");
		myForm.postCode.focus();
		return (false);
	}
	
	myForm.submit();
	
}


function confirmDelete(myForm){
	
	if (confirm("Are you sure you want to Delete this Item?")) {
		myForm.action.value="delete";
		myForm.submit();
	}
	else { return (false);}
}

	


function validateMailForm(myForm){
if (!isEmail(myForm.emailAddress.value)){
		alert("Please enter a valid Email Address or you will not receive a response to your enquiry");
		myForm.emailAddress.focus();
		return (false);
	}
else {	
	myForm.submit();
	}
}

function submitAction(myForm,actionValue){
	
		myForm.action.value=actionValue;
		myForm.submit();

}

function discountAction(myForm,url,id){
	windowURL=url;
	
	openWindow(windowURL,"discount",500,300,100,100,menu,scroll);

}
	
function openWindow(windowURL,windowName,windowWidth,windowHeight,x,y,menu,scroll) {
	newWindow = window.open(windowURL,windowName,'width='+windowWidth+',height='+windowHeight+',left='+x+',top='+y+',toolbar=0,location=0,directories=0,status=0,menuBar='+menu+',scrolling='+scroll+',resizable=1');
	newWindow.focus();
}	