/* 2005 Kahiloa Solutions et Communication - http://www.kahiloa.com */
/* www.vins-de-bourgogne-sud.com */
/* SCRIPT GLOBAL */

//surcharge de getElementById , plus fiable
if (document.getElementById) {
  window.GE = function(id) {
    return document.getElementById(id);
  }
} else if (document.all) {
  window.GE = function(id) {
    return document.all[id]
  }
} else {
  window.GE = function(id) {
    return false;
  }
}

//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;

//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
	}
};

/* 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';	
	//alert(vStyle.height);
}

/* Redimensionnement d'un div par rapport a un autre */
function resizeLeftDiv(pLeftColValue, pRightColValue){

	var vObjLeft = document.getElementById(pLeftColValue);
	var vObjRight = document.getElementById(pRightColValue);
    
	if(vObjLeft!=null && vObjRight!=null){
		var vLeftHeightDiv = getHeightDivById(pLeftColValue);
		var vRightHeightDiv = getHeightDivById(pRightColValue);
		var vDiff = 0;
		var vtype = null;
		    
		if(vLeftHeightDiv > vRightHeightDiv) {
			vtype = 'right';
			vDiff = vLeftHeightDiv - vRightHeightDiv;			
		} else {
			vtype = 'left';
			vDiff = vRightHeightDiv - vLeftHeightDiv;
		}
		
		//alert('vRightHeightDiv : '  + vRightHeightDiv + ' / vLeftHeightDiv : ' + vLeftHeightDiv + ' / vtype : ' + vtype + ' / vDiff : ' + vDiff );				
		vDiff = vDiff + 13;

		
		if(vtype == 'left') {			 				
			setHeightDivById('left_bottom_spacer', vDiff);
		} else {			
			setHeightDivById('right_bottom_spacer', vDiff);
		}
    
		// test navigator
		if(sniff.bw.ie) { 
			vDiff=vDiff;
		} else { 
			vDiff=vDiff-2;
		}
	}
}


/* Open Window */
//Ouverture d'une window
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openWindow(pUrl, pNameWindow, pWidth, pHeight, pResizable, pMenubar, pToolbar, pLocation, pDirectories, pStatus, pScrollbars, pLeft, pTop) {
  var vParamNewWindow = '';
	vParamNewWindow += 'width=' + pWidth;
	vParamNewWindow += ',height=' + pHeight;
	if (pResizable) vParamNewWindow += ',resizable=1'; else vParamNewWindow += ',resizable=0';
  if (pMenubar) vParamNewWindow += ',menubar=1'; else vParamNewWindow += ',menubar=0';
  if (pToolbar) vParamNewWindow += ',toolbar=1'; else vParamNewWindow += ',toolbar=0';
  if (pLocation) vParamNewWindow += ',location=1'; else vParamNewWindow += ',location=0';
	if (pDirectories) vParamNewWindow += ',directories=1'; else vParamNewWindow += ',directories=0';
	if (pStatus) vParamNewWindow += ',status=1'; else vParamNewWindow += ',status=0';
	if (pScrollbars) vParamNewWindow += ',scrollbars=1'; else vParamNewWindow += ',scrollbars=0';
	vParamNewWindow += ',left=' + pLeft;
	vParamNewWindow += ',top=' + pTop;
	var vRefNewWindow = window.open(pUrl, pNameWindow, vParamNewWindow);
}


function mot_passe_oublie(url,element,c){
	
	if(!element){
		var email = document.box_moncompte.login.value;
	} else {
		var email = element.value;
	}
	 
	if (email != '')
		window.location = "/?mpo=1&email=" + email + "&purl=" + escape(url) ;	
	else
		alert(c);	
}
 

function alert_mpo (envoye, c) {
	if (envoye == 1) {
		alert(c);
	}
}

function switchbloc(bloc, link, numbloc) 
{
	var a = document.getElementById(bloc); 
	
	var b = document.getElementById(link);
	
	for (var i = 1; i<=8; i++) 
	{
		var c = document.getElementById('bloc-dyn'+numbloc+'_'+i);
		var d = document.getElementById('tab-dyn'+numbloc+'_'+i);
		if (c && d) 
		{
			c.style.display='none';
			d.className='inactif';
		}
	}
	
	if (a) 
	{
	 
		a.style.display='block';
		b.className = 'actif';
	}
}
