//for rollOvers *************************************************************************************
function SimpleSwap(el,which) {
  el.src=el.getAttribute(which || "origsrc");
}
function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var longdesc = x[i].getAttribute("longdesc");
    if (!longdesc) continue;
      
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].longdesc_img = new Image();
    x[i].longdesc_img.src=longdesc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'longdesc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}
SimpleSwapSetup();
//***************************************************************************************************

//for highslide *************************************************************************************
hs.graphicsDir = 'js/highslide/graphics/';	//graphics folder for hs
hs.captionEval = 'this.a.title'; 						//get the link title and use it as caption
hs.transitions = ["expand"]; 								//options: ["expand"] , ["fade"]
hs.outlineType = null; 											//options: 'rounded-white', 'outer-glow', 'drop-shadow', null
hs.loadingOpacity = 0.75;										//alpha for loading div only
hs.showCredits = false;
hs.captionSlideSpeed = 0; 									// set to 0 to disable slide in effect

hs.expandSteps = 50;
hs.expandDuration = 200;
hs.restoreSteps = 20;
hs.restoreDuration = 200;

//hs.marginLeft = 50;
//hs.marginRight = 0;
hs.marginTop = 96;
//hs.marginBottom = 0;
hs.align = 'left';
hs.outlineWhileAnimating = true;
hs.restoreTitle = '';
hs.blockRightClick = true;
hs.fadeInOut = true;

hs.targetX = 'CMS_menusL1 0px';
//hs.targetY = 'CMS_menusL1 20px';
hs.restoreCursor = ''

// always use this with flash, else the movie will be stopped on close:
hs.preserveContent = false;

//GROUP NAVIGATION. To have a group with all images having class="highslide" class (see tinyMCE.css, the class is there)
hs.onSetClickEvent = function ( sender, e ) {
   // set the onclick for the element, output the group name to the caption for debugging
   e.element.onclick = function () {
      return hs.expand(this, { slideshowGroup: this.parentNode.className, 
         captionText: this.parentNode.className });
   }
   // return false to prevent the onclick being set once again
   return false;
}
//***************************************************************************************************


//delete confirmation
function confirmMsg(msg) {
  document.returnValue = confirm(msg);
}

//pour color_pick
function popup(color,inputid) {
	var iMyWidth;
	var iMyHeight;
	iMyWidth = (window.screen.width/2) - (75 + 10);
	iMyHeight = (window.screen.height/2) - (100 + 50);
	var win2 = window.open("js/colorpicker/colorpicker.php?inputid=" + inputid + "&color=" + color,"Window2","status=no,height=290,width=225,resizable=1,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
	//var win2 = window.open( "js/colorpicker/colorpicker.php?color=" + color, "myWindow", "status=0, height=290, width=225, resizable=1" );
	win2.focus();
}

//classic pop-up general uses
function popUp(URL,l,h) {
	id = 'popup';
	var iMyWidth;
	var iMyHeight;
	iMyWidth = (screen.width) ? (screen.width-l)/2 : 0;
	iMyHeight = (screen.height) ? (screen.height-h)/2 : 0;
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+ l +",height="+ h +",left = "+ iMyWidth +",top = "+ iMyHeight +"');");
}

//SHOW/HIDE DIV. Call with: onclick="showstuff('id_of_element_to_show');"
function showstuff(boxid){
   document.getElementById(boxid).style.display="block";
}
function hidestuff(boxid) {
   document.getElementById(boxid).style.display="none";
}

//Put a value into an input
function putValue(inputid, value) {
	document.getElementById(inputid).value = value;
}

//Change an image src
function changeSrc(img, src) {
	document.getElementById(img).src=src;
}

//PRELOAD IMAGES LIST
if (document.images) {
	/*
	img1 = new Image();
	img2 = new Image();
	img3 = new Image();
	img4 = new Image();
	img5 = new Image();
	
	img1.src = "templates/alex/img/bg_contact.jpg";
	img2.src = "templates/alex/img/bg_galerie.jpg";
	img3.src = "templates/alex/img/bg_home.jpg";
	img4.src = "templates/alex/img/bg_portrait.jpg";
	img5.src = "templates/alex/img/bg_programme.jpg";
	*/
}

//CLEAR INPUTS CONTENT
function clearText(thefield) {
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
}
function clearStyle(thefield) {
	theField.style.color = "black";
}

function f(el) {
	if ( el.defaultValue == el.value ) el.value = "";
}
function b(el, txt) {
	if (this.value == '') el.value = txt;
}


//if(this.value == 'Click here and this will disappear..') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Click here and this will disappear..';}"
//*************************************************************************************************************************
