﻿
function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
  //window.alert('hey stoopid');
   return false;
   }
else
   return true;
}


function swapBG(targetCol,colColor,targetHeader, newBG, banner,imgSource)
{
    //simply put... get the target to change the bacground of
    document.getElementById(targetHeader).style.background='url('+newBG+')';
    //also change the bacground of the column
    targetCol.style.backgroundColor=colColor;
    if(!banner == "")
    {
    document.getElementById(banner).src=imgSource;
    }
}

//hides expandable text section
function HideExtraText2(sender)
{
    if (document.getElementById("ext_text").style.display=='block')
    {
        document.getElementById("ext_text").style.display='none';
    }
    else
    {
        document.getElementById("ext_text").style.display='block';
    }
}
//hides expandable text section
function HideExtraText(sender)
{
    if (document.getElementById("ext_text").style.display=='block')
    {
        document.getElementById("ext_text").style.display='none';
        sender.innerText='read more...';
    }
    else
    {
        document.getElementById("ext_text").style.display='block';
        sender.innerText ='hide text...';
    }
}

function HideExtraTextIMG(sender)
{
    if (document.getElementById("ext_text").style.display=='block')
    {
        document.getElementById("ext_text").style.display='none';
        sender.src='images/buttons/read-more.png';
    }
    else
    {
        document.getElementById("ext_text").style.display='block';
        sender.src='images/buttons/hide-text.png';
    }
}

function HideExtraTextIMG1(sender)
{
    if (document.getElementById("ext_textIMG").style.display=='block')
    {
        document.getElementById("ext_textIMG").style.display='none';
        sender.src='images/buttons/readMore.gif';
    }
    else
    {
        document.getElementById("ext_textIMG").style.display='block';
        sender.src='images/buttons/hideTxt.gif';
    }
}

function HideExtraSecByID(sender, SecID) {
    if (document.getElementById("extSec_text" + SecID).style.display == 'block') {
        document.getElementById("extSec_text" + SecID).style.display = 'none';
        sender.innerText = 'Color Guide';
    }
    else {
        document.getElementById("extSec_text" + SecID).style.display = 'block';
        sender.innerText = 'Hide';
    }
}

//cancels "Enter" button
function CatchEnter(){if (event.keyCode == 13){event.cancelBubble = true; event.returnValue = false;}}


//used to hide or show various span elements...
//created for the product page on the label "(click here)"
function hideSpan()
{
var spanID;
var totalElements = 16;
    for(i = 0; i < totalElements; i++)
    {
        spanID = "click_span"+i;
       // window.alert(spanID);
       if( document.getElementById(spanID))
       {
         document.getElementById(spanID).className ='hideSpan';
       }
       
    }
}
//I could set up the available buttons, so I just need a reference, 
//give it an image ID:button_Base,  and a relative path to the button: button_over, 
//also to mimick the current functionlaity give it a table name
function table_swap(button_base, button_over,table)
{
    document.getElementById(button_base).src = button_over; 
    highlight(document.getElementById(table));
}

function table_swap_return(button_base, button_over,table)
{
   
    document.getElementById(button_base).src = button_over; 
    unhighlight(document.getElementById(table));
}

