// ProductDetailUtility.js
function askScientist(link){
	window.open(link,"AskAScientist",'resizable=yes,scrollbars=yes');
}

function internalProduct(link){
	window.open(link,"AskAScientist","height=500,width=780,scrollbars=yes,menubar=no,resizable=1,toolbar=no,status=no");
}

//layer1 if hidden make visible
//layer2 make hidden
//layer3 make visible
function toggleLayer(layer1,layer2,layer3 ){
	var layer1Obj = document.getElementById(layer1);
	var layer2Obj = document.getElementById(layer2);
	var layer3Obj = document.getElementById(layer3);
	
	if(layer1Obj.className == 'blockDiv'){
		layer1Obj.className = 'openDiv';
	}
	else{
		layer1Obj.className = 'blockDiv';
	}
	
	//layer2 hidden
	layer2Obj.className = 'blockDiv';
	
	//layer3 make visible
	layer3Obj.className = 'openDiv';
}


function nextTab(tabId_){
	//tabs
	var tabSpec = document.getElementById("specTab");
	var tabRel = document.getElementById("relProdTab");
	var tabRef = document.getElementById("refTab");
	var tabRev = document.getElementById("revTab");
	//div
	var tabSpecDiv = document.getElementById("Specifications");
	var tabRelDiv = document.getElementById("RelatedProducts");
	var tabRefDiv = document.getElementById("References");
	var tabRevDiv = document.getElementById("Reviews");
		
	if(tabId_ == "specTab"){
		tabSpec.className = "tabSelected";
		tabRel.className = "tabNotSelected";
		tabRef.className = "tabNotSelected";
		tabRev.className = "tabNotSelected";
		//divs
		tabSpecDiv.className = "openDiv";
		tabRelDiv.className = "blockDiv";
		tabRefDiv.className = "blockDiv";
		tabRevDiv.className = "blockDiv";
	}
	else if(tabId_ == "relProdTab"){
		tabRel.className = "tabSelected";
		tabSpec.className = "tabNotSelected";
		tabRef.className = "tabNotSelected";
		tabRev.className = "tabNotSelected";
		//divs
		tabSpecDiv.className = "blockDiv";
		tabRelDiv.className = "openDiv";
		tabRefDiv.className = "blockDiv";
		tabRevDiv.className = "blockDiv";
	}
	else if(tabId_ == "refTab"){
		tabRef.className = "tabSelected";
		tabRel.className = "tabNotSelected";
		tabSpec.className = "tabNotSelected";
		tabRev.className = "tabNotSelected";
		//divs
		tabSpecDiv.className = "blockDiv";
		tabRelDiv.className = "blockDiv";
		tabRefDiv.className = "openDiv";
		tabRevDiv.className = "blockDiv";
	}
	else if(tabId_ == "revTab"){
		tabRev.className = "tabSelected";
		tabRef.className = "tabNotSelected";
		tabRel.className = "tabNotSelected";
		tabSpec.className = "tabNotSelected";
		//divs
		tabSpecDiv.className = "blockDiv";
		tabRelDiv.className = "blockDiv";
		tabRevDiv.className = "openDiv";
		tabRefDiv.className = "blockDiv";
		cmTagAndLink('Reviews','Product Detail Page', null, null, null);
		location.href="#reviews";
	}
	
}

function closeErrorDialogBox(){
	
	cloneConfigErrorDialogBox = document.getElementById("confirmCloneConfigErrorDialog");
	controlConfigErrorDialogBox = document.getElementById("confirmControlConfigErrorDialog");
	if( cloneConfigErrorDialogBox!=null && cloneConfigErrorDialogBox.style.visibility=='visible'){
		closeConfigErrorViewer('confirmCloneConfigErrorDialog', displayManagerSHRNAClones);
	}
	if(controlConfigErrorDialogBox!=null && controlConfigErrorDialogBox.style.visibility=='visible'){
		closeConfigErrorViewer('confirmControlConfigErrorDialog', displayManagerSHRNAControls)
	}
}

