/* 2004-2005 Kahiloa Solutions et Communication */
/* Nikon Europe Project */
/* SCRIPT GLOBAL DU SITE NIKON EUROPE */

var theme = "light";

//Test du navigator
var gCursor = null;
if(navigator.appName=='Microsoft Internet Explorer')	gCursor = 'hand';
else	gCursor = 'pointer';

// Navigator informations
var n = navigator;
var d = document;
var agent = n.userAgent.toLowerCase();
var name = n.appName.toLowerCase();
var opera = agent.indexOf("opera") != -1;

// Lib Versions
var Versions = {
	Prototype: '1.5.0',
	Scriptaculous: '1.6.5',
	nw: '1.0'		
};

//Browser sniff hash obj
var sniff = {
	bw: {
	ie:agent.indexOf("msie") != -1 && !opera,
	ie4:agent.indexOf("msie 4.") != -1 && !opera,
	ie5:agent.indexOf("msie 5.") != -1 && !opera,
	ie6:agent.indexOf("msie 6.") != -1 && !opera,
	ns:name.indexOf("netscape") != -1 && agent.indexOf("gecko") == -1,
	ns6:agent.indexOf("netscape6") != -1
	},
	os: {
	win:n.userAgent.indexOf("Win") != -1,
	mac:n.userAgent.indexOf("Mac") != -1
	}
};

// Utilitaire DOM
if (document.getElementById) {
  window.GetObject = function(id) {
    return document.getElementById(id);
  }
} else if (document.all) {
  window.GetObject = function(id) {
    return document.all[id]
  }
} else {
  window.GetObject = function(id) {
    return false;
  }
}

/*
 * displPopup()
 * @param {String} href
 * @param {String} mode : compact | full screen | normal
 * @param {Integer} width
 * @param {Integer} height
 */
function displayPopup(href, mode, width, height) {										
	if(width <= 0 && height <= 0) {		
		width = 800;
		height = 600;
	}			
	var left = Math.round((screen.availWidth-width)/2);
	var top = Math.round((screen.availHeight-height)/2);	
	switch(mode) {
	 	case "compact" :	
			var popup = window.open(href, "", "scrollbars=auto,menubar=0,resizable=0,location=0,directories=0,status=0,toolbar=0,menubar=0,top="+top+",left="+left+",width="+width+",height="+height);	 					
	 	break;
	 	case "full screen": 
			left = 0;
			top = 0;
			width = screen.availWidth;
			height = screen.availHeight;
			var popup = window.open(href, "", "scrollbars=auto,menubar=0,resizable=0,location=0,directories=0,status=0,toolbar=0,top="+top+",left="+left+",width="+width+",height="+height);
	 	break;
		default:
			var popup = window.open(href, "", "scrollbars=auto,menubar=1,resizable=1,location=1,status=1,toolbar=1,top="+top+",left="+left+",width="+width+",height="+height);
		break; 
 	}			
	//alert(popup.document.getElementsByTagName("body")[0]);			
	return false;
}

/*
 * displayMinisite()
 * @param {String} href
 * @param {Integer} width
 * @param {Integer} height
 * @param {String} color : default | light | dark
 * @param {String} type : flash | iframe | img
 * @param {String} base
 */