//changes the table border color to yellow
//changes the header image to the yellow bg
function highlight(table)
{	
	table.style.borderColor = '#fac805';
	table.style.backgroundImage = 'url(images/pages/global/header_2.jpg)';
}
//changes the table border color to light gray
//changes the header image to the gray bg
function unhighlight(table)
{	
	table.style.borderColor = '#cccccc';
	table.style.backgroundImage = 'url(images/pages/global/header_1.jpg)';
}
//changes the table border color to yellow
//changes the header image to the yellow bg
//changes the black buy button to the yellow buy button
function highlightTB(table, buyButton)
{	
	document.getElementById(table).style.borderColor = '#fac805';
	document.getElementById(table).style.backgroundImage = 'url(images/pages/global/header_2.jpg)';
	document.getElementById(buyButton).src="images/buttons/yellowbuy-quote.gif";
}
//changes the table border color to light gray
//changes the header image to the gray bg
//changes the yellow buy button to the black buy button
function unhighlightTB(table, buyButton)
{	
	document.getElementById(table).style.borderColor = '#cccccc';
	document.getElementById(table).style.backgroundImage = 'url(images/pages/global/header_1.jpg)';
	document.getElementById(buyButton).src="images/buttons/blkbuy-quote.gif";
}
//changes the table border color to yellow
//changes the header image to the yellow bg
//changes the black buy button to the yellow buy button
function highlightSwitch(table, imageID, fileName)
{	
	document.getElementById(table).style.borderColor = '#fac805';
	document.getElementById(table).style.backgroundImage = 'url(images/pages/global/header_2.jpg)';
	document.getElementById(imageID).src="images/buttons/" +fileName;
}
//changes the table border color to light gray
//changes the header image to the gray bg
//changes the yellow buy button to the black buy button
function unhighlightSwitch(table, imageID, fileName)
{	
	document.getElementById(table).style.borderColor = '#cccccc';
	document.getElementById(table).style.backgroundImage = 'url(images/pages/global/header_1.jpg)';
	document.getElementById(imageID).src="images/buttons/" +fileName;
}
//changes the source of an image
function changeImage(imageID, imageSrc)
{
	document.getElementById(imageID).src=imageSrc;
}
//changes the sidebar table border color to yellow
//changes the header image to the yellow bg
function highlightSB(table)
{	
	table.style.borderColor = '#fac805';
	table.style.backgroundRepeat = 'no-repeat';
	table.style.backgroundImage = 'url(images/pages/masterpage/rounded-header-yellow.png)';
}

//changes the table border color to light gray
//changes the header image to the gray bg
function unhighlightSB(table)
{	
	table.style.borderColor = '#cccccc';
	table.style.backgroundRepeat = 'no-repeat';
	table.style.backgroundImage = 'url(images/pages/masterpage/rounded-header-grey.png)';
}

function highlightIndex(li) {
    li.style.backgroundImage = 'url(../images/pages/solutions/category/index-selected.png)';
    li.style.backgroundRepeat = 'no-repeat';
}

function unhighlightIndex(li) {
    li.style.backgroundImage = 'none';
}

function highlightAccountSidebar(li) {
    li.style.borderColor = '#e94f1a';
}

function unhighlightAccountSidebar(li) {
    li.style.borderColor = '#e2e2e2';
}

//opens a new browser window
	var win = null;
	function newWindow(mypage,myname,w,h,features) {
		var settings = '';
		if (w > 0 && h > 0){
			var winl = (screen.width-w)/2;
			var wint = (screen.height-h)/2;
			if (winl < 0) winl = 0;
			if (wint < 0) wint = 0;
			settings = 'height=' + h + ',';
			settings += 'width=' + w + ',';
			settings += 'top=' + wint + ',';
			settings += 'left=' + winl + ',';
			settings += features;
		}
		else
		  settings = features;
		  
		win = window.open(mypage,myname,settings);
		
		if (win != null)
			win.window.focus();
	} 

//redirects a button to the specified url
function goToURL(pageURL)
{ window.location = pageURL; }
function openNew(pageURL)
{ newwin=window.open(pageURL,'newwin','width=50,height=50,outerWidth=1000,outerHeight=1000');
  
 }

//used to show the fake popup window
function showWindow(pageID)
{
    document.getElementById(pageID).style.visibility="visible";
}

//used to hide the fake popup window
function hideWindow(pageID)
{
    document.getElementById(pageID).style.visibility="hidden";
}

//used to show the fake popup window
function showWindowIFrame(iframeID, layerID)
{
    //document.getElementById(iframeID).style.display="block";
    var iframe = document.getElementById(iframeID)
    var layer = document.getElementById(layerID)

    layer.style.visibility="visible";
    iframe.style.visibility="visible";
    iframe.style.width=layer.offsetWidth;
    iframe.style.height=layer.offsetHeight;
    iframe.style.left=layer.offsetLeft;
    iframe.style.top=layer.offsetTop;
}

//used to hide the fake popup window
function hideWindowIFrame(iframeID, layerID)
{
    //document.getElementById(iframeID).style.display="none";
    document.getElementById(iframeID).style.visibility="hidden";
    document.getElementById(layerID).style.visibility="hidden";
}

