var active = "none";
var timer = 0;

function show_hide(id) {
	if(document.getElementById(id).style.display != 'none') {
		document.getElementById(id).style.display = 'none';
	}
	else {
		document.getElementById(id).style.display = 'block';
	}
}

function show(sid) {	
	clearTimeout(timer);
	document.getElementById(sid).style.display = "block";
	if(active != sid && active != "none") {
		hide(active);
	}
	active = sid;
}

function starthide(sid) {	
	timer = setTimeout("hide('"+sid+"')", 300);
}

function hide(sid) {
	clearTimeout(timer);
	document.getElementById(sid).style.display = "none";
}

function switch_qa(this_id,target_id){
	var this_qa_id='qa_'+this_id;
	var target_qa_id='qa_'+target_id;
	var this_link_id='link_qa'+this_id;
	var target_link_id='link_qa'+target_id;

	if(document.getElementById(this_qa_id).style.display == "none"){
		document.getElementById(target_qa_id).style.display = "none";
		document.getElementById(this_qa_id).style.display = "block";
		document.getElementById(this_qa_id).style.display = "block";
	}
		document.getElementById(this_link_id).style.color = "#787879";
		document.getElementById(this_link_id).removeAttribute("href");
		document.getElementById(target_link_id).style.color = "#a19f74";
		document.getElementById(target_link_id).removeAttribute("class");
		
		var styleattr=document.createAttribute("class");
		styleattr.nodeValue="no_hover"
		document.getElementById(this_link_id).setAttributeNode(styleattr);
		document.getElementById(target_link_id).setAttribute('href', '#questions-answers');
}

function switch_mainnav(nav_item,mode){

	if(mode==1){
		document.getElementById('menu_'+nav_item).style.backgroundColor = 'rgb(9,10,10)';		
		//alert(document.getElementById('menu_'+nav_item).style.backgroundColor);
	}
	else{
		document.getElementById('menu_'+nav_item).style.background = '#040507';
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function flip_arrow() {
	var path = document.getElementById('feedback-arrow').src;
	var arrow_down = "down_arrow.gif";
	var arrow_down2 = "down_arrow2.gif";
	if(path.lastIndexOf(arrow_down) > -1) {
		document.getElementById('feedback-arrow').src = arrow_down2;
	}
	else if(path.lastIndexOf(arrow_down2) > -1) {
		document.getElementById('feedback-arrow').src = arrow_down;
	}
}

function flip_arrow2(id) {
	alert(document.getElementById(id).backgroundImage);
	if (document.getElementById(id).style.background-image('/') !=-1){
		firstpos=document.getElementById(id).src.lastIndexOf('/')+1;
	}
	lastpos=document.getElementById(id).src.length;
	file_name=document.getElementById(id).src.substring(firstpos,lastpos);
	file_folder = document.getElementById(id).src.substring(0,firstpos);

	if(path.lastIndexOf(arrow_down) > -1) {
		document.getElementById('feedback-arrow').src = arrow_down2;
	}
	else if(path.lastIndexOf(arrow_down2) > -1) {
		document.getElementById('feedback-arrow').src = arrow_down;
	}
}

function flip_image(image_off, image_on, id) {
	var path = document.getElementById(id).src;
	if(path.lastIndexOf(image_off) > -1) {
		document.getElementById(id).src = image_on;
	}
	else if(path.lastIndexOf(image_on) > -1) {
		document.getElementById(id).src = image_off;
	}
}

function flip_image2(image_off, image_on, id) {

	if (document.getElementById(id).src.lastIndexOf('/') !=-1){
		firstpos=document.getElementById(id).src.lastIndexOf('/')+1;
	}
	lastpos=document.getElementById(id).src.length;
	file_name=document.getElementById(id).src.substring(firstpos,lastpos);
	file_folder = document.getElementById(id).src.substring(0,firstpos);
	//alert(file_folder + file_name);

	if(file_name == image_on) {
		//alert(image_on + " -> " + image_off);
		document.getElementById(id).src = file_folder + image_off;
	}
	if(file_name == image_off) {
		//alert(image_off + " -> " + image_on);
		document.getElementById(id).src = file_folder + image_on;
	}
}


function hoverRow(tableRow, highLight){
	if (highLight){
	  tableRow.style.backgroundColor = '#eef1f5';
	  tableRow.style.cursor = 'pointer';
	}
	else{
	  tableRow.style.backgroundColor = '#FFFFFF';
	  tableRow.style.backgroundImage = 'url(../images/rowbg.jpg)';
	  tableRow.style.backgroundPosition = 'top left';
	  tableRow.style.backgroundRepeat = 'repeat-y';
	  tableRow.style.cursor = 'default';
	}

}

function close_jukebox(){
	setCookie('wodjukebox',0);
	var cur_page=window.parent.siteFrame.location.href;
	//alert(cur_page);
	parent.location.href=cur_page;
}

function open_jukebox(track){
	str=new String(document.location.href);
	var result = "";
	
	for (i = 0; i < str.length; i++) {
		if (str.charAt(i) == " ") result += "+";
		else result += str.charAt(i);
	}
	
	var test = escape(result);
	//alert(test);

	var param2 = '&tid='+track;
	var result2 = "";
	
	for (i = 0; i < param2.length; i++) {
		if (param2.charAt(i) == " ") result2 += "+";
		else result2 += param2.charAt(i);
	}
	
	var param2_value = escape(result2);
}

function getcookie(cookiename) {
 var cookiestring=""+document.cookie;
 var index1=cookiestring.indexOf(cookiename);
 if (index1==-1 || cookiename=="") return ""; 
 var index2=cookiestring.indexOf(';',index1);
 if (index2==-1) index2=cookiestring.length; 
 return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}


function setCookie(cookieName,cookieValue) {
 document.cookie = cookieName+"="+escape(cookieValue)+ ";path=/";
 //alert(getcookie(cookieName));
}

function checkJukebox(){
	var valid=true;

	if(parent.document.getElementById('jukeboxFrame')){
		alert('Jukebox already open');
		valid = false;
	}
	else{
		//alert('no frame there is');
	}

return valid;

}


var cur_browser='uptodate';
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
		if(this.browser == 'Opera'){
			if(this.version < 9){
			cur_browser = 'old';			
			//alert(this.version + '=' + cur_browser);
			}
		}
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},		
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},		
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

function hide_overflowx(){
		var styleattri=document.createAttribute("class");
		styleattri.nodeValue="hide_overflow-x";
	    var htmlTags=document.getElementsByTagName('html');

	    for(var i=0;i<htmlTags.length;i++){
			htmlTags[i].setAttributeNode(styleattri);
		}
}

if(parent.document.getElementById('jukeboxFrame')){
		hide_overflowx();
}