function displayMinisite(href, width, height, color, type, base,calledByFlash) {
	
	var _fixedTop = 10;
	
	var _overlay, _container, _topbar, _close, _target, _content;
	// pagesize = [0: pageW, 1: pageH, 2: winW, 3: winH]	
	var psize = getPageSize();
	var pscroll = getPageScroll();			
	var top =(psize[3]/2) - (height/2) + pscroll[1];
	var left =(psize[2]/2) - (width/2);
	
	if(color == "default") color = theme;
			
	// contruct overlay
	_overlay = document.createElement('div');
	_overlay.id = "MnsOverlay";
	_overlay.className = 'mns_overlay';
	_overlay.style.display = 'block';
	_overlay.style.position = 'absolute';
	_overlay.style.zIndex = 100;	
	_overlay.style.top = 0+'px';
	_overlay.style.left = 0+'px';	
	_overlay.style.width = '100%';	
	_overlay.style.height = psize[1]+'px';
		
	switch(color) {
		case "dark" :
			_overlay.style.backgroundColor = '#000000';			
		break
		default : 
			_overlay.style.backgroundColor = '#FFFFFF';			
		break;
	}	
		
	// construct top bar
	_topbar = document.createElement('div');
	_topbar.className = "mns_top";			
	
	var _close = document.createElement('img');
	_close.style.cursor = "pointer";	
	_close.src = '/site/_common/images/global/btn_close_mns.gif';  				
	_close.style.paddingBottom = '2px';
	_close.style.width = '16px';
	_close.style.height = '16px';
	
	// construct view container
	_container = document.createElement('div');
	_container.id = "MnsContainer";		
	_container.className = 'mns_viewer';	
	_container.style.display = 'block';			
	_container.style.position = 'absolute';
	_container.style.zIndex = 2000;
	_container.style.top = _fixedTop+'px';
	//_container.style.top = top+'px';
	_container.style.left = left+'px';		
	_container.style.width = width+'px';
	_container.style.height = (Number(height)+20)+'px';	
	
	// contruct view content target
	_target = document.createElement('div');
	_target.style.clear = 'both';
	_target.id = "MnsTarget";
	_target.className = "mns_target_" + color;
	
	// append in DOM
	document.getElementsByTagName('body')[0].appendChild(_overlay);		
	// hide billboard, leftcol and rightcol
	if(document.getElementById("div_corporate_billboard"))		
		document.getElementById("div_corporate_billboard").style.visibility = 'hidden';
	if(document.getElementById("div_leftcol"))
		document.getElementById("div_leftcol").style.visibility = 'hidden';
	if(document.getElementById("div_rightcol"))
		document.getElementById("div_rightcol").style.visibility = 'hidden';	
				
	document.getElementsByTagName('body')[0].appendChild(_container);
	_container.appendChild(_topbar);
		_topbar.appendChild(_close);		
	_container.appendChild(_target);
	
	// scroll top the top	
	window.scroll(0,0);
	
	// Event Listenner for close button
	if(!sniff.bw.ie) {
		_close.addEventListener('click',closeMinisite,false);	
	}
	else {
		_close.attachEvent('onclick',closeMinisite);
	}
	
	// construct content to insert in target
	switch(type) {
		case "img" :
			var _content = '<img src="'+href+'" alt="" />';			
		break;
		case "flash" :						
			var _content = BuiltFlash(href, width, height, true, base);	
			//alert(_content);					
		break;
		case "iframe" : 
			var _content = '<iframe src="'+href+'" marginwidth="0" marginheight="0" frameborder="0" height="'+height+'" width="'+width+'"></iframe>';
		break;		
	}	
	// insert content in target		
	_target.innerHTML = _content;			
	if (!calledByFlash) {
		return false;
	}
}

/*
 * Close a minisite layer
 */
function closeMinisite() {	
	var _overlay = document.getElementById("MnsOverlay");		
	var _container = document.getElementById("MnsContainer");
	if(document.getElementById("div_corporate_billboard"))
		document.getElementById("div_corporate_billboard").style.visibility = '';
	if(document.getElementById("div_leftcol"))
		document.getElementById("div_leftcol").style.visibility = '';
	if(document.getElementById("div_rightcol"))
		document.getElementById("div_rightcol").style.visibility = '';	
	document.getElementsByTagName('body')[0].removeChild(_container);
	document.getElementsByTagName('body')[0].removeChild(_overlay);	
}

function showDeeplink(link) { return; }


// Permet de faire apparaitre et disparaitre un div
// @bool (optionnel)
function onOff(id, bool){
	var element = $(id);
    if(element){
        if(bool==null) {
            element.style.display = (element.style.display=='') ? 'none' : '';
        }
        else {
            if(bool==true) {
                element.style.display = '';
            }
            else {
                element.style.display = 'none';
            }
        }
    }
}

/* 
 * Affichage d'une animation flash avec focus direct (IE, Opera, Firefox) 
 */
function InsertFlash(data, width, height, transparent, base, htmlClass){
    n_width = Number(width);
	n_height = Number(height);
	if(n_width > 0 && n_height > 0) {
		var swf = BuiltFlash(data, n_width, n_height, transparent, base, htmlClass);	
		document.write(swf);
	}
    return;
}

