var slidespeed=1;
var fadeduration=2;
var slideduration=3000;
var ie=document.all;
var imageholder=new Array();
var Picture = new Array(); 
var Caption = new Array();
var Link = new Array();
var tss;
var iss;
var jss = 0;

function gotoshow(){
  window.location=slidelinks[whichlink];
}

function followlink(){
  window.location=Link[jss];
}

function slideit(){
if (!document.images) return
if (ie) document.images.slide.filters[0].apply()
document.images.slide.src=imageholder[whichimage].src
if (ie) document.images.slide.filters[0].play()
whichlink=whichimage
whichimage=(whichimage<slideimages.length-1)? whichimage+1 : 0
setTimeout("slideit()",slidespeed+fadeduration)
}

function runSlideShow(){
jss += 1; if (jss > (pss)) jss=1;
if (document.all){
document.images.PictureBox.style.filter="blendTrans(duration=fadeduration)";
document.images.PictureBox.filters.blendTrans.Apply();
}
document.images.PictureBox.src = preLoad[jss].src;
if (document.getElementById) document.getElementById("CaptionBox").innerHTML=Caption[jss];
if (ie) document.images.PictureBox.filters.blendTrans.Play();
tss = setTimeout('runSlideShow()', slideduration);
}

function Trsf(a){
   b=(Math.pow(a,2)-1)*3;
   return "Babe"+b+".jpg";
}

function OpenWin (PageURL,PageWidth,PageHeight) {
  NewWindow = window.open(PageURL, "NewWin", "width="+PageWidth+",height="+PageHeight+",toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");
  NewWindow.focus();
}

