// Corporate Global JavaScript Document

// make an entire table cell clickable
// e.g. <td  onclick="cellLink('http://www.canadiangeographic.ca/gohere.asp');">
function cellClick(theUrl)
{
document.location.href = theUrl;
}

// function for drop-down selector
function land(ref, target)
{
lowtarget=target.toLowerCase();
if (lowtarget=="_self") {window.location=loc;}
else {if (lowtarget=="_top") {top.location=loc;}
else {if (lowtarget=="_blank") {window.open(loc);}
else {if (lowtarget=="_parent") {parent.location=loc;}
else {parent.frames[target].location=loc;};
}}}
}
function jump(menu)
{
ref=menu.choice.options[menu.choice.selectedIndex].value;
splitc=ref.lastIndexOf("*");
target="";
if (splitc!=-1)
{loc=ref.substring(0,splitc);
target=ref.substring(splitc+1,1000);}
else {loc=ref; target="_self";};
if (ref != "") {land(loc,target);}
}



// function for drop-down selector
function landOurSites(refOurSites, targetOurSites)
{
lowtargetOurSites=targetOurSites.toLowerCase();
if (lowtargetOurSites=="_self") {window.location=loc;}
else {if (lowtargetOurSites=="_top") {top.location=loc;}
else {if (lowtargetOurSites=="_blank") {window.open(loc);}
else {if (lowtargetOurSites=="_parent") {parent.location=loc;}
else {parent.frames[target].location=loc;};
}}}
}
function jumpOurSites(menuOurSites)
{
refOurSites=menuOurSites.choiceOurSites.options[menuOurSites.choiceOurSites.selectedIndex].value;
splitc=refOurSites.lastIndexOf("*");
target="";
if (splitc!=-1)
{loc=refOurSites.substring(0,splitc);
target=refOurSites.substring(splitc+1,1000);}
else {loc=refOurSites; target="_blank";};
if (refOurSites != "") {landOurSites(loc,target);}
}


//Begin Email a friend script

/*
    Turn the email form on / off
*/
    function changeEmailOnOff(){
        if ( (x = MM_findObj("divEmail")) != null ){
            if (x.style.display == "none")
                x.style.display = "";        
            else
                x.style.display = "none";    
        }
    }

/*
    Show the email form 
*/
    function showEmail(){
        if ( (x = MM_findObj("divEmail")) != null ){
            x.style.display = "";
        }
    }

/*
    Hide the email form 
*/
    function hideEmail(){
        if ( (x = MM_findObj("divEmail")) != null ){
            x.style.display = "none";
        }
    }

/*
    Add the email to the list 
*/
    function addOption(){
        if ( ((el = MM_findObj("emailList")) != null) && ((e = MM_findObj("email")) != null) && e.value != ""){
            if ( checkEmail(e.value) ){
                el.options[el.options.length] = new Option(e.value, e.value);
                e.value = "";
            }
            else 
                alert("'"+e.value+"' is not a valid email address");
        }
    }

/*
    Remove the email from the list 
*/
    function removeOption(){
        if ( ((el = MM_findObj("emailList")) != null)){
            for (i = el.length - 1; i >=0 ; i--){
                if (el.options[i].selected){
                    el.options[i] = null;
                }
            }
        }
    }

/*
    Validate the email format 
*/
    function checkEmail(email){
      spi = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
        if (!spi.test(email)){
            return false;
        }
        return true;
    }


/*
    Form validation
*/
    function submitForm(){
        check = false;
        msg = "";
        if ( ((el = MM_findObj("emailList")) != null)){
            for ( i = 0; i < el.options.length ; i++){
                el.options[i].selected = "selected";
                check = true;
            }
        }

        spi = /^\s*$/;
        if ( ((el = MM_findObj("sender")) != null)){
            if (spi.test(el.value))
                msg += "Please input \"Your Name\"\n";
        }

        if ( ((el = MM_findObj("senderEmail")) != null)){
            if (spi.test(el.value))
                msg += "Please input \"Your E-mail\"\n";
            else
                if ( !checkEmail(el.value) )
                    msg += "'"+el.value+"' is not a valid email address";
        }

        if (!check)
            msg += "Please input \"Recipient E-mail\"\n";

        if (msg == ""){
            window.open('','emailWindow','top=0,left=0,directories=no,height=200,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=300');
            if ( ((fm = MM_findObj("frmEmail")) != null)){
                fm.target = "emailWindow";
				fm.articleLink.value = self.location; 
                fm.submit();
                self.location = self.location;
            }
        }
        else
            alert (msg);
    }

    function MM_findObj(n, d) { //v4.0
    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 && document.getElementById) 
        x=document.getElementById(n); 
    return x;
}
//Clos email a friend script