//print the page
var gAutoPrint = true; //Tells whether to automatically call the print function
var hide_items = false;
function printSpecial()
{
    if (document.getElementById != null)
    {
    var html = '<HTML>\n<HEAD>\n';

    hide_items = true;

    //html += "<script src=\"http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js\" type=\"text/javascript\"></script>";
    //html += "<script language=\"javascript\" type=\"text/javascript\">";
    //html += "hide_items = true;";
    //html += "$(document).ready(function() {"; //ready Begin
    //html += "$(\".ItemActionButtons\").each(function() {$(this).toggleClass(\"HiddenItem\");});";
    //html += "});"; //ready End
    //html += "</script>";
    //html += "<style type=\"text/css\">.HiddenItem{background: transparent; display: none;}</style>";

    if (document.getElementsByTagName != null)
    {
    var headTags = document.getElementsByTagName("head");
    if (headTags.length > 0)
    html += headTags[0].innerHTML;
}

    html += '\n</HEAD>\n<BODY>\n';

    var printReadyElem = document.getElementById("printReady");

    if (printReadyElem != null)
    {
    html += printReadyElem.innerHTML;
    }
    else
    {
    alert("Could not find the printReady function");
    return;
    }

    //html += "<script src=\"scripts/common.js\"></script>";
    html += "<script src=\"scripts/jquery.js\"></script>";
    html += "<script language=\"javascript\" type=\"text/javascript\" defer>";
    //html += "hide_items = true;";
    //html += "$(document).ready(function() {"; //ready Begin
    //html += "$(\".ItemActionButtons\").each(function() {$(this).toggleClass(\"HiddenItem\");});";
    //html += "});"; //ready End
    //html += "</script>";
    //html += "<SCRIPT language=javascript src=\"scripts/common.js\" type=text/javascript></SCRIPT>";

    //html += "<script language=\"javascript\" type=\"text/javascript\" defer>";
    //html += "hide_items_all();<!-- x -->";
    //html += "changecss('.ItemActionButtons', 'display', 'none');";
    html += "hide_tables('ItemActionButtons')";
    html += "</script>";

    html += '\n</BODY>\n</HTML>';

    var printWin = window.open("","printSpecial");
    printWin.document.open();
    printWin.document.write(html);
    printWin.document.close();
    if (gAutoPrint)
    printWin.print();
    }
    else
    {
    alert("The print ready feature is only available if you are using an browser. Please update your browser.");
    }
}

// http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
function getWidthHeight() {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    //window.alert('Width = ' + myWidth);
    //window.alert('Height = ' + myHeight);
    return [myWidth, myHeight];
}

// http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
function getScrollXY() {
    var scrOfX = 0, scrOfY = 0;
    if (typeof (window.pageYOffset) == 'number') {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }
    return [scrOfX, scrOfY];
}

function isdefined(variable) {
    return (typeof (window[variable]) == "undefined") ? false : true;
}

function changecss(theClass, element, value) {
    //Last Updated on June 23, 2009
    //documentation for this script at
    //http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
    var cssRules;

    var added = false;
    for (var S = 0; S < document.styleSheets.length; S++) {

        if (document.styleSheets[S]['rules']) {
            cssRules = 'rules';
        } else if (document.styleSheets[S]['cssRules']) {
            cssRules = 'cssRules';
        } else {
            //no rules found... browser unknown
        }

        for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
            if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
                if (document.styleSheets[S][cssRules][R].style[element]) {
                    document.styleSheets[S][cssRules][R].style[element] = value;
                    added = true;
                    break;
                }
            }
        }
        if (!added) {
            if (document.styleSheets[S].insertRule) {
                document.styleSheets[S].insertRule(theClass + ' { ' + element + ': ' + value + '; }', document.styleSheets[S][cssRules].length);
            } else if (document.styleSheets[S].addRule) {
                document.styleSheets[S].addRule(theClass, element + ': ' + value + ';');
            }
        }
    }
}

function hide_tables(tableClassName) {
    var tables = document.getElementsByTagName("TABLE");
    for (var i = tables.length - 1; i >= 0; i -= 1) {
        if (tables[i] && tables[i].className == tableClassName)//tables[i].parentNode.removeChild(tables[i]);
        {
            tables[i].className = "HiddenItem";
        }
    }
}
