// Detect  navigator version.
var undef = "undefined";
function AgentBw () {
	this.version = navigator.appVersion;
	this.agent = navigator.userAgent;
	// Detect navigator vendor id, need to recognize Netscape version which more than 4.x.
	// If navigator not support this field, it set 0.
	this.vendorSub = (navigator.vendorSub == undef || 
							navigator.vendorSub == null || 
							navigator.vendorSub == "") ? 0 : parseInt (navigator.vendorSub);
	this.supportDom = document.getElementById ? 1 : 0;
	//********** Opera detect section *******************//
	this.opera5 = (this.agent.indexOf ("Opera 5") > -1) ? 1 : 0;
	this.opera7 = (this.agent.indexOf ("Opera 7") > -1) ? 1 : 0;
	this.opera6 = (this.agent.indexOf ("Opera 6") > -1) ? 1: 0;
	this.opera = (this.opera5 || this.opera7 || this.opera6);
	this.webtv = (this.version.indexOf ("WebTV") > -1) ? 1 : 0;
	//********* Internet Exlorer detect section *************//
	this.ie5 = (this.version.indexOf ("MSIE 5") >-1 && this.supportDom && !this.opera) ? 1 : 0;
	this.ie6 = (this.version.indexOf ("MSIE 6") >-1 && this.supportDom && !this.opera) ? 1 : 0;
	this.ie4 = (document.all && !this.supportDom && !this.opera && !this.webtv) ? 1 : 0;
	this.ie = (this.ie5 || this.ie6 || this.ie4);
	//********* Macintosh detect section ******************//
	this.mac = (this.agent.indexOf ("Mac") > -1) ? 1 : 0;
	//******** Netscape Navigator detect section *********//
	this.ns7 = (this.supportDom && this.vendorSub == 7) ? 1 : 0;
	this.ns6 = (this.supportDom && this.vendorSub == 6) ? 1 : 0;
	this.ns4 = (document.layers && !this.supportDom) ? 1 : 0;
	this.ns = (this.ns6 || this.ns4 || this.ns7);
	//******** Mozilla detect section *************//
	this.mozilla5 = (!this.ns && !this.ie && !this.opera && 
	this.agent.indexOf ("Gecko") > -1 && parseInt (this.version) == 5) ? 1 : 0;
	this.mozilla = this.mozilla5;

	this.bw = (this.ie || this.ns || this.opera || this.mozilla);
	return this;
}

var bw = new AgentBw ();

var undef = "undefined";

function createLayer (elemId) {
	var obj = document.getElementById (elemId);
	if (obj == null)
		return null;
	this.css = obj.style;
	this.layerX = parseInt (this.css.left);
	this.layerY = parseInt (this.css.top);
	this.width = parseInt (obj.offsetWidth);
	this.height = parseInt (obj.offsetHeight);
	return this;
}
		
createLayer.prototype.setPositionX = function (newX) {
	this.css.left = newX;
}
		
createLayer.prototype.setPositionY = function (newY) {
	this.css.top = newY;
}
		
createLayer.prototype.setWidth = function (newWidth) {
	this.css.width = newWidth;
}
		
createLayer.prototype.setHeight = function (newHeight) {
	this.css.height = newHeight;
}
		
createLayer.prototype.showLayer = function () {
	this.css.visibility = "visible";
}
		
createLayer.prototype.hideLayer = function () {
	this.css.visibility = "hidden";
}
		
createLayer.prototype.setFirstLimitX = function (fLimX) {
	this.firstLimitX = fLimX;
}
		
createLayer.prototype.setLastLimitX = function (lLimX) {
	this.lastLimitX = lLimX;
}
		
createLayer.prototype.setFirstLimitY = function (fLimY) {
	this.firstLimitY = fLimY;
}
		
createLayer.prototype.setLastLimitY = function () {
	this.lastLimitY = parseInt (this.css.top) + this.height + 15;
}

