function OpenCloseDiv(obj)
{
    var DivId = document.getElementById(obj);
    if(DivId.style.visibility  == "hidden")
    {
        DivId.style.visibility = "visible";
        DivId.style.display = "block";
    }
    else
    {
        DivId.style.visibility = "hidden";
        DivId.style.display = "none";
    }
}

function addToFavorites(url, title)
{
    if (window.sidebar) // firefox
        window.sidebar.addPanel(title, url, "");
    else if(window.opera && window.print) // opera
        alert('Please press Ctrl + D to Bookmark this page');
    else if(document.all)// ie
        window.external.AddFavorite(url, title);
    else
        alert('Please press Ctrl + D to Bookmark this page');    
}
	
function emailToFriend(urlAddress)
{
    var url = "http://www.goecart.com/";
	var t = (screen.availHeight/2) - (485/2);
	var l = (screen.availWidth/2) - (605/2);
	var emailWin = window.open(url +'support/email_page.aspx?src=EmailFrnd&link='+urlAddress, "emailWin", "scrollbars=yes,toolbar=1,statusbar=0,width=605,height=300,top="+t+",left="+l);
}



function popnew(strFileName, intHeight, intWidth)
{
	var objPopWin=window.open(strFileName, '', "Height="+ intHeight +", Width="+ intWidth +", top=25,left=100, help=no, resizable=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes");
	objPopWin.focus();
}

function fnShowPopupImage(strFileName, intHeight, intWidth)
	{
	var objPopWin=window.open(strFileName, '', "Height="+ intHeight +", Width="+ intWidth +", top=25,left=100, help=no, resizable=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no");
	objPopWin.focus();
	}

function fnShowPopupPDF(strFileName, intHeight, intWidth)
	{
	var objPopWin=window.open(strFileName, '', "Height="+ intHeight +", Width="+ intWidth +", top=25,left=100, help=no, resizable=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes");
	objPopWin.focus();
	}

function fnShowPopupImage10(strFileName, intHeight, intWidth)
	{
	var objPopWin=window.open(strFileName, '', "Height="+ intHeight +", Width="+ intWidth +", top=25,left=100, help=no, resizable=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes");
	objPopWin.focus();
	}

function OpenCloseSearchDiv(obj, objtext)
{
    var DivId = document.getElementById(obj);
    var textfield = document.getElementById(objtext);
    if(DivId.style.visibility  == "hidden")
    {
        DivId.style.visibility = "visible";
        DivId.style.display = "block";
        textfield.focus();
        return false;
    }
    else
    {
        DivId.style.visibility = "hidden";
        DivId.style.display = "none";
    }
}

function submitSearchForm(frm, url)
{
    if(frm.txtSearch.value == '')
    {
        alert("Please enter a search term");
        frm.txtSearch.focus();
        return false;
    }
    
    window.location.href = url + '?zoom_query='+ frm.txtSearch.value;
    return false;
}
function InvokeEnter(evt, frm, url) {
	if (!evt) evt = window.event;
	key = evt.keyCode ? evt.keyCode : evt.which;

	if(key == 13)
	{
		submitSearchForm(frm, url);
		return false;
	}
}
function InvokeSubmit(evt, frm, url) {
	if (!evt) evt = window.event;
	key = evt.keyCode ? evt.keyCode : evt.which;

	if(key == 13)
	{
	    //window.location.href = url + "?zoom_query="+ frm.zoom_query.value;
		frm.submit()
		return false;
	}
}

function submitSearch(frm, url, blogurl, field)
{
    if(field.value == '')
    {
        alert("Please enter a search term");
        field.focus();
        return false;
    }
    
    if(frm.radOption[0].checked == true)
        window.location.href = url + '?zoom_query='+ field.value;
    else
	window.open(blogurl + '?s='+ field.value);

        //window.location.href = blogurl + '?q='+ field.value;
            
    return false;
}
function InvokeSearchEnter(evt, frm, url, blogurl, field) {
	if (!evt) evt = window.event;
	key = evt.keyCode ? evt.keyCode : evt.which;

	if(key == 13)
	{
		submitSearch(frm, url, blogurl, field);
		return false;
	}
}


function validateEmail (emailStr) {

var emailPat=/^(.+)@(.+)$/

var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

var validChars="\[^\\s" + specialChars + "\]"

var firstChars=validChars

var quotedUser="(\"[^\"]*\")"

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

var atom="(" + firstChars + validChars + "*" + ")"

var word="(" + atom + "|" + quotedUser + ")"

var userPat=new RegExp("^" + word + "(\\." + word + ")*$")

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

var matchArray=emailStr.match(emailPat)
if (matchArray==null) {  
	alert("Email address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

if (user.match(userPat)==null) {
    // user is not valid
    alert("The name part of the email address seems to be invalid.")
    return false
}

var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {    
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("The IP part of the email address is invalid!")
		return false
	    }
    }
    return true
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name of the email address doesn't seem to be valid.")
    return false
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>4) {
   // the address must end in a two letter or four letter word.
   alert("The email address must end in a three-letter or four-letter domain, or two letter country.")
   return false
}

if (domArr[domArr.length-1].length==3 && len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}
// If we've gotten this far, everything's valid!
return true;
}

