/* Javascript Document */
/* Author: Travis Cunningham */
/* Date: 02/2008 */
/* Description: dts Onload Functions */


$jquery(function(){
	$jquery('#midNav ul').tabs({ unselected: false, cache: false });
	$jquery('#techTabs ul').tabs({ unselected: false, cache: false });
	//$jquery('#manuTabs ul').tabs({ unselected: false, cache: false });
	
	$jquery('#btnPrint').click(function(){window.print()});
	
	$jquery('#contentResults tr:odd').addClass('oddRow'); 
	$jquery('#trailerResults tr:even').addClass('evenRow'); 
	
	$jquery(".trigger").click(function () {
		var expandReady = true;
		if(expandReady && !$jquery(this).parent().next().hasClass("opened")) {
		expandReady = false;
		$jquery(".expand").animate({height: 'hide'}, "normal"); 
		$jquery(".trigger").removeClass("activeTrig");
		$jquery(".trigger").html('+');
		$jquery(".opened").removeClass("opened");
		$jquery(this).parent().next().animate({height: 'show'}, "normal", function() { expandReady = true; });
		$jquery(this).addClass("activeTrig");
		$jquery(this).parent().next().addClass("opened");
		$jquery(this).html('-');
		} 
	});
	
	$jquery(".hover").click(function () {
		var expandReady2 = true;
		if(expandReady2 && !$jquery(this).next().hasClass("hoverOn")) {
		expandReady2 = false;
		$jquery(".expand2").animate({height: 'hide'}, "normal"); 
		$jquery(".hoverOn").removeClass("hoverOn");
		$jquery(this).next().animate({height: 'show'}, "normal", function() { expandReady2 = true; });
		$jquery(this).next().addClass("hoverOn");
		} 
	});
	
	$jquery(".answer").click(function () {
		$jquery(this).next().toggle({height: 'show'}, "normal");
		if($jquery(this).hasClass("openAns")) {
		  $jquery(this).removeClass("openAns"); 
		}
		else {
		  $jquery(this).addClass("openAns");
		  var thisId = this.getAttribute('id');
		  var thisQuestion = this.getAttribute('question');
		  var thisCategory = this.getAttribute('category');
		  _sTrackFAQ(thisQuestion, thisCategory);	
		  url = "/Support/FAQ/Hit.aspx?q=" + thisId;
    	initRequest("POST", url, true,function(){})		  
		}
	});
	
	var currentLoc = window.location.hash;
	var anchorId = currentLoc.replace(/#/,'');		
	var answers = $jquery('.answer');
	//Compare URL to toggle faq answer open
	for(var i=0,z=answers.length;i<z;i++){
		if(anchorId == answers[i].id){
			var foundId = $jquery(anchorId);
			$jquery(foundId).next().toggle({height: 'show'}, "normal");
			$jquery(foundId).addClass("openAns");
			url = "/Support/FAQ/Hit.aspx?q=" + anchorId;
			initRequest("POST", url, true,function(){})
		}
	}
	
	/* ribbonObj= new Ribbon("ribbonCont","mainNavCont","ribbonObj"); */
	
	var innerLength = $jquery('#softSelectInner .softLink').length;
	if(innerLength > 0) {
		$jquery('#softSelectInner').width(innerLength * 150);
	}
	else {
		return false;
	}
});



function navbar(){
    this.container = "#mainNavCont";
    this.items = ["nav_consumer","nav_professional","nav_licensee"];
    this.timeout = 1000;
    this.timeIt = null;
    this.menu = null;
    this.menuDefault = "nav_consumer";
  }
  
navbar.prototype  = {
  setMenu : function(c){
      NAVBAR.menu = c;
  },
  doHover    : function(c) {
    this.setMenu(c);
    //$jquery("#navBlock div.secondaryNav").show();
    $jquery("#secondaryNavCont ul.subnav").hide();
    $jquery("#sub"+this.menu.id).css('display', 'inline');
    $jquery(this).css('background-position', '0 0');
    this.stopTimer();
    //this.timer();
  },
  doHoverOut : function(c){
    this.setMenu(c);
    $jquery("#secondaryNavCont ul.subnav").hide();
    //alert(this.menuDefault.id);
    $jquery("#sub"+this.menuDefault).css('display', 'inline');
    //var rdn=Math.floor(Math.random()*9 + 1);
    //$jquery("body").css({'background-color' : '#2'+rdn+'2'+rdn+'2'+rdn});
    if($jquery("ul.subnav").hover()){
      this.stopTimer();
    }
    else{
      this.timer();
    }
  },
  doClose : function(){
    $jquery("#secondaryNavCont ul.subnav").css('display', 'none');
    $jquery("#navBlock div.secondaryNav").css('display', 'none');
    this.stopTimer();
  },
  doClick : function(c) {
  	this.setMenu(c);
  	this.menuDefault = this.menu.id;
  	$jquery("#navBlock div.primaryNav a.btn_sprite").removeAttr("style");
    $jquery(this.menu).css('background-position', '0 0'); 
	  $jquery("#sub"+this.menu.id).css('display', 'inline');
	  this.stopTimer();
  },
  timer : function(c){
  	this.setMenu(c);
    this.timeIt = setTimeout('NAVBAR.doClose()', this.timeout);
  },
  stopTimer : function(c){
  	this.setMenu(c);
    if(this.timeIt){  
      clearTimeout(this.timeIt);
      this.timeIt = null;
    }
  }


};
  
//NAVBAR = new navbar();


