/*
  $Id: general.js,v 1.1.1.1 2005/05/03 15:20:33 manmachine Exp $
+-----------------------------------------------------------------------+
|                  osCSS Open Source E-commerce                         |
+-----------------------------------------------------------------------+
| Copyright (c) 2005 The osCSS developers                               |
|                                                                       |
| http://www.counteractdesign.com                                       |
|                                                                       |
| Portions Copyright (c) 2003 osCommerce                                |
+-----------------------------------------------------------------------+
| This source file is subject to version 2.0 of the GPL license,        |
| available at the following url:                                       |
| http://www.counteractdesign.com/license/2_0.txt.                      |
+-----------------------------------------------------------------------+
*/

function SetFocus(TargetFormName) {
  var target = 0;
  if (TargetFormName != "") {
    for (i=0; i<document.forms.length; i++) {
      if (document.forms[i].name == TargetFormName) {
        target = i;
        break;
      }
    }
  }

  var TargetForm = document.forms[target];
    
  for (i=0; i<TargetForm.length; i++) {
    if ( (TargetForm.elements[i].type != "image") && (TargetForm.elements[i].type != "hidden") && (TargetForm.elements[i].type != "reset") && (TargetForm.elements[i].type != "submit") ) {
      TargetForm.elements[i].focus();

      if ( (TargetForm.elements[i].type == "text") || (TargetForm.elements[i].type == "password") ) {
        TargetForm.elements[i].select();
      }

      break;
    }
  }
}

function RemoveFormatString(TargetElement, FormatString) {
  if (TargetElement.value == FormatString) {
    TargetElement.value = "";
  }

  TargetElement.select();
}

function CheckDateRange(from, to) {
  if (Date.parse(from.value) <= Date.parse(to.value)) {
    return true;
  } else {
    return false;
  }
}

function IsValidDate(DateToCheck, FormatString) {
  var strDateToCheck;
  var strDateToCheckArray;
  var strFormatArray;
  var strFormatString;
  var strDay;
  var strMonth;
  var strYear;
  var intday;
  var intMonth;
  var intYear;
  var intDateSeparatorIdx = -1;
  var intFormatSeparatorIdx = -1;
  var strSeparatorArray = new Array("-"," ","/",".");
  var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  strDateToCheck = DateToCheck.toLowerCase();
  strFormatString = FormatString.toLowerCase();
  
  if (strDateToCheck.length != strFormatString.length) {
    return false;
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
      intFormatSeparatorIdx = i;
      break;
    }
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
      intDateSeparatorIdx = i;
      break;
    }
  }

  if (intDateSeparatorIdx != intFormatSeparatorIdx) {
    return false;
  }

  if (intDateSeparatorIdx != -1) {
    strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
    if (strFormatArray.length != 3) {
      return false;
    }

    strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
    if (strDateToCheckArray.length != 3) {
      return false;
    }

    for (i=0; i<strFormatArray.length; i++) {
      if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm') {
        strMonth = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'dd') {
        strDay = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'yyyy') {
        strYear = strDateToCheckArray[i];
      }
    }
  } else {
    if (FormatString.length > 7) {
      if (strFormatString.indexOf('mmm') == -1) {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mm'), 2);
      } else {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mmm'), 3);
      }

      strDay = strDateToCheck.substring(strFormatString.indexOf('dd'), 2);
      strYear = strDateToCheck.substring(strFormatString.indexOf('yyyy'), 2);
    } else {
      return false;
    }
  }

  if (strYear.length != 4) {
    return false;
  }

  intday = parseInt(strDay, 10);
  if (isNaN(intday)) {
    return false;
  }
  if (intday < 1) {
    return false;
  }

  intMonth = parseInt(strMonth, 10);
  if (isNaN(intMonth)) {
    for (i=0; i<strMonthArray.length; i++) {
      if (strMonth == strMonthArray[i]) {
        intMonth = i+1;
        break;
      }
    }
    if (isNaN(intMonth)) {
      return false;
    }
  }
  if (intMonth > 12 || intMonth < 1) {
    return false;
  }

  intYear = parseInt(strYear, 10);
  if (isNaN(intYear)) {
    return false;
  }
  if (IsLeapYear(intYear) == true) {
    intDaysArray[1] = 29;
  }

  if (intday > intDaysArray[intMonth - 1]) {
    return false;
  }
  
  return true;
}

function IsLeapYear(intYear) {
  if (intYear % 100 == 0) {
    if (intYear % 400 == 0) {
      return true;
    }
  } else {
    if ((intYear % 4) == 0) {
      return true;
    }
  }

  return false;
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
}

//CCGV BOC
function couponpopupWindow(url) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
}
//CCGV EOC

// Debut -désactiver clic droit

var message="This site is protected by copyright - Cosmaphrodite"
/*
function empecheClicDroit(e) {
  if (document.all) {
    if (event.button == 2) {
      alert(message);
      return false;
    }
  }
  if (document.layers||document.getElementById) {
    if (e.which == 3) {
      alert(message);
      return false;
    }
  }
}
if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=empecheClicDroit;
// eof clic droit
*/

var defilement = false;
			var Fondu = function(classe_img){
				this.courant = 0;
				this.coeff = 100;
				this.collection = this.getImages();
				this.collection[0].style.zIndex = 100;
				this.total = this.collection.length - 1;
				this.encours = false;
			}
			Fondu.prototype.getImages = function(){
				var tmp = [];
				if(document.getElementsByClassName){
					tmp = document.getElementsByClassName('slideshow');
				}
				else{
					var i=0;
					while(document.getElementsByTagName('*')[i]){
						if(document.getElementsByTagName('*')[i].className=='slideshow'){
							tmp.push(document.getElementsByTagName('*')[i]);
						}
						i++;
					}
				}
				var j=tmp.length;
				while(j--){
					if(tmp[j].filters){
						tmp[j].style.width = tmp[j].style.width || tmp[j].offsetWidth+'px';
						tmp[j].style.filter = 'alpha(opacity=100)';
						tmp[j].opaque = tmp[j].filters[0];
						this.coeff = 1;
					}
					else{
						tmp[j].opaque = tmp[j].style;
					}
				}
				return tmp;
			}
			Fondu.prototype.change = function(sens){
				var prevObj = this.collection[this.courant];
				if(this.encours){
					return false;
				}
				this.encours = true;
				if(sens){
					this.courant++;
					if(this.courant>this.total){
						this.courant = 0;
					}
				}
				else{
					this.courant--;
					if(this.courant<0){
						this.courant = this.total;
					}
				}
				var nextObj = this.collection[this.courant];
				nextObj.style.zIndex = 50;
				var tmpOp = 100;
				var that = this;
				var timer = setInterval(function(){
					if(tmpOp<0){
						clearInterval(timer);
						timer = null;
						prevObj.opaque.opacity = 0;
						nextObj.style.zIndex = 100;
						prevObj.style.zIndex = 0;
						prevObj.opaque.opacity = 100 / that.coeff;
						that.encours = false;
					}
					else{
						prevObj.opaque.opacity = tmpOp / that.coeff;
						tmpOp -= 5;
					}
				}, 25);
			}
			function defil(){
				var boutons = document.getElementsByTagName('input');
				if(defilement){
					clearInterval(defilement);
					defilement = false;
					/*boutons[1].value = 'Défilement automatique';*/
				}
				else{
					monFondu.change(true);
					defilement = setInterval(function(){monFondu.change(true);},4000);
					/*boutons[1].value = 'Stopper le défilement';*/
				}
				//boutons[0].disabled = !boutons[0].disabled;
				//boutons[2].disabled = !boutons[2].disabled;
			}