function OpenCloseDiv(obj)
{
    var DivId = document.getElementById(obj);
    if(DivId.style.visibility  == "hidden")
    {
        DivId.style.visibility = "visible";
        DivId.style.display = "block";
    }
    else
    {
        DivId.style.visibility = "hidden";
        DivId.style.display = "none";
    }
}

function addToFavorites(url, title)
{
    if (window.sidebar) // firefox
        window.sidebar.addPanel(title, url, "");
    else if(window.opera && window.print) // opera
        alert('Please press Ctrl + D to Bookmark this page');
    else if(document.all)// ie
        window.external.AddFavorite(url, title);
    else
        alert('Please press Ctrl + D to Bookmark this page');    
}
	
function emailToFriend(urlAddress)
{
    var url = "http://www.goecart.com/";
	var t = (screen.availHeight/2) - (485/2);
	var l = (screen.availWidth/2) - (605/2);
	var emailWin = window.open(url +'support/email_page.aspx?src=EmailFrnd&link='+urlAddress, "emailWin", "scrollbars=yes,toolbar=1,statusbar=0,width=605,height=300,top="+t+",left="+l);
}



function popnew(strFileName, intHeight, intWidth)
{
	var objPopWin=window.open(strFileName, '', "Height="+ intHeight +", Width="+ intWidth +", top=25,left=100, help=no, resizable=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes");
	objPopWin.focus();
}

function fnShowPopupImage(strFileName, intHeight, intWidth)
	{
	var objPopWin=window.open(strFileName, '', "Height="+ intHeight +", Width="+ intWidth +", top=25,left=100, help=no, resizable=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no");
	objPopWin.focus();
	}

function fnShowPopupPDF(strFileName, intHeight, intWidth)
	{
	var objPopWin=window.open(strFileName, '', "Height="+ intHeight +", Width="+ intWidth +", top=25,left=100, help=no, resizable=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes");
	objPopWin.focus();
	}

function fnShowPopupImage10(strFileName, intHeight, intWidth)
	{
	var objPopWin=window.open(strFileName, '', "Height="+ intHeight +", Width="+ intWidth +", top=25,left=100, help=no, resizable=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes");
	objPopWin.focus();
	}

function OpenCloseSearchDiv(obj, objtext)
{
    var DivId = document.getElementById(obj);
    var textfield = document.getElementById(objtext);
    if(DivId.style.visibility  == "hidden")
    {
        DivId.style.visibility = "visible";
        DivId.style.display = "block";
        textfield.focus();
        return false;
    }
    else
    {
        DivId.style.visibility = "hidden";
        DivId.style.display = "none";
    }
}

function submitSearchForm(frm, url)
{
    if(frm.txtSearch.value == '')
    {
        alert("Please enter a search term");
        frm.txtSearch.focus();
        return false;
    }
    
    window.location.href = url + '?zoom_query='+ frm.txtSearch.value;
    return false;
}
function InvokeEnter(evt, frm, url) {
	if (!evt) evt = window.event;
	key = evt.keyCode ? evt.keyCode : evt.which;

	if(key == 13)
	{
		submitSearchForm(frm, url);
		return false;
	}
}
function InvokeSubmit(evt, frm, url) {
	if (!evt) evt = window.event;
	key = evt.keyCode ? evt.keyCode : evt.which;

	if(key == 13)
	{
	    //window.location.href = url + "?zoom_query="+ frm.zoom_query.value;
		frm.submit()
		return false;
	}
}

function submitSearch(frm, url, blogurl, field)
{
    if(field.value == '')
    {
        alert("Please enter a search term");
        field.focus();
        return false;
    }
    
    if(frm.radOption[0].checked == true)
        window.location.href = url + '?zoom_query='+ field.value;
    else
	window.open(blogurl + '?s='+ field.value);

        //window.location.href = blogurl + '?q='+ field.value;
            
    return false;
}
function InvokeSearchEnter(evt, frm, url, blogurl, field) {
	if (!evt) evt = window.event;
	key = evt.keyCode ? evt.keyCode : evt.which;

	if(key == 13)
	{
		submitSearch(frm, url, blogurl, field);
		return false;
	}
}