function OpenHelp (PageURL,PageWidth,PageHeight) {
  NewImgWindow = window.open(PageURL, "NewHelp", "width="+PageWidth+",height="+PageHeight+",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
  NewImgWindow.focus();
}

function ZoomImg (PageURL,PageWidth,PageHeight) {
  NewImgWindow = window.open(PageURL, "NewZoom", "width="+PageWidth+",height="+PageHeight+",toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");
  NewImgWindow.focus();
}

function ZoomAndToggle (PageURL,PageWidth,PageHeight) {
  NewImgWindow = window.open(PageURL, "ZoomToggle", "width="+PageWidth+",height="+PageHeight+",toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");
  var html = "<html><head><link rel='stylesheet' href='/sm.css' type='text/css'><script language='JavaScript1.2' src='/sm.js'></script></head>"
  html += "<body><img onmouseover='SetOn(this)' onmouseout='SetOff(this)' alt='Après' src='"+PageURL+"' border='0' name='img_toggle'></body></html>"
  NewImgWindow.document.open()
  NewImgWindow.document.write(html)
  NewImgWindow.document.close()
  NewImgWindow.focus();
}

function PreLoad () {
  if (!document.images) return;
  var ar = new Array();
  var arguments = PreLoad.arguments;
  for (var i = 0; i < arguments.length; i++) {
    ar[i] = new Image();
    ar[i].src = "images/" + arguments[i];
  }
}
function newImage (arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
function changeImages () {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
function High (ImgObject){
	ImgObject.filters.alpha.opacity=100;
	ImgObject.opacity=1;
	return;
}
function Low (ImgObject){
	ImgObject.filters.alpha.opacity=50;
	ImgObject.opacity=.5;
	return;
}

function Gray (ImgObject){
	ImgObject.filters.gray.enabled = 1;
	return;
}
function Color (ImgObject){
	ImgObject.filters.gray.enabled = 0;
	return;
}
function SetOn(ImgObject){
  ImgObject.src = ImgObject.src.replace("-1.","-2."); 
	return;	
}
function SetOff(ImgObject){
  ImgObject.src = ImgObject.src.replace("-2.","-1."); 
	return;	
}

function ProcessParticipationForm () {
   var err_msg;
  
   err_msg = "";

   if (trim(document.participationform.realname.value).length <= 0) {
      err_msg = "Merci de spécifier votre nom et prénom...\n";  
   }

   if (trim(document.participationform.address.value).length <= 0) {
      err_msg = err_msg + "Merci de spécifier votre adresse complète...\n";  
   }

   if (trim(document.participationform.birthdate.value).length <= 0) {
      err_msg = err_msg + "Merci de spécifier votre date de naissance...\n";  
   }

   if (trim(document.participationform.email.value).length <= 0) {
      err_msg = err_msg + "Merci de spécifier votre adresse Email...\n";  
   } else {   
     if (!isEmail(document.participationform.email.value)) {
       err_msg = err_msg + "L'adresse Email indiquée n'est pas valide...\n";  
     } else {
       if (document.participationform.email.value != document.participationform.email2.value) {
         err_msg = err_msg + "Les 2 adresses Email spécifiées ne sont pas identiques...\n";  
       }
     }
   } 

   if (trim(document.participationform.phone.value).length <= 0) {
      err_msg = err_msg + "Merci de spécifier un numéro de mobile valable...\n";  
   }    

   if (!document.participationform.accept_conditions.checked) {
      err_msg = err_msg + "Il faut accepter nos conditions pour pouvoir valider votre inscription...\n";  
   }    

   if (trim(document.participationform.imgverify.value).length <= 0) {
      err_msg = err_msg + "Il faut retaper le code de sécurité pour pouvoir valider votre inscription...\n";  
   }    

   if (err_msg.length > 0) {
      alert(err_msg);
   } else {
     document.forms["participationform"].submit();
   }
}

function ProcessCastingForm () {
   var err_msg;
  
   err_msg = "";

   if (trim(document.castingform.realname.value).length <= 0) {
      err_msg = "Il manque votre nom et votre prénom...\n";  
   }

   if (trim(document.castingform.address.value).length <= 0) {
      err_msg = err_msg + "Il manque votre adresse complète...\n";  
   }

   if (trim(document.castingform.naissance.value).length <= 0) {
      err_msg = err_msg + "Il manque votre date de naissance...\n";  
   }

   if (trim(document.castingform.email.value).length <= 0) {
      err_msg = err_msg + "Il manque votre adresse Email...\n";  
   } else {   
     if (!isEmail(document.castingform.email.value)) {
       err_msg = err_msg + "L'adresse Email indiquée n'est pas valide...\n";  
     } else {
       if (document.castingform.email.value != document.castingform.email2.value) {
         err_msg = err_msg + "Les 2 adresses Email spécifiées ne sont pas identiques...\n";  
       }
     }
   } 

   if (trim(document.castingform.phone.value).length <= 0) {
      err_msg = err_msg + "Il manque un numéro de mobile valable...\n";  
   }    

   if (trim(document.castingform.grandeur.value).length <= 0) {
      err_msg = err_msg + "Il manque votre grandeur...\n";  
   }

   if (trim(document.castingform.poitrine.value).length <= 0) {
      err_msg = err_msg + "Il manque votre tour de poitrine...\n";  
   }

   if (document.castingform.bonnet.value == "-") {
      err_msg = err_msg + "Il manque la taille de vos bonnets...\n";  
   }

   if (trim(document.castingform.taille.value).length <= 0) {
      err_msg = err_msg + "Il manque votre tour de taille...\n";  
   }

   if (trim(document.castingform.hanche.value).length <= 0) {
      err_msg = err_msg + "Il manque votre tour de hanche...\n";  
   }

   if (document.castingform.confection.value == "-") {
      err_msg = err_msg + "Il manque votre confection (pour les habits)...\n";  
   }

   if (document.castingform.pointure.value == "-") {
      err_msg = err_msg + "Il manque votre pointure (pour les chaussures)...\n";  
   }

   if (trim(document.castingform.portrait.value).length <= 0 && trim(document.castingform.pied.value).length <= 0) {
      err_msg = err_msg + "Il faut nous faire parvenir au moins une photo...\n";  
   }    

   if (!document.castingform.accept_conditions.checked) {
      err_msg = err_msg + "Il faut accepter nos conditions pour valider votre inscription...\n";  
   }    

   if (trim(document.castingform.imgverify.value).length <= 0) {
      err_msg = err_msg + "Il faut retaper le code de sécurité pour valider l'inscription...\n";  
   }    

   if (err_msg.length > 0) {
      alert(err_msg);
   } else {
     document.forms["castingform"].submit();
   }
}

function myunescape(str)
{
	str = '' + str;
	while (true)
	{
		var i = str.indexOf ('+');
		if (i < 0)
			break;
		str = str.substring(0, i) + ' ' + str.substring(i + 1, str.length);
	}
	return unescape(str);
}

function args_init()
{
	var argstring = window.location.search;
	if (argstring.charAt(0) != '?')
		return;
	argstring = argstring.substring(1, argstring.length);
	var argarray = argstring.split('&');
	var i;
	var singlearg;
	for (i = 0; i < argarray.length; ++ i)
	{
		singlearg = argarray[i].split('=');
		if (singlearg.length != 2)
			continue;
		var key = myunescape(singlearg[0]);
		var value = myunescape(singlearg[1]);
		args[key] = value;
	}
}

function getParameter(paramName) {
	var currentUrl = myunescape(window.location.search);
	var strBegin = currentUrl.indexOf(paramName+"=") + (paramName.length+1);
	var strEnd = currentUrl.indexOf("&",strBegin);

	if (strEnd==-1)
		strEnd = currentUrl.length;

	return currentUrl.substring(strBegin,strEnd);
}

function isEmail(strSaisie) {
    var verif = /^[^@]+@(([\w\-]+\.){1,4}[a-zA-Z]{2,4}|(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5]))$/
    return ( verif.test(strSaisie) );
}

function trim(aString) {
    var regExpBeginning = /^\s+/;
    var regExpEnd       = /\s+$/;
    return aString.replace(regExpBeginning, "").replace(regExpEnd, "");
}

