﻿// JScript File

//------------------------------------------------------------
// Created:     06/20/2008
// Author:      Lori Shandor (FKQ)
// Description: Toggles the display of a form element to hide
//              (expand)or show (collapse) an area of the form
//
// Input(s): Div object
//------------------------------------------------------------
function showHide(divid,imageid,skinid){
    // get the form objects
    var dv = document.getElementById(divid);
   
    // det the display
    dv.style.display = (dv.style.display == 'none') ? 'block' : 'none';
    
    // change the arrow image
    // ??????????????????????
    var im = document.getElementById(imageid);
    
    if (dv.style.display == 'none'){
        im.src = 'skins/skin_' + skinid + '/images/custom/bluearrow.gif';
    } 
    else{
        im.src = 'skins/skin_' + skinid + '/images/custom/red_arrow2.gif';
    }
}

//------------------------------------------------------------
// Created:     06/23/2008
// Author:      Lori Shandor (FKQ)
// Description: Toggles the display of a form element to hide
//              (expand)or show (collapse) an area of the form
//              and to change the clicked link text
//
// Input(s): Div object; link object
//------------------------------------------------------------
function showHideLinkTextChange(divid,lnkid){
    // get the form objects
    var dv = document.getElementById(divid);
    var lnk = document.getElementById(lnkid);
    
    // det the display
    dv.style.display = (dv.style.display == 'none') ? 'block' : 'none';
    
    // change the link text
    //  if(dv.style.display == "block"){
    //      lnk.innerHTML = "Hide";
    //  }else{
    //      lnk.innerHTML = "Show";
    //  }
}

//------------------------------------------------------------
// Created:     06/23/2008
// Author:      Lori Shandor (FKQ)
// Description: Copied from ./jscripts/tip2.js ddrivetip 
//              function. Displays the description with
//              an image instead of just the description.
//
// Input(s): Div object; link object
//------------------------------------------------------------
function ddrivetip2(theimage, thetext, thename, thecolor, thewidth)
{    
//alert(theimage);
//alert(thetext);
//alert(thename);
//alert(thecolor);
//alert(thewidth);
    if (ns6||ie){
        if (typeof thewidth != "undefined") tipobj.style.width = thewidth + "px";
        if (typeof thecolor != "undefined" && thecolor != "") tipobj.style.backgroundColor = thecolor;
        var newHTML = "";
        
        if(thename != "")
        {
            // both image and description
            if(theimage != "" && thetext != ""){
                newHTML = "<table cellpadding='5' cellspacing='0'><tr><td align='left' valign='top'><img src='" + theimage + "'></td><td align='left' valign='top'><b>" + thename + "</b><br><hr>" + thetext + "</td></tr></table>";
            }
            
            // image only; no description
            if(theimage != "" && thetext == ""){
                newHTML = "<table cellpadding='5' cellspacing='0'><tr><td align='left' valign='top'><img src='" + theimage + "'></td><td align='left' valign='top' width='100%'><b>" + thename + "</b><hr></td></tr></table>";
            }
            
            // description only; no image
            if(thetext != "" && theimage == "")
            {
                newHTML = "<table cellpadding='5' cellspacing='0'><tr><td align='left' valign='top'><b>" + thename + "</b><br><hr>" + thetext + "</td></tr></table>";
            }
        }
        else
        {
            // both image and description
            if(theimage != "" && thetext != ""){
                newHTML = "<table cellpadding='5' cellspacing='0'><tr><td align='left' valign='top'><img src='" + theimage + "'></td><td align='left' valign='top'>" + thetext + "</td></tr></table>";
            }
            
            // image only; no description
            if(theimage != "" && thetext == ""){
                newHTML = "<table cellpadding='5' cellspacing='0'><tr><td align='left' valign='top'><img src='" + theimage + "'></td><td align='left' valign='top' width='100%'></td></tr></table>";
            }
            
            // description only; no image
            if(thetext != "" && theimage == "")
            {
                newHTML = "<table cellpadding='5' cellspacing='0'><tr><td align='left' valign='top'>" + thetext + "</td></tr></table>";
            }        
        }
        
        tipobj.innerHTML = "";
        tipobj.innerHTML = newHTML;
        enabletip = true;
        return false;
    }
}

//------------------------------------------------------------
// Created:     09/16/2008
// Author:      Lori Shandor (FKQ)
// Description: Validates the values entered into the 
//              Contact Us from before submitting
//
// Input(s): form object
//------------------------------------------------------------
function validateContactUsForm(frm)
{
    var emailRegEx = /^[\w]+([\.-][\w]+)*@\w[\w\d]+([\.-][\w\d]+)*\.[a-z]{2,7}$/i;
    
    if(frm.Name.value == ""){
        alert("Please enter your full name.");
        frm.Name.focus();
        return false;
    }
    if(frm.EMail.value == ""){
        alert("Please enter your email address.");
        frm.EMail.focus();
        return false;
    }else{
        //Validate the email address
        if (!emailRegEx.test(frm.EMail.value)){
            alert("Please enter a valid email address.");
            frm.EMail.focus();
            return false;
        }
    }
    if(frm.Subject.value == ""){
        alert("Please enter a subject.");
        frm.Subject.focus();
        return false;
    }
    if(frm.Message .value == ""){
        alert("Please enter your message.");
        frm.Message.focus();
        return false;
    }    
    return true;
}

//------------------------------------------------------------
// Created:     03/13/2009
// Author:      Lori Shandor (FKQ) -
//              http://forums.karamasoft.com/ShowPost.aspx?PostID=4295
// Description: When the user clicks in the text box this
//              function removes the watermark text
//
// Input(s): form object
//------------------------------------------------------------
function WatermarkFocus(obj, strWatermark) {
    if (obj.value == strWatermark) {
        obj.value = '';
        obj.className='searchBox';
    }
}


//------------------------------------------------------------
// Created:     03/13/2009
// Author:      Lori Shandor (FKQ) - 
//              http://forums.karamasoft.com/ShowPost.aspx?PostID=4295
// Description: When the user clicks out of the text box
//              this function populates the textbox with 
//              the watermark text
//
// Input(s): form object
//------------------------------------------------------------
function WatermarkBlur(obj, strWatermark) {
    if (obj.value == '') {
        obj.value = strWatermark;
        obj.className='searchBoxWatermark';
    }else{
        obj.className='searchBox';
    }
}


//------------------------------------------------------------
// Created:     03/13/2009
// Author:      Lori Shandor (FKQ)
// Description: Validates the value entered into the 
//              search textbox
//
// Input(s): form object
//------------------------------------------------------------
function validateSearch(frm, objText) {
    if(frm.SearchTerm.value == "" || frm.SearchTerm.value == objText) {
        alert("Please enter a keyword for your search.");
        frm.SearchTerm.focus();
        return false;
    }
    return true;
}