// Calculate element position x.
function relPos(which) {
  if (bw.ns4) {
    this.x = document.layers[which].pageX;
    this.y = document.layers[which].pageY;
  } else {
    var elem = (1)? document.getElementById(which) : document.all[which];
    this.x = elem.offsetLeft;
    this.y = elem.offsetTop;
	this.width = elem.offsetWidth;
	this.height = elem.offsetHeight;
    while (elem.offsetParent != null) {
	if (elem.tagName == 'BODY') break;
      elem = elem.offsetParent;
      this.x += elem.offsetLeft;
      this.y += elem.offsetTop;
    }
  }
  return this;
}

var activeElem = null;

// Highlight the image icon.
function highlightIcon (elemId, elemIndex) {
	document.getElementById (elemId).src = elemIndex;
}

// Init page aplpication.
function initApp (initAll) {
	bw = new AgentBw ();
}


function showSubMenu (elemId, divElemId) {
	if (activeElem != null) {
		releaseActiveElem ();
	}

	var img = new relPos (elemId);
	var _y = img.y;
	// If opera.
	if (bw.opera7)
		_y -= 89;

	activeElem = new createLayer (divElemId);
	if (activeElem == null)
		return;

	activeElem.setPositionX (img.x);
	activeElem.setPositionY (_y+img.height-1);
	activeElem.setWidth (img.width);
	activeElem.setFirstLimitX (img.x);
	activeElem.setLastLimitX (img.x + img.width);
	activeElem.setFirstLimitY (_y);
	activeElem.setLastLimitY ();
	activeElem.showLayer ();
}

function releaseActiveElem () {
	if (activeElem != null) {
		activeElem.hideLayer ();
		activeElem = null;
	}
}
		
document.onmousemove = function (e) {
	if (activeElem != null) {
		var _x = (bw.ie || bw.opera) ? event.clientX : e.pageX;
		var _y = (bw.ie || bw.opera) ? event.clientY : e.pageY;
		var scrollLeft = (document.body.scrollLeft) ? document.body.scrollLeft : 0;
		var scrollTop = (document.body.scrollTop) ? document.body.scrollTop : 0;
		_x += scrollLeft;
		_y += scrollTop;

		if (_x < activeElem.firstLimitX || _x > activeElem.lastLimitX 
			|| _y < activeElem.firstLimitY || _y > activeElem.lastLimitY) {
				releaseActiveElem ();
		}
	}
}

function BigXY(url,w,h,alt) {
//var w1=window.open('','zoom_window','resizable=yes,menubar=no,status=no,scrollbars=auto,width=1,height=1');
//w1.close();
var ScrWindow=window.open('/include/zoom.html','zoom_window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,left=15,top=15,width='+w+',height='+h);
if (ScrWindow != null && ScrWindow.opener == null) ScrWindow.opener=window;
	ScrWindow.document.open();
	ScrWindow.document.writeln ("<html><head><title>Peugeot - "+alt+"</title></head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>"+
	"<img src='"+url+"'>"+
	"</body></html>");
	ScrWindow.document.close();
ScrWindow.onload=ScrWindow.focus;
ScrWindow.focus();
}


function newWin (url,w,h) {
var
w1=window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,left=15,top=15,width='+w+',height='+h);
w1.focus();
}

function newWinNoResize (url,w,h) {
var
w1=window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=15,top=15,width='+w+',height='+h);
w1.focus();
}

function newWinScroll (url,w,h) {
var
w1=window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=15,top=15,width='+w+',height='+h);
w1.focus();
}

function newWinScrollRight (url,w,h,l,t) {
var
w1=window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left='+l+',top='+t+',width='+w+',height='+h);
w1.focus();
}

function newWinSame (url,w,h){
var w1=window.open('','same_window','resizable=yes,menubar=no,status=no,scrollbars=auto,width=1,height=1');
w1.close();
w1=window.open(url,'same_window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=15,top=15,width='+w+',height='+h);
w1.onload=w1.focus;
w1.focus();
}

/* SUBSCRIPTION */