function BuiltFlash(data, width, height, transparent, base, htmlClass) {
	var swf = '<object'+
              ' type="application/x-shockwave-flash" data="'+data+
              '" width="'+width+
              '" height="'+height+'"';
  if (htmlClass != null) {
  	swf+=' class="'+htmlClass+'"';
  }
  swf+='>\n';
  swf += '<param name="movie" value="'+data+'" />\n';	
	if(transparent==true) 
		swf += '<param name="wmode" value="transparent" />\n';
	if(base != '')	
		swf += '<param name="base" value="'+base+'">\n';		
        swf += '<embed src="'+data+'" pluginspage="http://www.macromedia.com/go/getflashplayer';
	if(base != '')	
		swf += '" base="'+base;              
		swf += '" width="'+width+
               '" height="'+height+
               '" type="application/x-shockwave-flash">'+
               '</embed>\n';
        swf += '</object>\n';
				
		return swf;
}

// Implements InsertDynamicAppletControl() function. This is a generic function used to generate
// applet tags. It is used by higher level api functions.		
function InsertDynamicAppletControl() {  
  // Initialize variables
  var currArg = '';
  var closer = '>';
  var srcFound = false;
  var embedStr = '<applet';
  var paramStr = '';
  
  embedStr += ' codebase="/" ';
  // Spin through all the argument pairs, assigning attributes and values to the object,
  // param, and embed tags as appropriate.
  for (var i=0; i < arguments.length; i=i+2) {
   currArg = arguments[i].toLowerCase();    
	
	if (currArg == "movie") {
        paramStr += '<param name="' + arguments[i] + '" value="' + arguments[i+1] + '"' + closer + '\n';
        srcFound = true;
    }
    else if (currArg == "width" || currArg == "height" || currArg == "code" || currArg == "archive" || currArg == "align" || currArg == "vspace" || currArg == "hspace" || currArg == "class" || currArg == "title" || currArg == "accesskey" || currArg == "tabindex")
    {
      embedStr += ' ' + arguments[i] + '="' + arguments[i+1] + '"';
    }
    // This is an attribute we don't know about. Assume that we should add it to the 
    // param and embed strings.
    else {
      paramStr += '<param name="' + arguments[i] + '" value="' + arguments[i+1] + '"' + closer + '\n'; 
    }
  }
  // Tell the user that a src is required, if one was not passed in.
  if (!srcFound){
    alert("The requires that a movie be passed in as one of the arguments.");
    return;
  }
  // Close off the object and embed strings
  embedStr += ' MAYSCRIPT>' + paramStr + '</applet>\n'; 
  return embedStr;
}


/* Récupération de la hauteur d'un div */
function getHeightDivById(pId){
	var vDivHeight = 0;
	vDivHeight=(sniff.bw.ns)?d[pId].clip.height:sniff.bw.ie?d.all[pId].offsetHeight:d.getElementById(pId).offsetHeight;
	return vDivHeight;
}

/* Affectation de la hauteur d'un div */
function setHeightDivById(pId, pHeight){	
	var vStyle=(sniff.bw.ns)?d[pId]:sniff.bw.ie?d.all[pId].style:d.getElementById(pId).style;
	if(pHeight>0)	vStyle.height = pHeight+'px';
}

/* FONCTIONS POUR LE ROLL OVER DES IMAGES */
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];}
}

/* 
 * Roll over global.
 */
function RollOverImages(prefixID, suffix_on, suffix_off) {	
	if(prefixID=='') { prefixID = "nbv_image_";}
	if(suffix_on=='') { suffix_on = "on" }
	if(suffix_off=='') { suffix_on = "off" }	
	var vNumTerr = 1;
	var vImObj	= document.getElementById(prefixID+vNumTerr);
	//Gestionnaire d'evenements sur les images de la navigation
	while(vImObj!=null){
		if(vImObj.style.cursor!=null)	vImObj.style.cursor = gCursor;
        //alert("img_nav_"+vNumTerr);
		MM_preloadImages(vImObj.src.replace(suffix_off, suffix_on));
		vImObj.onmouseover = function(){
			if(typeof(MM_swapImage)!='undefined')
				MM_swapImage(this.id,'',this.src.replace(suffix_off, suffix_on),1);
		}
		vImObj.onmouseout = function(){
			if(typeof(MM_swapImgRestore)!='undefined')		
				MM_swapImgRestore();	
		}
		vNumTerr++;
		vImObj	= document.getElementById(prefixID+vNumTerr);
	}	
}