function validateEmail (emailStr) {

var emailPat=/^(.+)@(.+)$/

var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

var validChars="\[^\\s" + specialChars + "\]"

var firstChars=validChars

var quotedUser="(\"[^\"]*\")"

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

var atom="(" + firstChars + validChars + "*" + ")"

var word="(" + atom + "|" + quotedUser + ")"

var userPat=new RegExp("^" + word + "(\\." + word + ")*$")

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

var matchArray=emailStr.match(emailPat)
if (matchArray==null) {  
	alert("Email address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

if (user.match(userPat)==null) {
    // user is not valid
    alert("The name part of the email address seems to be invalid.")
    return false
}

var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {    
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("The IP part of the email address is invalid!")
		return false
	    }
    }
    return true
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name of the email address doesn't seem to be valid.")
    return false
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>4) {
   // the address must end in a two letter or four letter word.
   alert("The email address must end in a three-letter or four-letter domain, or two letter country.")
   return false
}

if (domArr[domArr.length-1].length==3 && len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}
// If we've gotten this far, everything's valid!
return true;
}
function EmailValOutput(ResultCode) {
    var strMessage = '';    
    switch (ResultCode) 
    {
        case '0': //0 – Invalid Email address (bad email)
            return "The email you provided appears to be invalid. Please correct.";
            break;
        case '1': //1 – Not Used (good email)
            strMessage = "";
            break;
        case '2': //2 – Verified Email address (good email)
            strMessage = "";
            break;
        case '3': //3 – Mail Server will accept email (good email)
            strMessage = "";
            break;
        case '4': //4 – User Not Found (bad email)
            strMessage = "The email you provided appears to be invalid. Please correct.";
            break;
        case '5': //5 – Email Domain Not Found (bad email)
            strMessage = "The email you provided appears to be invalid. Please correct.";
            break;
        case '6': //6 – Not Used (good email)
            strMessage = "";
            break;
        case '7': //7 – SMTP/Timeout error (good email)
            strMessage = "";
            break;
        case '8': //8 – Domain valid. Email server down (good email)
            strMessage = "";
            break;
        case '9': //9 – License Key Allowance exceeded
            strMessage = "We are unable to verify your email address. Please enter alternate email.";
            break;
        case '10': //10 – SMTP/Timeour error (bad email)
            strMessage = "We are unable to verify your email address. Please enter alternate email.";
            break;
        case '-9999': //-9999 – License Key Allowance exceeded. This is from old documentation
            strMessage = "The email you provided appears to be invalid. Please correct.";
            break;
    }
    return strMessage;
}


function fnopenhide(tableId, ImageId, textId) {
    var existingHeight = pricingspacerdiv.style.height.replace('px', '');
    var newHeight = "";

    if (document.getElementById(tableId).style.visibility == "visible") {
        document.getElementById(tableId).style.visibility = "hidden";
        document.getElementById(tableId).style.display = "none";
        document.getElementById(ImageId).src = '../images/closed.gif';
        document.getElementById(textId).innerHTML = 'Full Comparison';
   
        if (tableId == 'PricingTable1') 
        {
            newHeight = parseInt(existingHeight) - parseInt(400);
            pricingspacerdiv.style.height = newHeight+'px';
        }
        else if (tableId == 'PricingTable2') 
        {
            newHeight = parseInt(existingHeight) - parseInt(160);
            pricingspacerdiv.style.height = newHeight + 'px';
        }
        else if (tableId == 'PricingTable3') {
            newHeight = parseInt(existingHeight) - parseInt(450);
            pricingspacerdiv.style.height = newHeight + 'px';
        }
        else if (tableId == 'PricingTable4') {
            newHeight = parseInt(existingHeight) - parseInt(220);
            pricingspacerdiv.style.height = newHeight + 'px';
        }
        else if (tableId == 'PricingTable5') {
            newHeight = parseInt(existingHeight) - parseInt(130);
            pricingspacerdiv.style.height = newHeight + 'px';
        }
        else if (tableId == 'PricingTable6') {
            newHeight = parseInt(existingHeight) - parseInt(225);
            pricingspacerdiv.style.height = newHeight + 'px';
        }
    } else {
        document.getElementById(tableId).style.visibility = "visible";
        document.getElementById(tableId).style.display = "block";
        document.getElementById(ImageId).src = '../images/open.gif';
        document.getElementById(textId).innerHTML = 'Close';

        if (tableId == 'PricingTable1') {
            newHeight = parseInt(existingHeight) + parseInt(400);
            pricingspacerdiv.style.height = newHeight + 'px';
        }
        else if (tableId == 'PricingTable2') {
            newHeight = parseInt(existingHeight) + parseInt(160);
            pricingspacerdiv.style.height = newHeight + 'px';
        }
        else if (tableId == 'PricingTable3') {
            newHeight = parseInt(existingHeight) + parseInt(450);
            pricingspacerdiv.style.height = newHeight + 'px';
        }
        else if (tableId == 'PricingTable4') {
            newHeight = parseInt(existingHeight) + parseInt(220);
            pricingspacerdiv.style.height = newHeight + 'px';
        }
        else if (tableId == 'PricingTable5') {
            newHeight = parseInt(existingHeight) + parseInt(130);
            pricingspacerdiv.style.height = newHeight + 'px';
        }
        else if (tableId == 'PricingTable6') {
            newHeight = parseInt(existingHeight) + parseInt(225);
            pricingspacerdiv.style.height = newHeight + 'px';
        }
    }
}
