//MCO - PPO 18092008
function newsecuritywindow(){
window.open('https://seal.verisign.com/splash?form_file=fdf/splash.fdf&dn=WWW.TELESCOPE.COM&lang=en','ppo','width=600,height=500,resizable=yes');
}
// end MCO - PPO



//JPA ADDED OMNITURE JS STRING STRIPPING UTILITY
	function omni_strip(val, shouldAlpha){
 		//match non-alpha-numerics and not the space
 		var myAlphaRegEx = new RegExp("[^A-Za-z0-9 ]","g");
 		var myCommaRegEx = new RegExp(",","g");
 		if(val != null){
 			//should I strip ALL non-aplha numeric
	 		if(shouldAlpha){
		 		return val.replace(myAlphaRegEx,"");
	 		} else {
	 			//ALWAYS strip commas at least
	 			return val.replace(myCommaRegEx,"");
	 		}
	 	} else {
	 		return val;
	 	}
 	}
//END STRIPPER


function closeStarDate(){
	document.getElementById('detail_popin').innerHTML = ' ';
	document.getElementById('detail_popin').style.display='none';
	document.getElementById('detail_popin_items').innerHTML = ' ';
	document.getElementById('detail_popin_items').style.display='none';
	document.getElementById('detail_popin_shim').style.display='none';
}


startList = function() {
	isloaded = true;
	var detect = navigator.userAgent.toLowerCase();
	var browser;
	if(detect.indexOf('opera')<0){
		if (document.all&&document.getElementById) {
			navRoot = document.getElementById("navul");
			if(navRoot != undefined){
				for (i=0; i<navRoot.childNodes.length; i++) {
					node = navRoot.childNodes[i];
					if (node.nodeName=="LI") {
						node.onmousemove=function() {
							if (this.className.indexOf("over") == -1) {
								this.className+=" over";
								//alert(this.className);
							}
						}
						node.onmouseout=function() {
							this.className=this.className.replace("over", "");
							//alert(this.className);
						}
					}
				}
			}
		}
	}
}
window.onload=startList;


var isAjax = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
	isAjax = new XMLHttpRequest();
} 
else if (window.ActiveXObject) { // IE
	try {
	    isAjax = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try {
	        isAjax = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e) {}
	}
}

function makeRequest(hurle, container, typ) {
	//affichage loading ////revoir INNERHTML
	document.getElementById(container).innerHTML = " ";	
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
		    if (typ == "XML") http_request.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) { // IE
		try {
		   http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		    try {
		        http_request = new ActiveXObject("Microsoft.XMLHTTP");
		    } catch (e) {}
		}
	}
	if (!http_request) {
		alert('Abandon :( Impossible de cr?er une instance XMLHTTP');
		return false;
	}
	http_request.onreadystatechange = function() {
	//alert("onreadystatechange(), http_request.readyState = " + http_request.readyState);
		if (http_request.readyState == 4) {
			//alert("http_request.readyState = " + http_request.readyState)
			if (typ == "XML"){
				parseContents(http_request, container);
				if(isIE){
					//alert("detect IE");
					document.getElementById("detail_popin_shim").style.height = document.getElementById(container).clientHeight+ "px";
				}
			}
			else {
				postContents(http_request, container);
				if(isIE){
					//alert("detect IE");
				document.getElementById("detail_popin_shim").style.height = document.getElementById(container).clientHeight+ "px";
				}
				
			}
		}
	}

	//alert(hurle);
	//alert(hurle.indexOf("?", 0));
	var variable = "";
	if (hurle.indexOf("?", 0) > -1){
		variable = "&dummy=" + new Date().getTime();
	}else{
		variable = "?dummy=" + new Date().getTime();
	}

	http_request.open('GET', hurle + variable, true);
	//alert(hurle);
	//alert(document.getElementById(container).clientHeight);
	http_request.send(null);	
}


