// Script written by Drew Noakes -- http://drewnoakes.com
// 14 Dec 2006

var HintClass = "hintTextbox";
var HintActiveClass = "hintTextboxActive";

// define a custom method on the string class to trim leading and training spaces
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };


function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
if (hasClass(ele,cls)) {
var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
ele.className=ele.className.replace(reg,' ');
}
}

function initHintTextboxes() {
  var inputs = document.getElementsByTagName('input');
  for (var i=0; i<inputs.length; i++) {
    var input = inputs[i];
    if (input.type!="text" && input.type!="password")
      continue;
      
    if (hasClass(input,HintClass)) {
      input.hintText = input.value;
      input.onfocus = onHintTextboxFocus;
      input.onblur = onHintTextboxBlur;
    }
  }
}

function onHintTextboxFocus() {
  var input = this;
  if (input.value.trim()==input.hintText) {
    input.value = "";
    addClass(input,HintActiveClass);
  }
}

function onHintTextboxBlur() {
  var input = this;
  if (input.value.trim().length==0) {
    input.value = input.hintText;
    removeClass(input,HintActiveClass);
  }
}

var t;
var timer_is_on=0;
var actualInput;
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (var i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					
				  var inputs = this.getElementsByTagName("input");   
          for (var j = 0; j < inputs.length; j++) {
            if (inputs[j].type=="text" || inputs[j].type=="password"){
            
            inputs[j].disabled=false;
            if(timer_is_on==1){
            timer_is_on=0; 
            clearTimeout(t);
            }
           }
          }
          
				}
				node.onmouseout=function() {	
				  actualInputs = this.getElementsByTagName("input");  
          timer_is_on=1;
				  t=setTimeout("inputDisable()",200);
			}
		}
	}
}}

function inputDisable(){ 
          for (var j = 0; j < actualInputs.length; j++) { 
          if (actualInputs[j].type=="text" || actualInputs[j].type=="password"){
            actualInputs[j].disabled=true;
            
           }
				}
}


function alternate(id){
 if(document.getElementsByTagName){  
   var tables = document.getElementById(id);
   var table = tables.getElementsByTagName("table");  
   for(var j = 0; j < table.length; j++){  
   var rows = table[j].getElementsByTagName("tr");  
   for(var i = 0; i < rows.length; i++){          
 //manipulate rows
     if(i % 2 == 0){
       rows[i].className = "even";
     }else{
       rows[i].className = "odd";
     }      
   }
   }
 }
}

function onTooltip(event){
Tip("<div class=\'tip\';>"+this.getAttribute("tooltip")+"</div>",DELAY,0);
}
 


function getElementsByClass(searchClass,node,tag) {
        var classElements = new Array();
        if ( node == null )
                node = document;
        if ( tag == null )
                tag = '*';
        var els = node.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
        for (i = 0, j = 0; i < elsLen; i++) {
                if ( pattern.test(els[i].className) ) {
                        classElements[j] = els[i];
                        j++;
                }
        }
        return classElements;
}



function tooltips(id){
    var nodes = getElementsByClass("products");
    for(var j = 0; j < nodes.length; j++){ 
   var anchors = getElementsByClass(id,nodes[j]);
    for(var i = 0; i < anchors.length; i++){        
 //manipulate rows
    title=anchors[i].getAttribute("tooltip",null,"a");
     if(title!=null && title.length>0){
      anchors[i].onmouseover = onTooltip;
      anchors[i].onmouseout = UnTip;
     }
  }
  }
 }




function init() {
startList();
initHintTextboxes();
tooltips("productName");
tooltips("productImage");
alternate("centerColumn");

if(document.getElementById("slider")){
featuredcontentslider.init({
id: "slider", //id of main slider DIV
contentsource: ["inline", ""], //Valid values: ["inline", ""] or ["ajax", "path_to_file"]
toc: "markup", //Valid values: "#increment", "markup", ["label1", "label2", etc]
nextprev: ["", "Next"], //labels for "prev" and "next" links. Set to "" to hide.
revealtype: "mouseover", //Behavior of pagination links to reveal the slides: "click" or "mouseover"
enablefade: [true, 0.07], //[true/false, fadedegree]
autorotate: [true, 3000], //[true/false, pausetime]
onChange: function(previndex, curindex){ //event handler fired whenever script changes slide
//previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
//curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)
}
});
}


}
window.onload = init; 


