//initiating
var ns4;
var ie4;
var ng5;
var lay;
var n;
var curnews;
var curpart;
var curvins;
var mappy;
curnews="news0";
curpart="accueil";
curvins="promo";
mappy="http://www.mappy.com/mappymoi/map?data_id=880DD843-B87E-4DD5-BD06-612DBD5E994D"

//detect browser
ns4 = (document.layers) ? true:false 
ie4 = (document.all) ? true:false 
ng5 = (document.getElementById) ? true:false 

function centerlayers() {
	if (ie4) wide = Math.min(Math.max(document.body.clientWidth,830),1200)-484
	else if (ns4 || ng5) wide = Math.min(Math.max(window.innerWidth,830),1200)-484
	if(ng5) {
		if (curpart=="accueil") document.getElementById(curnews).style.width = wide+"px"
		else if (curpart=="vins") document.getElementById(curvins).style.width = wide+"px"
		document.getElementById(curpart+"content").style.width = wide+"px"
		document.getElementById("grad").style.left = (334+wide)+"px"
		document.getElementById("fond").style.width = (484+wide)+"px"
		document.getElementById("langues").style.width = (wide-138)+"px"
	}
	else if (ns4) {
		if (curpart=="accueil") document.layers[curnews].width = wide+"px"
		else if (curpart=="vins") document.layers[curvins].width = wide+"px"
		document.layers[curpart+"content"].width = wide+"px"
		document.layers["grad"].left = (334+wide)+"px"
		document.layers["fond"].width = (484+wide)+"px"
		document.layers["langues"].width = (wide-138)+"px"
	}
	else if (ie4) {
		if (curpart=="accueil") document.all[curnews].width = wide+"px"
		else if (curpart == "vins") document.all[curvins].width = wide+"px"
		document.all[curpart+"content"].width = wide+"px"
		document.all["grad"].left = (334+wide)+"px"
		document.all["fond"].width = (484+wide)+"px"
		document.all["langues"].width = (wide-138)+"px"
	}
}

function poplay(lay) {	//set any layer visible
	if (ng5) document.getElementById(lay).style.visibility = "visible"
	else if (ns4) document.layers[lay].visibility = "show"
	else if (ie4) document.all[lay].style.visibility = "visible"
}

function hidelay(lay) { //set any layer hidden
	if (ng5) document.getElementById(lay).style.visibility = "hidden"
	else if (ns4) document.layers[lay].visibility = "hide"
	else if (ie4) document.all[lay].style.visibility = "hidden"
}

function shownews(lay) {
	hidelay(curnews)
	poplay(lay)
	curnews=lay
	centerlayers()
}
function showsec(sec) {
	hidelay(curvins)
	poplay(sec)
	curvins=sec
	centerlayers()
}
function showpart(part) {
	if (curpart=="accueil") hidelay(curnews)
	else if (curpart=="vins") hidelay(curvins)
	else if (curpart=="contact") { 
		if (ie4) frames["contactcontent"].location.href = ""
		else if (ng5||ns4) document.getElementById("contactcontent").src= ""
	}
	hidelay(curpart)
	hidelay(curpart+"content")
	poplay(part)
	poplay(part+"content")
	if (part=="vins") poplay(curvins)
	else if (part=="accueil") poplay(curnews)
	else if (part=="contact") {
		if (ie4) frames["contactcontent"].location.href = mappy
		else if (ng5||ns4) document.getElementById("contactcontent").src= mappy
	}
	curpart=part
	centerlayers()
}
document.onResize=centerlayers()