function postContents(http_request, div) {
	if (http_request.status == 200) {
		document.getElementById(div).innerHTML = http_request.responseText;
		document.getElementById(div).style.display = "block";
		
		try{
			if(mErrorMessage != null){
				em = new String(unescape(mErrorMessage));
				em = em.replace(/\+/g," ");
				document.getElementById("with-or-without-errors").innerHTML = "<font color='red'>"+em+"</font>";
			}
			if(mAddToCartErrorMessage != null){
				em = new String(unescape(mAddToCartErrorMessage));
				em = em.replace(/\+/g," ");
				document.getElementById("with-or-without-errors").innerHTML = "<font color='red'>"+em+"</font>";
			}
		}catch(e){
			//IE error, we might want to do something in the future.
		}
	} 
	else {
		alert('A problem occurred with the request.');
	}
}
function displayPopin(cible, xOffset, yOffset){
	if(xOffset==undefined || xOffset==''){
		xOffset = 0;
	}	
	if(yOffset==undefined || yOffset==''){
		yOffset = 100;
	}
	
	if(cible==undefined || cible==''){
		cible = "detail_popin";
	}


	//position div
	var posX = 0;
	var posY = 0;

	if (cible.indexOf("wishlistPopin") > -1){
		posX = rel_mouse_x - 10;
		posY = mouse_y + 40;
	}/** FJA IMAG-011 Product specs hyperlinks - BEGIN */else if (cible.indexOf("specDefinition_") > -1){
		cptx = document.getElementById("productdetailtabs").offsetLeft+document.getElementById("productleftbar").width;
		cpty = document.getElementById("productdetailtabs").offsetTop;
		posX = 50;
		posY = rel_mouse_y - cpty -70;
	}else if (cible.indexOf("specDefCompare_") > -1){
		cptx = document.getElementById("doCompareDefinitionSpecBoundary").offsetLeft;
		cpty = document.getElementById("doCompareDefinitionSpecBoundary").offsetTop;
		posX = 50;
		posY = rel_mouse_y - cpty - 70;
	}/** FJA IMAG-011 Product specs hyperlinks - END*/
	/** FJA IMAG-033-MISC.3 BEGIN*/
	else if (cible.indexOf("infoDefinition_") > -1){
		cptx = document.getElementById("ecom-mainarea").offsetLeft;
		cpty = document.getElementById("ecom-mainarea").offsetTop;
		posX = rel_mouse_x - cptx - 200;
		posY = rel_mouse_y - cpty + 25;
	}/** FJA IMAG-033-MISC.3 END*/else{
		posX = rel_mouse_x - 300;
		posY = mouse_y - 130;
	}
	
	document.getElementById(cible).style.left = posX - xOffset + "px";
	document.getElementById(cible).style.top = (posY - yOffset) + "px";
	
	/** FJA IMAG-033-MISC.3 BEGIN*/
	if(this.lastDisplayedPopin != 'NULL'){
		document.getElementById(this.lastDisplayedPopin).style.display= 'none';
	}
	this.lastDisplayedPopin = cible;
	/** FJA IMAG-033-MISC.3 END*/
	
	// Affichage de la div detail 
	/** FJA DEBUG - (block moved) well displaying borders first time popin appears - BEGIN*/
	document.getElementById(cible).style.display = "block";
	/** FJA DEBUG - END */
	
	
	return false;
}

function detailPanel(hurle,cible, referenceDiv, xOffset, yOffset){
	/* action AJAX qui cr?? le contenu de la div "detail_produit" 
	en utilisant l'identifiant produit (ou toute variable qu'il semblerait utile d'utiliser */
	if(isAjax){
		if(yOffset==undefined || yOffset==''){	yOffset = 100;	}
		if(cible==undefined || cible==''){	cible = "detail_popin";	}
		// Affichage de la div detail 
		document.getElementById(cible).style.display = "block";
		//position div
		var posX = mouse_x - 50;
		var posY = mouse_y - 50;
		document.getElementById(cible).style.left = posX + "px";
		document.getElementById(cible).style.top = (posY - yOffset) + "px";
		if(isIE){	
			document.getElementById("detail_popin_shim").style.display="block";
			document.getElementById("detail_popin_shim").style.left = posX + "px";
			document.getElementById("detail_popin_shim").style.top = (posY - yOffset) + "px";
		}
		
		//appel AJAX
		makeRequest(hurle, cible);
		//to avoid the href call
		return false;
	}
	displayPopinAt(cible,referenceDiv,xOffset,yOffset);
}

