var old_letter = null;

function jump(obj) {
        var olds = new Array;
        var name1 = old_letter.id.split('let');
        var name2 = "a2let" + name1[1];
        name1 = "a1let" + name1[1];

        olds[0] = document.getElementById(name1); olds[1] = document.getElementById(name2);
        for(i=0; i<=1; i++){
        olds[i].style.fontSize = "12px"; olds[i].style.color = "gray"; olds[i].style.border = "none";
        }
        //alert(obj);
        
        var news = new Array;
        var name3 = obj.id.split('let');
        var name4 = "a2let" + name3[1];
        name3 = "a1let" + name3[1];
        news[0] = document.getElementById(name3); news[1] = document.getElementById(name4);
        for(i=0; i<=1; i++){
        news[i].style.fontSize = "18px"; news[i].style.color = "black"; news[i].style.borderBottom = "2px solid black";
        news[i].onmouseover = ""; news[i].onmouseout= "";
        }
        old_letter = obj;
        
        var letNum = new Array("", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
        
        var name = obj.id;
        name = name.split("let");
        name = "#" + getInnerText(obj) //letNum[name[1]];
        window.location = name;     
}

function setup (total, begin, instance, letNum) {
        //
        if ((!letNum)||(letNum.length<=1))
        {
            var letNum = new Array("", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
        }
        if (!total) { total = letNum.length-1; }

        var end = total + 1;
        var premier = begin;
        //var premier = begin + 1;
        for(i=premier; i<end; i++) {
        var name = instance + "let" + i;
        if (document.getElementById(name)) { 
                obj = document.getElementById(name);
                obj.onmouseover = function () {
                        this.style.fontSize = "16px";        
                        }
                obj.onmouseout = function () {
                        this.style.fontSize = "12px";        
                        }
//                obj.onclick = function (obj,letNum) { 
//                        if ((!letNum)||(letNum.length<=1))
//                        {
//                            var letNum = new Array("", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
//                        }
//                        
//                        var myObj = this.id.split('let');

//                        var i = myObj[1];
//                        
//                        
//                        var url = document.URL; 
//                        var filename = url.substring(url.lastIndexOf("\\")+1,url.lastIndexOf("\."));
//                        var currChar = filename.substring(filename.lastIndexOf("-")+1);
//                        var newfilename = "";

//                        if (currChar.length > 1){
//                            newfilename = filename + "-" + getInnerText(this) + ".aspx";
//                        } else {
//                            newfilename = filename.substring(0,filename.lastIndexOf("-")) + "-" + getInnerText(this) + ".aspx";
//                        }

//                        /* // OLD CODE
//                        if (currChar.length > 1){
//                            newfilename = filename + "-" + letNum[i].toUpperCase() + ".aspx";
//                        } else {
//                            newfilename = filename.substring(0,filename.lastIndexOf("-")) + "-" + letNum[i].toUpperCase() + ".aspx";
//                        }
//                        */
//                        window.location = url.substring(0, url.lastIndexOf("\\")) + newfilename;
//                        //jump(this);        
//                        }
                }
        }
        //document.getElementById("let1").onclick();
        
        name = instance + "let" + begin;
        obj = document.getElementById(name);
        obj.style.fontSize = "18px"; obj.style.color = "black"; obj.style.borderBottom = "2px solid black";
        obj.onmouseover = "";
        obj.onmouseout = "";
        //obj.onclick = function () {jump(this); }
        old_letter = obj;
                
        obj = document.getElementById(instance + "let27");
        obj.onmouseover = function () {this.style.fontSize = "16px";}
        obj.onmouseout = function () {this.style.fontSize = "12px";}
//        obj.onclick = function () {document.getElementById(name).onclick();}
        obj.onclick = function () {window.location = document.getElementById(name).href;}

}

function toggleState(id) {
        var obj = document.getElementById(id);
        if (obj != undefined)
        {
            if (obj.style.display == "block") {obj.style.display = "none"; }
            else {obj.style.display = "block"; }
        }

    }
    
    
function hide(id) {
        var obj = document.getElementById(id);
        if (obj != undefined)
        {
            obj.style.display = "none";
        }
    }

function show(id) {
        var obj = document.getElementById(id);
        if (obj != undefined)
        {
            obj.style.display = "block";
        }
    }

// MODIFIED BY SATHISH (ORIGINAL BELOW)
// MODIFIED TO ADD HREF LINKS SO THAT THE SEARCH ENGINE CAN FOLLOW
function letNav(total, begin, instance, letNum, link) {
        if (!begin) { begin = 1;}
        if (!instance) {instance = "a1";}
        if ((!letNum)||(letNum.length<=1))
        {
            var letNum = new Array("", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
        } 
        /*else { 
            if (letNum.length <= 1) {
                var letNum = new Array("", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
            }
        }*/
        
        if (!total) { total = letNum.length-1; }

        //Total MUST be >= 1
        var ui='<ul class="alphabet">';
        var end = total + 1

        if (!link)
        {
            var url = document.URL; 
            var filename = url.substring(url.lastIndexOf("\\")+1,url.lastIndexOf("\."));
            var currChar = filename.substring(filename.lastIndexOf("-")+1);
            
            if (currChar.length > 1){
                link = filename + "-";
            } else {
                link = filename.substring(0,filename.lastIndexOf("-")) + "-";
            }
        }

        for(i=begin; i<end; i++) {ui += '<li style="cursor: pointer;" id="' + instance + 'letli' + i + '"><a id="' + instance + 'let' + i + '" style="font-size:12px;color:gray;border:none;cursor: pointer;" href="' + link + letNum[i] + '.aspx">' +  letNum[i] + '</a></li>';}
        ui += '<li id="' + instance + 'let27"> - back to top</li></ul>';    
        document.write(ui);
        setup (total, begin, instance, letNum);
        }
        
/* // COMMENTED BY SATHISH, OCTOBER 14, 2008 (a modified function has been placed instead of below)

function letNav(total, begin, instance, letNum) {
        if (!begin) { begin = 1;}
        if (!instance) {instance = "a1";}
        if ((!letNum)||(letNum.length<=1))
        {
            var letNum = new Array("", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
        } 
        
        if (!total) { total = letNum.length-1; }

        //Total MUST be >= 1
        var ui='<ul class="alphabet">';
        var end = total + 1


        for(i=begin; i<end; i++) {ui += '<li style="cursor: pointer;" id="' + instance + 'let' + i + '">' +  letNum[i] + '</li>';}
        ui += '<li id="' + instance + 'let27"> - back to top</li></ul>';    
        document.write(ui);
        setup (total, begin, instance, letNum);
        }
*/
        
/*    
function letNav() {
          var ui='<ul class="alphabet"><li id="let1">A</li><li id="let2">B</li><li id="let3">C</li><li id="let4">D</li><li id="let5">E</li><li id="let6">F</li><li id="let7">G</li><li id="let8">H</li><li id="let9">I</li><li id="let10">J</li><li id="let11">K</li><li id="let12">L</li><li id="let13">M</li><li id="let14">N</li><li id="let15">O</li><li id="let16">P</li><li id="let17">Q</li><li id="let18">R</li><li id="let19">S</li><li id="let20">T</li><li id="let21">U</li><li id="let22">V</li><li id="let23">W</li><li id="let24">X</li><li id="let25">Y</li><li id="let26">Z</li><li id="let27"> - back to top</li></ul>';    
document.write(ui);
}*/

if (!navigator.userAgent.match("MSIE")) {
    //ammend style if we're not on IE
    document.write("<style>");
    document.write(".products {width: 231px;} .nonschool{padding-bottom: 1px;}");
    document.write("</style>");

}

function getInnerText(obj){
  if (document.all) { // IE;
    return obj.innerText;
  }
  else{
    if (obj.text)
    {
      return obj.text; 
    }
    else
      return "";
  }
} 

function validate_field(field,NOTvalue)
{
    with (field)
    {
        if (value==null||value==NOTvalue)
          {return false;}
        else {return true}
    }
}

function validate_email(field)
{
    with (field)
    {
        apos=value.indexOf("@");
        dotpos=value.lastIndexOf(".");
        if (apos<1||dotpos-apos<2) 
          {return false;}
        else {return true;}
    }
}

function validateBulkOrderForm(thisForm,alertText) {
    with (thisForm)
    {
        if (validate_field(ProductType,"") && validate_field(Color,"") && validate_field(Quantity,"") && validate_field(DecorationType,"") && validate_field(NoOfPrintColors,"") && validate_field(NoOfPrintLocations,""))
        {
            if (validate_email(EmailAddress)) {
                return true;          
            } else {
                alert("Please enter a valid email address.");
                return false;
            }
        }
        else
        {
            alert(alertText);
            return false;
        }
    }
}

function validateSchoolInfoForm(thisForm) {
    with (thisForm)
    {
        if (validate_field(SchoolName,"") && validate_field(SchoolCity,"") && validate_field(SchoolState,"") && validate_field(GradeLevels,""))
        {
            if (validate_email(Email)) {
                return true;          
            } else {
                alert("Please enter a valid email address.");
                return false;
            }
        }
        else
        {
            alert("Please fill in all the fields marked with asteriks(*) to continue.");
            return false;
        }
    }
}

function validateContactForm(thisForm) {
    with (thisForm)
    {
        if (validate_email(Email)) {
            return true;          
        } else {
            alert("Please enter a valid email address.");
            return false;
        }
    }
}

function validateMailingListForm(thisForm) {
    with (thisForm)
    {
            if (validate_email(email)) {
                thisForm.submit();
                return true;        
            } else {
                alert("Please enter a valid email address.");
                return false;
            }
    }
}

function bulk_order_submit() {
    alert("Thank you for your request!  We will respond within 48 hours to the email address provided.");
}

function mailing_list_submit() {
    alert("Thank You!");
}

function team_submit() {
    alert("Thank You! We will respond to you within 48 hours to the email you provided.");
}

function changeSportImage(path, obj)
{
	document.getElementById(obj).src=path;
}