// JavaScript Document

/* ####################################################### */
/* Script for Product Detail Tabs Hide and Show */

//if (document.images && document.location.href.indexOf('sitemap.asp')==-1){
if (document.images){
	var badvantageon=new Image();badvantageon.src="images/nav_tabs/Tab_ToshAdv2.gif";
	var badvantageoff=new Image();badvantageoff.src="images/nav_tabs/Tab_ToshAdv.gif";
	var badvantageover=new Image();badvantageover.src="images/nav_tabs/Tab_ToshAdv2.gif";
	
	var bsolutionson=new Image();bsolutionson.src="images/nav_tabs/Tab_EmbedSol2.gif";
	var bsolutionsoff=new Image();bsolutionsoff.src="images/nav_tabs/Tab_EnbedSol.gif";
	var bsolutionsover=new Image();bsolutionsover.src="images/nav_tabs/Tab_EmbedSol2.gif";
		
	var bintegrationon=new Image();bintegrationon.src="images/nav_tabs/Tab_SimplifyInt2.gif";
	var bintegrationoff=new Image();bintegrationoff.src="images/nav_tabs/Tab_Simplify.gif";
	var bintegrationover=new Image();bintegrationover.src="images/nav_tabs/Tab_SimplifyInt2.gif";
	
	var bqaon=new Image();bqaon.src="images/nav_tabs/Tab_MLCnand2.gif";
	var bqaoff=new Image();bqaoff.src="images/nav_tabs/Tab_MLCnand.gif";
	var bqaover=new Image();bqaover.src="images/nav_tabs/Tab_MLCnand2.gif";
	
	
}



/* Product Detail panel handling */
var currentOpenInfo="advantage";

function actInfo(id){
	if(id!=currentOpenInfo){
		var buttname="b"+id;
		act(buttname);
	}
}

function inactInfo(id){
	//alert('id='+id+'\ncurrentOpenInfo='+currentOpenInfo);
	if(id!=currentOpenInfo){
		var buttname="b"+id;
		inact(buttname);
	}
}

function viewInfo(id){
	if(id!=currentOpenInfo){
		var buttname="b"+id;
		var prevbuttname="b"+currentOpenInfo;
		closePane(currentOpenInfo);
		if(document[prevbuttname])document[prevbuttname].src=eval(prevbuttname+'off.src');
		openPane(id);		
		document[buttname].src=eval(buttname+'on.src');
		currentOpenInfo=id;
	}
	//alert('id='+id+'\ncurrentOpenInfo='+currentOpenInfo);
}
function closePane(id){
	var theObj=getElementRef(id)
	if (theObj) {
		if (dom1||ie4plus){
			theObj.style.display='none';
		} else {
			theObj.display='none';
		}
	}
}

function openPane(id){
	var theObj=getElementRef(id)
	if (theObj) {
		if (dom1||ie4plus){
			theObj.style.display='block';
		} else {
			theObj.display='block';
		}
	}
}
/* ############################################################# */
/* Script for Product Detail tabs content handling */


var cookieName='collapsedPanels';
var daysToKeep = 365; // 

var expires = new Date();
expires.setTime(expires.getTime()+(daysToKeep*24*60*60*1000));

function initPanelSettings(){
	get_array(cookieName, collapsedPanelsList);//updates array from cookie
	//numPanelsToHide=collapsedPanelsList.length;
	
	collapsedPanelsListstr=collapsedPanelsList.join("\n");
	//alert('collapsedPanelsList='+collapsedPanelsListstr)
	//alert(collapsedPanelsList.length)
	//if(collapsedPanelsList.length>0){
		//if(collapsedPanelsList[0]==null)alert(collapsedPanelsList[0])
		/*
		if(collapsedPanelsList.length>0){
			for (i=0; i<collapsedPanelsList.length; i++) {
				//remove null values?
				//alert(collapsedPanelsList[i])
				if(collapsedPanelsList[i]==null || collapsedPanelsList[i]=="null") {
					var x=i;
					//alert('trying to del collapsedPanelsList['+i+']');
					del_entry(cookieName, collapsedPanelsList, xs, expires)
				}
			}	
		}
		*/
		for (i=0; i<collapsedPanelsList.length; i++) {
			togglePane(collapsedPanelsList[i],true)//closes panel without re-adding to array (second param)
		}

}
/*
function isPanelDisplayed(id){
	var theObj=getElementRef(id);
	if(theObj==null)return null;
	if (theObj.style){
		if(theObj.style.display=='block') return true;
		else return false;
	}else if (theObj.display){
		if(theObj.display)=='block') return true;
		else return false;
	}else{
		return null;
	}
}
*/
function openPane(id){
	var theObj=getElementRef(id);
	if(theObj==null)return;
	if(theObj.style)theObj.style.display='block';
	else if(theObj.display)theObj.display='block';
}
function closePane(id){
	var theObj=getElementRef(id);
	if(theObj==null)return;
	if(theObj.style)theObj.style.display='none';
	else if(theObj.display)theObj.display='none';
}

