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.location.href = blogurl + '?zoom_query='+ 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;
}