/* FONCTION INITIALISATION DES IMAGES DE LA NAV */
function __initImgAvantAffichage(){
	var vNumTerr = 1;
	var vImObj	= document.getElementById('img_nav_'+vNumTerr);
	//Gestionnaire d'evenements sur les images de la navigation
	while(vImObj!=null){
		if(vImObj.style.cursor!=null)		vImObj.style.cursor = gCursor;
        //alert("img_nav_"+vNumTerr);
		MM_preloadImages(vImObj.src.replace('off', 'on'));
		vImObj.onmouseover = function(){
			if(typeof(MM_swapImage)!='undefined')	MM_swapImage(this.id,'',this.src.replace('off', 'on'),1);
		}
		vImObj.onmouseout = function(){
			if(typeof(MM_swapImgRestore)!='undefined')		MM_swapImgRestore();	
		}
		vNumTerr++;
		vImObj	= document.getElementById('img_nav_'+vNumTerr);
	}
}

/* Open Window */
//Ouverture d'une window
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/*
 * Function:  getPageSize
 * Returns:  array with page width, height and window width, height [pw, ph, ww, wh]
 */
function getPageSize(){	
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight); 
	return arrayPageSize;
}

/*
 * Function: getPageScroll
 * Returns: array with x,y page scroll values.
 */
function getPageScroll(){
	var xScroll;
	var yScroll;
	
	if (self.pageXOffset) {		
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollLeft){	 // Explorer 6 Strict
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		xScroll = document.body.scrollLeft;
	}
	
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	
	arrayPageScroll = new Array(xScroll,yScroll);
	return arrayPageScroll;
}