function togglePane(id,nonewcookieentry){
	//alert('togglePane')
	var theObj=getElementRef(id);
	if(theObj==null)return;//why try if we know the browser cant
	//get_array(cookieName, collapsedPanelsList);//update array from cookie
	
	if (theObj) {
		if (theObj.style){//browsers that support the style object
			if (theObj.style.display=='block') {
				//hiding panel
				//alert('hiding '+id)
				theObj.style.display='none';
				convertToShow(id);
				if(nonewcookieentry!=true){
					//add panel to cookie
					
					//attempting to see if this is already in the array
					var existsinarray=false;
					for (var j=0; j<collapsedPanelsList.length; j++) {
						if(id==collapsedPanelsList[j]) existsinarray=true;
					}
					
					if (!existsinarray){
						collapsedPanelsList[collapsedPanelsList.length]=id;
						set_array(cookieName, collapsedPanelsList, expires);
					}
				}
			}
			else {
				//showing panel
				//alert('showing '+id)
				theObj.style.display='block';
				convertToHide(id)
				//removing panel from cookie
				for (var j=0; j<collapsedPanelsList.length; j++) {
					if(collapsedPanelsList[j]==id){
						var pos = j; // assign the number of the value within the cookie that is to be deleted
						del_entry(cookieName, collapsedPanelsList, pos, expires);//
					}
				}
			}
		} else {//browsers that DONOT support the style object
			if (theObj.display=='block') {
				//hiding panel
				theObj.display='none';
				convertToShow(id);
				if(nonewcookieentry!=true){
					//add panel to cookie
					collapsedPanelsList[collapsedPanelsList.length]=id;
					set_array(cookieName, collapsedPanelsList, expires);
				}
			}
			else {
				//showing panel
				theObj.display='block';
				convertToHide(id);
				//removing panel from cookie
				for (var j=0; j<collapsedPanelsList.length; j++) {
					if(collapsedPanelsList[j]==id){
						var pos = j; // assign the number of the value within the cookie that is to be deleted
						del_entry(cookieName, collapsedPanelsList, pos, expires);//
					}
				}
			}
		}
	}
}

var hidebutt=new Image();hidebutt.src='../img/butt_red_hide.gif';
var showbutt=new Image();showbutt.src='../img/butt_red_show.gif';
var hidenewsbutt=new Image();hidenewsbutt.src='../img/butt_greybar_hide.gif';
var shownewsbutt=new Image();shownewsbutt.src='../img/butt_greybar_show.gif';

function convertToHide(n){
	if(document.images){
		imgname='showhide'+n;
		thisbutt=document[imgname];
		thisbutt.src=(n.indexOf('news')==-1)?hidebutt.src:hidenewsbutt.src;
		thisbutt.alt='Click to hide';
	}
}
function convertToShow(n){
	if(document.images){
		imgname='showhide'+n;
		thisbutt=document[imgname];
		thisbutt.src=(n.indexOf('news')==-1)?showbutt.src:shownewsbutt.src;
		thisbutt.alt='Click to show';
	}
}

var dom1=(document.getElementById)?1:0;
var ie4plus=(document.all)?1:0;
var ns4=(document.layers)?1:0;
var safari=(navigator.appVersion.indexOf("Safari") != -1)?1:0;
var mac=(navigator.appVersion.indexOf("Macintosh") != -1)?1:0;
var lowerUserAgent=navigator.userAgent.toLowerCase();
var opera = (lowerUserAgent.indexOf('opera')!=-1)?true:false;


function pact(imgN){if (document.images) document[imgN].src=pbuttover.src;}
function pinact(imgN){if (document.images) document[imgN].src=pbuttoff.src;}
function gact(imgN){if (document.images) document[imgN].src=gobuttover.src;}
function ginact(imgN){if (document.images) document[imgN].src=gobuttoff.src;}
function act(imgN){	if (document.images) document[imgN].src=eval(imgN+'over.src');}
function inact(imgN){if (document.images) document[imgN].src=eval(imgN+'off.src');}

function isUndefined(v) {
    var undef;
    return v===undef;
}

function getElementRef(id){
	if (dom1) return document.getElementById(id);
	else if (ie4plus) return document.all[id];
	else if (ns4) return document.layers[id];
	else return null;
}

//END
// Open and Close section 

function toggleFirstSection(divObj1,divObj2) {

state = document.getElementById(divObj2).style.display;

if(state != null && state == "none")
 {
 document.getElementById(divObj1).className = "firstSectionOpen";
 document.getElementById(divObj2).style.display = "block";
  } 
  else 
  {
	document.getElementById(divObj1).className = "firstSectionClose";
	document.getElementById(divObj2).style.display = "none";
  }
}

function toggleSecondSection(divObj1,divObj2) {

state = document.getElementById(divObj2).style.display;
 
 if(state != null && state == "none") 
 {
  document.getElementById(divObj1).className = "secondSectionOpen";
  document.getElementById(divObj2).style.display = "block";
  } 
  else 
  {
   document.getElementById(divObj1).className = "secondSectionClose";
   document.getElementById(divObj2).style.display = "none";
  }
}

function toggleThirdSection(divObj1,divObj2) {

state = document.getElementById(divObj2).style.display;
 
 if(state != null && state == "none") 
 {
  document.getElementById(divObj1).className = "thirdSectionOpen";
  document.getElementById(divObj2).style.display = "block";
  } 
  else 
  {
   document.getElementById(divObj1).className = "thirdSectionClose";
   document.getElementById(divObj2).style.display = "none";
  }
}
function toggleSectionA(divObj1,divObj2) {

state = document.getElementById(divObj2).style.display;

if(state != null && state == "none")
 {
 document.getElementById(divObj1).className = "sectionAOpen";
 document.getElementById(divObj2).style.display = "block";
  } 
  else 
  {
	document.getElementById(divObj1).className = "sectionAClose";
	document.getElementById(divObj2).style.display = "none";
  }
}
//END