﻿var IE = ((document.all)&&(navigator.userAgent.indexOf("Opera")<0) ? parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]):0);
var allCss = (IE==0 || IE==7);

var gss = {
	FLASH_TEXT_MARGIN : 10,
	FLASH_TEXT_PREFIX : "flashText_",
	/* Class ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
	FlashText : function(id/*String*/, label/*String*/, margin/*Number*/, className/*String*/, menuElement/*Boolean*/, active/*Boolean*/, callBack/*String*/, onClick/*String*/, scale/*Number*/) {
		this.id = id;
		this.domNode = null;
		this.container = null;
		this.margin = margin;
		this.usableWidth = 0;
		this.usableHeight = 0;
		var HTML="";
		var flashVars="";
		flashVars+="FV_label="+label;
		flashVars+="&FV_id="+id;
		flashVars+="&FV_on="+(active?"1":"0");
		flashVars+="&FV_menu="+(menuElement?"1":"0");
		flashVars+="&FV_callBack="+(callBack!="" ? callBack : (this.id+".resize"));
		flashVars+="&FV_onClick="+onClick;
		flashVars+="&FV_scale="+scale;
		HTML+="<div id=\""+gss.FLASH_TEXT_PREFIX+id+"\" class=\"flashText\" style=\"width:1px;\">";
		HTML+="<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" ";
		HTML+="width=\"100%\" height=\"100%\" align=\"middle\">";
		HTML+="<param name=\"movie\" value=\"_elements/movies/menu_entry.swf\" />";
		HTML+="<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
		HTML+="<param name=\"FLASHVARS\" value=\""+flashVars+"\" />";
		HTML+="<param name=\"quality\" value=\"best\" />";
		HTML+="<param name=\"wmode\" value=\"transparent\" />";
		HTML+="<param name=\"scale\" value=\"noscale\" />";
		HTML+="<embed align=\"middle\" allowfullscreen=\"false\" allowscriptaccess=\"sameDomain\" ";
		HTML+="flashvars=\""+flashVars+"\" ";
		HTML+="width=\"100%\" height=\"100%\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" quality=\"best\" scale=\"noscale\" src=\"_elements/movies/menu_entry.swf\" type=\"application/x-shockwave-flash\"  wmode=\"transparent\"></embed>";
		HTML+="</object>";
		HTML+="</div>";
		this.HTML = HTML;
		if(!gss.FlashTextInitOK) {
			/* Initialisation des méthodes publiques................................................................................................................................................................................................................................................................................................................*/
			gss.FlashText.prototype.toString = function()/*String*/ {
				return ("FlashText : "+ this.id);
			}
			/* .......................................................................................................................................................................................................................................................................................................................................................*/
			gss.FlashText.prototype.write = function(container/*Object (Dom Element)*/) {
				if(container) {
					this.container = container;
					container.innerHTML = this.HTML;
				} else {
					document.write(this.HTML);
				}
				this.domNode = document.getElementById(gss.FLASH_TEXT_PREFIX+this.id);
			}
			/* .......................................................................................................................................................................................................................................................................................................................................................*/
			gss.FlashText.prototype.resize = function(width/*Number*/, height/*Number*/) {
				this.usableWidth = Math.round(Number(width)+this.margin);
				this.usableHeight = Math.round(Number(height));
				this.domNode.style.width=this.usableWidth+"px";
				//this.domNode.style.height=this.usableHeight+"px";
				return this.usableWidth;
			}
			/* .......................................................................................................................................................................................................................................................................................................................................................*/
			gss.FlashTextInitOK = true;
		}
	},
	/* Class ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
	Menu : function(varName/*String*/, prefix/*String*/, entriesContainerId/*String*/, scale/*Number*/) {
		this.varName = varName;
		this.prefix = prefix;
		this.entriesContainerId = entriesContainerId;
		this.scale = scale;
		this.entriesContainer = null;
		this.cursor = null;
		this.entries = {length:0};
		this.totalWidth = 0;
		this.activeEntry = "";
		this.cursorHalfWidth = 16;
		if(!gss.MenuInitOK) {
			/* Initialisation des méthodes publiques................................................................................................................................................................................................................................................................................................................*/
			gss.Menu.prototype.addEntry = function(label/*String*/, url/*String*/) {
				this.entries.length++;
				var id = this.prefix+this.entries.length;
				this.entries[id] = {id:id,label:label,url:url,usableWidth:0,middle:0,flashText:null};
			}
			/* .......................................................................................................................................................................................................................................................................................................................................................*/
			gss.Menu.prototype.write = function(idActive/*String*/) {
				this.entriesContainer = document.getElementById(this.entriesContainerId);
				this.cursor = this.entriesContainer.firstChild;
				this.cursor.style.display = "none";
				this.activeEntry = idActive;
				for(var i=1;i<=this.entries.length;i++) {
					var id = this.prefix+i;
					this.entries[id].flashText = new gss.FlashText(id, this.entries[id].label, gss.FLASH_TEXT_MARGIN, "", true, id==idActive, this.varName+".resize", this.varName+".onClick", this.scale);
					this.entries[id].flashText.write();
				}
			}
			/* .......................................................................................................................................................................................................................................................................................................................................................*/
			gss.Menu.prototype.resize = function(width/*String*/, height/*String*/, id/*String*/) {
				var usableWidth = this.entries[id].flashText.resize(width, height);
				this.entriesContainer.style.width=(this.totalWidth+=usableWidth)+"px";
				this.entries[id].usableWidth = usableWidth;
				this.entries[id].middle = this.totalWidth-usableWidth/2;
				if(id==this.activeEntry) this.setCursor(id);
			}
			/* .......................................................................................................................................................................................................................................................................................................................................................*/
			gss.Menu.prototype.setCursor = function(id/*String*/) {
				var entry = this.entries[id];
				this.cursor.style.display = "block";
				this.cursor.style.left=(entry.middle-this.cursorHalfWidth)+"px";
			}
			/* .......................................................................................................................................................................................................................................................................................................................................................*/
			gss.Menu.prototype.onClick = function(id/*String*/) {
				document.location = this.entries[id].url;
			}
			/* .......................................................................................................................................................................................................................................................................................................................................................*/
			gss.MenuInitOK = true;
		}
	},
	/* package ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
	title : {
		/* function ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
		write : function(label) {
			eval("window['pageTitle'] = new gss.FlashText('pageTitle', \""+label+"\", 10, '', false, true, 'gss.title.resize', '', 110)");
			pageTitle.write();
		},
		/* function ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
		resize : function(width, height) {
			var usableWidth = pageTitle.resize(width, height);
			document.getElementById("divTitle").style.width=usableWidth+"px";
			if(allCss) {
				document.getElementById("divTitle").style.marginLeft="-"+Math.round(usableWidth/2)+"px";
				document.getElementById("divTitleFlash").style.width=usableWidth+"px";
			} else {
				document.getElementById("divTitleFlash").style.marginLeft=Math.round((260-usableWidth)/2)+"px";
			}
		}
		/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
	},
	/* Class ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
	ArtWork : function(id/*Number*/, title/*String*/, technic/*String*/, dimensions/*String*/, price/*Number*/, image/*String*/) {
		this.id = id;
		this.title = title;
		this.technic = technic;
		this.dimensions = dimensions;
		this.price = price;
		this.image = image;
		if(!gss.ArtWorkInitOK) {
			/* Initialisation des méthodes publiques................................................................................................................................................................................................................................................................................................................*/
			gss.ArtWork.prototype.display = function(link) {
				link.blur();
				document.getElementById("objTitle").innerHTML = this.title;
				document.getElementById("objTechnic").innerHTML = this.technic;
				document.getElementById("objDimensions").innerHTML = this.dimensions;
				document.getElementById("objImage").src = this.image;
				document.getElementById("objImage").title = this.title;
				document.getElementById("objImage").alt = this.title;
			}
			/* .......................................................................................................................................................................................................................................................................................................................................................*/
			gss.ArtWorkInitOK = true;
		}
	},
	/* Class ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
	Exposition : function(id/*Number*/, title/*String*/, dates/*String*/, recto/*String*/, verso/*String*/) {
		this.id = id;
		this.title = title;
		this.dates = dates;
		this.recto = recto;
		this.verso = verso;
		if(!gss.ExpositionInitOK) {
			/* Initialisation des méthodes publiques................................................................................................................................................................................................................................................................................................................*/
			gss.Exposition.prototype.display = function(link) {
				link.blur();
				document.getElementById("objTitle").innerHTML = this.title;
				document.getElementById("objTechnic").innerHTML = this.technic;
				document.getElementById("objDimensions").innerHTML = this.dimensions;
				document.getElementById("objImage").src = this.image;
			}
			/* .......................................................................................................................................................................................................................................................................................................................................................*/
			gss.ExpositionInitOK = true;
		}
	}
	/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
}