/* Fonction initialisation du rollover de la navigation niveau 2 et 3 */
function __initNavAvantAffichage(pNumNav){
	
    var vNumRub = 1;
	var vObjNameHref = "";
	var vObjNameImgLeft = "";
	var vObjNameImgRight = "";
	var vObjNameDiv = "";
	var vClassName = "";
	var vClassNameSelected = "";
	var vImgBrd = "";
	var vTabContentId = new Array();
	vTabContentId['div'] = new Array();
	vTabContentId['imgleft'] = new Array();
	vTabContentId['imgright'] = new Array();
	vTabContentId['imgstatus'] = new Array();
	
	switch(pNumNav){
		case "2": 
			vObjNameHref = "div_action_stitle"; 
			vObjNameImgLeft = "img_stitle_left";
			vObjNameImgRight = "img_stitle_right";
			vObjNameDiv = "div_stit";
			
			//alert(gPageCode);
            
            vClassName = "div_nav02_tit";
            vClassNameSelected = "div_nav02_tit_selected"
            
			switch(gPageCode) {
				case "products":
					vImgBrd = "brd_nav2_on";
					break;
				case "wheretobuy": 
					vImgBrd = "brd_nav3_on";
					break;
				case "support":
					vImgBrd = "brd_nav4_on";
					break;
				case "pressroom":
					vImgBrd = "brd_nav5_on";
					break;
				case "local_services":
					vImgBrd = "brd_nav6_on";
					break;
				case "nps":
					vImgBrd = "brd_nav7_on";
					break;
				default: 
					vImgBrd = "brd_nav2_on";
					break;				
			}
			
			
		break;
		case "3": 
			vObjNameHref = "div_action_stitle2_"; 
			vObjNameImgLeft = "img_stitle_left2_";
			vObjNameImgRight = "img_stitle_right2_";
			vObjNameDiv = "div_stit2_";
			vClassName = "div_nav02_tit";
			vClassNameSelected = "div_nav02_tit_selected";
			vImgBrd = "brd_nav2_on";
		break;
	}
	var vObjA = document.getElementById(vObjNameHref+vNumRub);
	
	while(vObjA!=null){
		var vObjImgLeft = document.getElementById(vObjNameImgLeft+vNumRub);
		var vObjImgRight = document.getElementById(vObjNameImgRight+vNumRub);
		//var vObjImgStatus = document.getElementById('img_stitle_status'+vNumRub);
		var vObjDiv = document.getElementById(vObjNameDiv+vNumRub);
		
		if(vObjA.className != "nav_disable"){ 
			vObjA.style.cursor = gCursor;			
			/* text decoration none */
			vObjA.style.textDecoration = 'none';
			
			if(vObjDiv!=null){
			
        /*alert(vObjDiv.className + " :: " + vClassName);*/
				// Test sur les titres de niveau 2 non sélectionnées 
				if(vObjDiv.className==vClassName){
				
					vTabContentId['div'][vObjA.id] = vObjDiv.id;
					vTabContentId['imgleft'][vObjA.id] = vObjImgLeft.id;
					vTabContentId['imgright'][vObjA.id] = vObjImgRight.id;
					//alert(vObjImgLeft.id + " " + vObjDiv.id + " " + vObjImgRight.id );
					//vTabContentId['imgstatus'][vObjA.id] = vObjImgStatus.id;
					//mouse over event
					vObjA.onmouseover = function(){
						vId = vTabContentId['div'][this.id];
						document.getElementById(vId).className = vClassNameSelected;
						//vId = vTabContentId['imgstatus'][this.id];
						//document.getElementById(vId).src = document.getElementById(vId).src.replace('_off', '_on');
						vId = vTabContentId['imgleft'][this.id];
						document.getElementById(vId).src =  document.getElementById(vId).src.replace('spacer', vImgBrd);
						vId = vTabContentId['imgright'][this.id];
						document.getElementById(vId).src =  document.getElementById(vId).src.replace('spacer', vImgBrd);
					}
					//mouse out event
					vObjA.onmouseout = function(){
						vId = vTabContentId['div'][this.id];
						document.getElementById(vId).className = vClassName;
						//vId = vTabContentId['imgstatus'][this.id];
						//document.getElementById(vId).src =  document.getElementById(vId).src.replace('_on', '_off');
						vId = vTabContentId['imgleft'][this.id];
						document.getElementById(vId).src = document.getElementById(vId).src.replace(vImgBrd, 'spacer');
						vId = vTabContentId['imgright'][this.id];
						document.getElementById(vId).src = document.getElementById(vId).src.replace(vImgBrd, 'spacer');
					}
					
				}
			}
		} else {
			vObjDiv.className = vObjDiv.className + " nav_disable"
			vObjA.style.cursor = "default";	
		}
		vNumRub++;
		//alert(vObjNameHref+vNumRub);
		vObjA = document.getElementById(vObjNameHref+vNumRub);
		//alert(vObjA);
		if(vObjA == null){
			vNumRub++;
			vObjA = document.getElementById(vObjNameHref+vNumRub);
		}
		//alert(vObjA);
	}
}

/* Redimensionnement du fond de la colonne de la navigation 3e niveau */
function resizeBgkLeftMenu(pLeftColValue){
	var vId = 'div_greyleftmiddle';
	var vObj = document.getElementById(vId);
	var vObjLeft = document.getElementById('div_leftcol');
	var vObjRight = document.getElementById('div_rightcol');
	if(vObjLeft!=null && vObjRight!=null){
		var vLeftHeightDiv = getHeightDivById('div_leftcol');
		var vRightHeightDiv = getHeightDivById('div_rightcol');
		var vDiff = 0;		
		if(pLeftColValue !=null && pLeftColValue>0) 	
			vDiff = vRightHeightDiv-pLeftColValue;
		else 	
			vDiff = vRightHeightDiv-vLeftHeightDiv;		
		//Test navigator
		//if(sniff.bw.ie) vDiff=vDiff+12;
		//else vDiff=vDiff+12;
		if(vDiff > 0 && vObj!=null){ 
			setHeightDivById(vId, vDiff+12);
		}
	}
}

function resizeIframe(height) {
	var iframe = document.getElementsByTagName('iframe')[0];
	iframe.height = height; 	
}

/* Redirige vers l'url passé en paramètre */
/*function goTo(pUrl){
	window.location = pUrl;
}*/

