﻿function trackAndGo(page, country) {
	$.ajax({
		type: "GET",
		url: "trackContact.asp?nom="+page,
		success: function(msg){
			eval(msg);
			if (country != null) {
				window.location.href = page + "?country=" + country;
			}
			else {
				window.location.href = page;
			}
		},
		error: function(msg){}	
	});
}

function go_to_country(where) {
	window.location.href = where;
}

function show(zone)
{
	
	var objDivStyle = document.getElementById(zone).style
	objDivStyle.display = "block";
}

function hide(zone)
{
	var objDivStyle = document.getElementById(zone).style;
	objDivStyle.display = "none";
}
function changeImage(ancienneImage,nouvelleImage)
{
	var objImage = document.getElementById(ancienneImage);
	objImage.src= "../images/" + nouvelleImage;
}
function show_country(zone,titre){
	/*var objImage = document.getElementById('titreZone');
	objImage.src= "../images/"+ titre;*/
	document.getElementById("form_map").style.display = "none";
	var objTitre = document.getElementById('titreZone');
	objTitre.innerHTML=titre

	document.getElementById(zone).style.display = "block";
	var objDivStyle = document.getElementById('map').style
	objDivStyle.display = "none";
	
	document.getElementById('preview').style.visibility = "visible";
}
function hide_country(zone){
	document.getElementById(zone).style.display = "none";
	var objDivStyle = document.getElementById('map').style
	objDivStyle.display = "block";
	
	/*var objImage = document.getElementById('titreZone');
	objImage.src= "../images/titre_Worldwide.gif";*/
	
}

function Validation(champ) 
{
	var pass=true;
	if (document.images) 
	{
		for (i=0;i<champ.length;i++) 
		{
			var tempobj=champ.elements[i];
			if (tempobj.name.substring(0,3)=="obl") 
			{
				if (((tempobj.type=="text"||tempobj.type=="textarea")&&
				tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
				tempobj.selectedIndex==0)) 
				{
					pass=false;
					break;
				}
			}
		}
	}
	if (!pass) 
	{
		champnom=tempobj.name.substring(3,30).toUpperCase();
		alert("Veuillez saisir une valeur pour le champ : "+ champnom +".");
		tempobj.focus();
		return false;
	}
	else
	return true;
}


function Imprimer() {window.print();}

function OuvrirFenetre(NomFenetre,fichier, param)
{
	window.open(fichier, NomFenetre, param);
	return;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function get_mouse(e)
{
	y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.clientY+document.body.scrollTop;
	x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.clientX+document.body.scrollLeft;
}
	
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 switchImage(imgName, imgSrc) 
{
	if (document.images)
	{
		if (imgSrc != "none")
		{
			document.images[imgName].src = imgSrc;
		}
	}
}

function version4() 
{
	if(navigator.appVersion.charAt(0) >= 4) 
	{
		return true;
	}
	return false
}
	
function setupBrowser(){
	if(!version4()) return
		divStyle = new Array
	divStyle[1] = document.getElementById("Reponse1").style;
	divStyle[2] = document.getElementById("Reponse2").style;
	divStyle[3] = document.getElementById("Reponse3").style;
	divStyle[4] = document.getElementById("Reponse4").style;
	divStyle[5] = document.getElementById("Reponse5").style;
 }
	
function displayDivision(i, left, yoffset, id) 
{
	if(!version4() || !window.divStyle) return
	divStyle[i].top = 113 + yoffset;
	divStyle[i].left = document.getElementById("bandeau").offsetParent.offsetLeft + left;
	divStyle[i].visibility = "visible"
	if ( currentdiv != -1 && currentdiv != i ) { hideDivision( currentdiv ); }
	currentdiv=i;
}
	//.offsetParent.offsetLeft - 4;
function hideDivision(i) 
{
 if(!version4() || !window.divStyle) return
 divStyle[i].visibility = "hidden"
 
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}



var idTimer = "";
var idTimer2 = "";

$(document).ready(function(){
	/*sous menu*/
	/*
	$(".lienmenu").mouseover(function(){
		$(".lienmenu ul").hide();
		$(this).children("ul:eq(0)").show();
        clearTimeout(idTimer);
	});
	$(".lienmenu").mouseout(function(){
		idTimer = setTimeout("$('#" + $(this).children("ul:eq(0)").attr("id") + "').hide();", 200);
	});
	*/
	$(".lienmenu").mouseover(function(){
		$(".lienmenu ul[class!='dl_ssmenu'][class!='dl_ssmenu2']").hide();
		$(this).children("ul:eq(0)").show();
        clearTimeout(idTimer);
	});
	$(".lienmenu").mouseout(function(){
		idTimer = setTimeout("$('#" + $(this).children("ul:eq(0)").attr("id") + "').hide();", 200);
	});

	$("#ssLibrary li").hover(
	  function () {
		$(this).children("ul").show();	
	  }, 
	  function () {
		$(this).children("ul").hide();
	  }
	);	
	
	/*selection drapeaux en fonction du nom de domaine*/
	var selectedId = "flag_us";
	var mon_domaine = location.host;
    switch(mon_domaine)
    {
        case "www.fischerconnectors.co.uk":
          selectedId = "flag_uk";
          break;
        case "www.fischerconnectors.fr":
          selectedId = "flag_fr";
          break;
        case "www.fischerconnectors.ch":
          selectedId = "flag_ch";
          break;
        case "www.fischerconnectors.it":
          selectedId = "flag_it";
          break;
        case "www.fischerconnectors.de":
          selectedId = "flag_de";
          break;
    }
    $("#"+ selectedId +"").show();

});


function showLangs(e) {
	$('#changeLang').show();
	clearTimeout(idTimer2);
}
function hideLangs() {
	idTimer2 = setTimeout("$('#changeLang').hide();", 200);
}

// JavaScript Document
// Auteur : Mazeberry
// Version : 1

function creer_cookie (name, value, days)
{
	var expires;
		if (days) {
			var date = new Date();
			date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
			expires = "; expires=" + date.toGMTString();
		}
		else {
			expires = "";
		}
		document.cookie = name + "=" + value + expires + "; path=/" + "; domain=" +window.location.href.toLowerCase().split(/\/+/g)[1];;
}

function lire_cookie (n)
{
	var nameEQ = n + "=";
	var ca = document.cookie.split(';');
	for (var i = 0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0)===' ') {
			c = c.substring(1, c.length);
		}
		if (c.indexOf(nameEQ)===0) {
			return c.substring(nameEQ.length, c.length);
		}
	}
	return null;
}

function ga_track_pdf(destination_url)
{
	try {
	// lire cookie cpt_pdf
	var cpt_pdf = lire_cookie ('cpt_pdf');
	if(cpt_pdf===null)
	{
		// Initialiser cookie
		creer_cookie ('cpt_pdf', '1', '');
	}
	else
	{
		cpt_pdf = parseInt(cpt_pdf) + 1;
		creer_cookie ('cpt_pdf', cpt_pdf, '');
	}
	
	if(cpt_pdf==3)
	{
		pageTracker._trackPageview('goal/session-catalog-3/');
	}
	
	pageTracker._trackPageview(destination_url);
	} catch(err) {}
}

function doNothing(){}