function detailPanelItems(hurle,cible, xOffset, yOffset){
	/* action AJAX qui cr?? le contenu de la div "detail_produit" 
	en utilisant l'identifiant produit (ou toute variable qu'il semblerait utile d'utiliser */
	if(isAjax){
		if(yOffset==undefined || yOffset==''){
			yOffset = 100;
		}

		if(cible==undefined || cible==''){
			cible = "detail_popin_items";
		}
		// Affichage de la div detail 
		document.getElementById(cible).style.display = "block";
		//position div
		var posX = mouse_x;
		var posY = mouse_y;
		document.getElementById(cible).style.left = posX + "px";
		document.getElementById(cible).style.top = (posY - yOffset) + "px";
		if(isIE){
			//alert("detect IE");		
			document.getElementById("detail_popin_shim").style.display="block";
			document.getElementById("detail_popin_shim").style.left = posX + "px";
			document.getElementById("detail_popin_shim").style.top = (posY - yOffset) + "px";
		}
		
		//appel AJAX
		makeRequest(hurle, cible);
		displayPopinAt('detail_popin_items','product_summary',xOffset,yOffset);
		return false;
	}
}

var lastDisplayedPopin='NULL';

function displayPopinAt(cible, referenceDiv, xOffset, yOffset){
	if(xOffset==undefined || xOffset==''){xOffset = 0;}	
	if(yOffset==undefined || yOffset==''){yOffset = 0;}
	
	var posX = rel_mouse_x - xOffset;
	var posY = rel_mouse_y - yOffset;
	
	if(referenceDiv!=undefined && referenceDiv!=''){
		posX = posX - document.getElementById(referenceDiv).offsetLeft;
		posY = posY - document.getElementById(referenceDiv).offsetTop;
	}

	document.getElementById(cible).style.left = posX  + "px";
	document.getElementById(cible).style.top = posY  + "px";
	
	if(this.lastDisplayedPopin != 'NULL'){
		document.getElementById(this.lastDisplayedPopin).style.display= 'none';
	}
	this.lastDisplayedPopin = cible;
	document.getElementById(cible).style.display = "block";
	return false;
}
function displayPopinAtAbsolute(cible, referenceDiv, xOffset, yOffset){
	if(xOffset==undefined || xOffset==''){xOffset = 0;}	
	if(yOffset==undefined || yOffset==''){yOffset = 0;}
	
	var posX = xOffset;
	var posY = yOffset;
	
	if(referenceDiv!=undefined && referenceDiv!=''){
		posX = posX + document.getElementById(referenceDiv).offsetLeft;
		posY = posY + document.getElementById(referenceDiv).offsetTop;
	}

	document.getElementById(cible).style.left = posX  + "px";
	document.getElementById(cible).style.top = posY  + "px";
	
	if(this.lastDisplayedPopin != 'NULL'){
		document.getElementById(this.lastDisplayedPopin).style.display= 'none';
	}
	this.lastDisplayedPopin = cible;
	document.getElementById(cible).style.display = "block";
	return false;
}


function displayElement(elmt, disp){
	document.getElementById(elmt).style.display=disp;
}
	
//detection position souris
var mouse_x = 0;
var mouse_y = 0;
var scroll_x = 0;
var scroll_y = 0;
var rel_mouse_x = 0; //for centered page
var rel_mouse_y = 0; //for centered page
function positionSouris(evt){
    if( !evt ) evt = window.event;
    if (evt.pageX || evt.pageY){
		mouse_x = evt.pageX;
		mouse_y = evt.pageY;
	}
	else if (evt.clientX || evt.clientY) 	{
		
	    if(document.documentElement && document.documentElement.scrollTop) {
	    	scroll_x = document.documentElement.scrollLeft;
	    	scroll_y = document.documentElement.scrollTop;
	    }else if(document.body) {
			scroll_x = document.body.scrollLeft;
			scroll_y = document.body.scrollTop;
	    }
	    mouse_x = evt.clientX + scroll_x;
	    mouse_y = evt.clientY + scroll_y;
    } 
    if(document.getElementById('ecom-page')){
		rel_mouse_x = mouse_x - document.getElementById('ecom-page').offsetLeft;
		rel_mouse_y = mouse_y - document.getElementById('ecom-page').offsetTop;
    }
    //window.status = "Souris X:"+x+" / Y:"+y;
}
document.onmousemove = positionSouris;