/* Permet de récupérer la valeur d'un paramètre dans l'url */
/* pKey : clé dans l'url */
/*function getValueByUrlKey(pKey){
	var url = window.location.href;
	var exp_reg = '('+pKey+'=)(.+)(&)(.+)';
	var reg = new RegExp(exp_reg);
	if(!reg.test(url)) { exp_reg = '('+pKey+'=)(.+)(&)((.+)?)'; 	reg = new RegExp(exp_reg);}
	if(!reg.test(url)) { exp_reg = '('+pKey+'=)(.+)(#.+)'; 	reg = new RegExp(exp_reg);}
	if(!reg.test(url)) {exp_reg = '('+pKey+'=)(.+)'; 	reg = new RegExp(exp_reg);}
	if(reg.test(url)){
		reg.exec(url);
		return RegExp.$2;
	}
}*/

/*Recupération de l'url avec le type*/
/*function getTypeUrl(pType){
	var vUrl = window.location.href;
	var vUrlType = '';
	var vKey = 'page';
	exp_reg = '(.+)((#[a-z])?)([?]?)('+vKey+'=)([a-z0-9]+)';
	reg = new RegExp(exp_reg);
	if(reg.test(vUrl)){
		vUrlType = RegExp.$1+vKey+'='+pType;
	}else{
		exp_reg = '(.+)(#.+)';
		reg = new RegExp(exp_reg);
		if(reg.test(vUrl)) {
			if(vUrl.indexOf('?')>-1) vUrlType = RegExp.$1+'&'+vKey+'='+pType;
			else	vUrlType = vUrlType = RegExp.$1+'?'+vKey+'='+pType;
		}
		else{
			if(vUrl.indexOf('?')>-1) vUrlType = vUrl+'&'+vKey+'='+pType;
			else	vUrlType = vUrl+'?'+vKey+'='+pType;
		}
	}
	return vUrlType;
}*/

/* Redirection vers une des pages produit */
/*function goToProduct(pType){
	var vUrl = '';
	vUrl = getTypeUrl(pType);
	if(vUrl!='') goTo(vUrl);
}*/

/*
 * Dynamic billboard handling
 */	
 
function getParameter( name ) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "";
	else
		return results[1];
}

function getBandwidth(){
	var bandwidth = lit_cook("nikon_billboard");
	if (bandwidth != "narrow" && bandwidth != "broad") {
			// Cookie not set correctly
		// First, check the bandwidth parameter
		bandwidth = getParameter("bandwidth");
		if (bandwidth == "") {
			// then, fallback to url parsing
			var href = document.location.href;
			if (href.indexOf("/narrow/") != -1) {
				bandwidth = "narrow";
			} else {
				// default bandwidth is broad
				bandwidth = "broad";
			}
		}
		// store the result as a cookie
		cre_cook0("nikon_billboard", bandwidth, getDefaultExpirationDate() ,"/"); //creation du cookie		
	}
	return bandwidth;
}

function displayFlashBillboard(div,billboard) {
	var billboardHTML = "";
	billboardHTML ='<object type="application/x-shockwave-flash" height="'+billboard.height+'" width="'+billboard.width+'" data="'+billboard.imageUrl+'">\n';
	billboardHTML+='<param name="movie" value="'+billboard.imageUrl+'"> </param>\n';
	if (billboard.base != undefined) {
		billboardHTML+='<param name="base" value="'+billboard.baseUrl+'"> </param>\n';
	}
	if (billboard.transparency == "true") {
		billboardHTML+='<param name="wmode" value="transparent"> </param>\n';
	}
	billboardHTML+='<embed src="'+billboard.imageUrl+'"'
							 + ' pluginspage="http://www.macromedia.com/go/getflashplayer"';
	if (billboard.base != undefined) {
		billboardHTML+=' base="'+billboard.baseUrl+'"';
	}
	billboardHTML+=' type="application/x-shockwave-flash" height="'+billboard.height+'"'
							 + ' width="'+billboard.width+'"';
	if (billboard.transparency == "true") {
		billboardHTML+=' wmode="transparent"';
	}
	billboardHTML+='>\n';
	billboardHTML+='</embed>\n';
	
	billboardHTML+='</object>';
	
	div.innerHTML=billboardHTML;
}