function shRNANextTab(tabId_){
	//tabs
	var tabClones = document.getElementById("clonesTab");
	var tabControls = document.getElementById("controlsTab");
	var tabRel = document.getElementById("relProdTab");
	var tabRef = document.getElementById("refTab");
	//div
	var tabClonesDiv = document.getElementById("Clones");
	var tabControlsDiv = document.getElementById("Controls");
	var tabRelDiv = document.getElementById("RelatedProducts");
	var tabRefDiv = document.getElementById("References");
		
	if(tabId_ == "clonesTab"){
		tabClones.className = "tabSelected";
		tabControls.className = "tabNotSelected";
		tabRel.className = "tabNotSelected";
		if(tabRef != null){
			tabRef.className = "tabNotSelected";
		}
		//divs
		tabClonesDiv.className = "openDiv";
		tabControlsDiv.className = "blockDiv";
		tabRelDiv.className = "blockDiv";
		tabRefDiv.className = "blockDiv";
		
	}else if(tabId_ == "controlsTab"){
		tabControls.className = "tabSelected";
		tabRel.className = "tabNotSelected";
		tabClones.className = "tabNotSelected";
		if(tabRef != null){
			tabRef.className = "tabNotSelected";
		}
		//divs	
		tabClonesDiv.className = "blockDiv";
		tabControlsDiv.className = "openDiv";
		tabRelDiv.className = "blockDiv";
		tabRefDiv.className = "blockDiv";		
						
		if(document.getElementById("pricingLoaded").value == 0){
			loadShRNAControlsPA();		
		}
	}
	else if(tabId_ == "relProdTab"){
		tabRel.className = "tabSelected";
		tabClones.className = "tabNotSelected";
		tabControls.className = "tabNotSelected";
		if(tabRef != null){
			tabRef.className = "tabNotSelected";
		}
		//divs
		tabControlsDiv.className = "blockDiv";
		tabClonesDiv.className = "blockDiv";
		tabRelDiv.className = "openDiv";
		tabRefDiv.className = "blockDiv";
	}
	else if(tabId_ == "refTab"){
		if(tabRef != null){
			tabRef.className = "tabSelected";
		}
		tabRel.className = "tabNotSelected";
		tabClones.className = "tabNotSelected";
		tabControls.className = "tabNotSelected";
		//divs
		tabClonesDiv.className = "blockDiv";
		tabControlsDiv.className = "blockDiv";
		tabRelDiv.className = "blockDiv";
		tabRefDiv.className = "openDiv";
	}
	currentFocusedTabId = tabId_;
}

var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
 	return{
	show:function(v,w){
		if(tt == null){
			tt = document.createElement('div');
			tt.setAttribute('id',id);
			t = document.createElement('div');
			t.setAttribute('id',id + 'top');
			c = document.createElement('div');
			c.setAttribute('id',id + 'cont');
			b = document.createElement('div');
			b.setAttribute('id',id + 'bot');
			tt.appendChild(t);
			tt.appendChild(c);
			tt.appendChild(b);
			document.body.appendChild(tt);
			tt.style.opacity = 1;
			tt.style.filter = 'alpha(opacity=100)';
			document.onmousemove = this.pos;
		}
	tt.style.display = 'block';
	c.innerHTML = v;
	tt.style.width = w ? w + 'px' : 'auto';
	if(!w && ie){
		t.style.display = 'none';
		b.style.display = 'none';
		tt.style.width = tt.offsetWidth;
		t.style.display = 'block';
		b.style.display = 'block';
	}
	if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
	h = parseInt(tt.offsetHeight) + top;
	clearInterval(tt.timer);
	tt.timer = setInterval(function(){tooltip.fade(1)},timer);
	},
	pos:function(e){
	
	// For IE6 compatibity - nick 22/08/2008 11:32
		var u = 0, l = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
			u = window.pageYOffset;
			l = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
			u = document.body.scrollTop;
			l = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
			u = document.documentElement.scrollTop;
			l = document.documentElement.scrollLeft;
		} 
		
		u = ie ? event.clientY + u : e.pageY;
		l = ie ? event.clientX + l : e.pageX;
		tt.style.top = (u - h) + 'px';
		tt.style.left = (l + left) + 'px';
	
	},
	fade:function(d){
		var a = alpha;
		if((a != endalpha && d == 1) || (a != 0 && d == -1)){
			var i = speed;
			if(endalpha - a < speed && d == 1){
				i = endalpha - a;
			}else if(alpha < speed && d == -1){
				i = a;
			}
			alpha = a + (i * d);
			tt.style.opacity = alpha * .01;
			tt.style.filter = 'alpha(opacity=' + alpha + ')';
		}else{
			clearInterval(tt.timer);
			if(d == -1){tt.style.display = 'none'}
		}
	},
	hide:function(){
		clearInterval(tt.timer);
		tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
	}
};
}();