function displayImageBillboard(div,billboard) {
	div.innerHTML = "<img src=" + billboard.imageUrl + ">";
}

function isFlashImage(src) {
	return src.indexOf(".swf") > -1;
}

function handleBillboard(billboard){
	var billboard = eval("(" + billboard + ")");
	var div = document.getElementById("div_corporate_billboard");
	if (getBandwidth() == "broad" && billboard.type != "none") 
	{
		div.style.marginTop="14px";
		// display billboard
		if ((billboard.type) == "flash") {
			displayFlashBillboard(div,billboard);	
		} else if ((billboard.type) == "image") {
			displayImageBillboard(div,billboard);
		} else if (billboard.type == "internal") {
			if (isFlashImage(billboard.imageUrl)) {
				displayFlashBillboard(div,billboard);
			} else {
				displayImageBillboard(div,billboard);
			}
		}
	} else {
		// narrowband or empty billboard
		div.style.marginTop="0px";
		div.innerHTML = "";
	}
}

// Function DateExpiration
// fixe la date d'expiration
function getDefaultExpirationDate () {
	var DateExp= new Date ();
	var aujourdhui = new Date(0);
	var aujourdhuidate = aujourdhui.getTime();
	if (aujourdhuidate > 0) {
		DateExp.setTime (DateExp.getTime() - aujourdhuidate);
	}
	//decallage d'un an
	DateExp.setTime (DateExp.getTime() + (365 * 24 * 60 * 60 * 1000)); 
	return DateExp;
}

function cre_cook0(nom,valeur,expire,path,domaine,securise) {
	document.cookie = nom + "=" + escape (valeur)
		+ ((expire) ? "; expires=" + expire.toGMTString() : "")
		+ ((path) ? "; path=" + path : "")
		+ ((domaine) ? "; domain=" + domaine : "")
		+ ((securise) ? "; secure" : "");
}

function lit_cook(nom) {
	var deb,fin
	deb = document.cookie.indexOf(nom + "=")
	if (deb >= 0) {
		deb += nom.length + 1
		fin = document.cookie.indexOf(";",deb)
		if (fin < 0) {
			fin = document.cookie.length;
		}
		return unescape(document.cookie.substring(deb,fin))
	}
	return "";
}

function tue_cook(nom) {
	cre_cook(nom,"",-1)
}


function handleBandwidthSwitcher(billboard){
	var billboard = eval("(" + billboard + ")");
//	var div = document.getElementById("img_narrow_broad");
//	if (getBandwidth() == "broad") {
//		div.innerHTML = "<img id='bandwidth_switcher' src='" + billboard.narrowbandImageUrl + "' alt='" + billboard.narrowbandTitle + "' title='" + billboard.narrowbandTitle + "' onclick='javascript:chang_img_narrow_broad(billboard);'/>";
//	} else if (getBandwidth() == "narrow") {
//		div.innerHTML = "<img id='bandwidth_switcher' src='" + billboard.broadbandImageUrl + "' alt='" + billboard.broadbandTitle + "' title='" + billboard.broadbandTitle + "' onclick='javascript:chang_img_narrow_broad(billboard);'/>";
//	}
}

function chang_img_narrow_broad(billboard){
	var billboard = eval("(" + billboard + ")");
	var div = document.getElementById("img_narrow_broad");
	var bandwidth = getBandwidth();
	if (bandwidth == "broad") {
		div.innerHTML = "<img id='bandwidth_switcher' src='" + billboard.narrowbandImageUrl + "' alt='" + billboard.narrowbandTitle + "' title='" + billboard.narrowbandTitle + "' onclick='javascript:chang_img_narrow_broad(billboard);'/>";
		bandwidth = "narrow";
	} else {
		div.innerHTML = "<img id='bandwidth_switcher' src='" + billboard.broadbandImageUrl + "' alt='" + billboard.broadbandTitle + "' title='" + billboard.broadbandTitle + "' onclick='javascript:chang_img_narrow_broad(billboard);'/>";
		bandwidth = "broad";
	}
	cre_cook0("nikon_billboard", bandwidth, getDefaultExpirationDate() ,"/");
	document.location.reload();
}