//<script>
//alert('Lib.js included succesfully');
/**************************************
Function : Open New Window function   *
Author   : Martin Bélanger            *
***************************************
parameters :
	-Page to Open
	-Height of the new window
	-Width of the new window
	-Name of the new window (optional)

syntax : 

	WinOpen('fichier',H,W[,WinName])
*/


function WinOpen(fichier,H,W,WinName)
{
	if (WinName == '')
	{
		WinName = 'popwin'
	}
	var avwidth = screen.availWidth;
	var avheight = screen.availHeight;
	avwidth = (avwidth - W)/2;
	avheight = (avheight - H)/2;
	var win = window.open(fichier,WinName,"scrollBars=yes,height="+H+",width="+W+",top="+avheight+",left="+avwidth+" resizable=yes")
	win.focus();
}

function WinOpenFull(fichier,WinName)
{
	if (WinName == '')
	{
		WinName = 'popwin'
	}
	var avwidth = screen.availWidth;
	var avheight = screen.availHeight;
	avwidth = avwidth - 50;
	avheight = avheight - 50;
	var win = window.open(fichier,WinName,"scrollBars=yes,height="+avheight+",width="+avwidth+",top=10,left=10 resizable=yes")
	win.focus();
}

//---------------------------------------------------------------------------------------------------------------
//Regular expr to enforce certain characters >> Author: Ramzi Abu-Abed

function isAlphaNumeric(strValid)
{
	strValid.search(/^[A-Z0-9a-z]+$/)!=-1?state = true:state = false;
	return state;
}
//---------------------------------------------------------------------------------------------------------------
//Enfore string length >> Author: Ramzi Abu-Abed
//Parameters: strValid: String to validate -- strMinLen: Min allowed characters -- strMaxLen: Max allowed characters
function isLengthOk(strValid,strMinLen,strMaxLen)
{
	!(strValid)?state = false:strValid.length > strMaxLen || strValid.length < strMinLen?state = false:state=true;
	return state;
}

//---------------------------------------------------------------------------------------------------------------
//Regular expr to enforce a number >> Author: Talal Chaihaytli
function IsThereNumber(strValue)
	{	
	  (strValue.replace(/[0-9]{1}/,'')==strValue)?state =false :state = true;
	  return state;	
	}

//---------------------------------------------------------------------------------------------------------------
//Regular expr to enforce a characters >> Author: Talal Chaihaytli
function IsThereChar(strValue)
{	
  (strValue.replace(/[a-zA-Z]{1}/,'')==strValue)?state =false :state = true;
  return state;	
}

//---------------------------------------------------------------------------------------------------------------
//Swap Images (ie only, faster than MM_swapImgRestore)

function  AlterImage(objImg,newImg)
{	
	var img = new Image()
	img.src = newImg
	objImg.src = img.src
}
//---------------------------------------------------------------------------------------------------------------

/*Swap Images functions*/
function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j < imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}
//---------------------------------------------------------------------------------------------------------------
/**************************************
Function : trim function like VB      *
Author   : Martin Bélanger            *
***************************************
removes leading and trailing spaces
*/
function trim(str)
	{
		str = this != window? this : str;
		return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
	}
//---------------------------------------------------------------------------------------------------------------
/**************************************
Function : round function like VB     *
Author   : Martin Bélanger            *
**************************************/
function round(number,X) 
{
	// rounds number to X decimal places, defaults to 2
	X = (!X ? 2 : X);
	return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}
//---------------------------------------------------------------------------------------------------------------
/*********************************************
Function : FormatNumber function like VB     *
Author   : Martin Bélanger					 *
*********************************************/
function FormatNumber(lnumber,lnbDec)
{
	if (!lnbDec)
		lnbDec = 2
		
	lnumber = round(lnumber,lnbDec)
	lnumber = lnumber.toString()
	lnumber = lnumber.replace(',','.')
	
	if(lnumber.indexOf('.') == -1)
		lnumber = lnumber + '.'
		
	for(i=0;i<lnbDec;i++)
	{
		if(lnumber.charAt((lnumber.indexOf('.')+1)+i) == '')
			lnumber = lnumber + '0'
	}
	return lnumber
}
//---------------------------------------------------------------------------------------------------------------
/***********************************************************
Function : Verify if at least One check box is checked     *
Author   : Martin Bélanger								   *
***********************************************************/

function AtLeastOneChecked(objFrame, objCheckAll)
{
	var nb=0;
	for (i=1; i<objFrame.length && nb == 0; i++)
	{
		
		if (objFrame(i).checked && objFrame(i).name != objCheckAll.name)
		{
			nb++;
			break;
		}
	}
	if (nb==0)
		return false;
	else
		return true;
}

function show(id) 
{
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	ns5 = (navigator.appName == "Netscape" || navigator.appVersion>=5)? true:false	
	if(ns4) document.layers[id].visibility = "show"
	else 
		if(ie4 && document.all[id]) document.all[id].style.visibility = "visible"
		else if(ns5) document.getElementById(id).style.visibility = "visible"
}

function showInner(id_outer,id_inner)//Author: Ramzi purpose: Created to access div within a div for Netscrap 4.75
{
	if(document.layers)
	 document.layers[id_outer].document.layers[id_inner].visibility = "show";
}

function hide(id) 
{	
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	ns5 = (navigator.appName == "Netscape" || navigator.appVersion>=5)? true:false
	if(ns4) document.layers[id].visibility = "hide"
	else 
		if(ie4 && document.all[id]) document.all[id].style.visibility = "hidden"
		else if(ns5) document.getElementById(id).style.visibility = "hidden"
}

function hideInner(id_outer,id_inner)//Author: Ramzi purpose: Created to access div within a div for Netscrap 4.75
{	
	if(document.layers)
	  document.layers[id_outer].document.layers[id_inner].visibility = "hidden";

}

function IsNumeric(number)
{
	var IsNumeric = true
	
	if(isNaN(Math.round(number)))
		IsNumeric = false
	
	if(number.length==0)	
		IsNumeric = false
	
	return(IsNumeric)
}

function IsEmail(strEmail) 
{	
	strEmail = trim(strEmail)
	if (strEmail.indexOf("@") < 1 || strEmail.indexOf(".") == -1 || (strEmail.lastIndexOf(".")-strEmail.indexOf("@") <= 1) || parseInt(strEmail.indexOf(".") + 1) == strEmail.length || strEmail.indexOf(" ") > -1)
	{
		return(false)
	}
	else
	{
		return(true)
	}
}


function layerWrite(id,nestref,text) 
{
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	ns5 = (navigator.appName == "Netscape" || navigator.appVersion>=5)? true:false
	if (ns4) {	
		var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document
		lyr.open()
		lyr.write(text)		
		lyr.close()
	}
	else if (ie4) document.all[id].innerHTML = text
	else if (ns5) document.getElementById(id).innerHTML = text
}




/*-----------------------------------------------------------------------------
' Prototype Name		: IsIn
' Constructor affected	: String, Number
' Exemple				: http://rcastaging.rideau.com/sample/in.asp
'
' MODIFICATIONS
' DATE			AUTHOR			ACTION
' 2002.04.08	Frédéric Vachon	Creation of prototye
'
'
'----------------------------------------------------------------------------*/
String.prototype.isIn =	function(strIsIn)
						{
							var arrIn = strIsIn.split(",")
							for(var i = 0; i < arrIn.length; i++)
								if(this == arrIn[i])
									return(true)
							return(false)		
						}
						
						
Number.prototype.isIn =	function(strIsIn)
						{
							var arrIn = strIsIn.split(",")
							for(var i = 0; i < arrIn.length; i++)
								if(this == arrIn[i])
									return(true)
							return(false)		
						}

/*-----------------------------------------------------------------------------
' Prototype Name		: toCharCode
' Constructor affected	: String
' Description			: Opposite to fromCharCode()
' Exemple				: http://rcastaging.rideau.com/sample/toCharCode.asp
'
' MODIFICATIONS
' DATE			AUTHOR			ACTION
' 2002.04.08	Frédéric Vachon	Creation of prototye
'
'
'----------------------------------------------------------------------------*/
String.prototype.toCharCode =	function (){return(this.charCodeAt(0).toString(10));}

//---------------------------------------------------------------------------------------------------------------
/********************************************************************
Function : enable/disable clicks of links and buttons on a page	    *
		initClickPrevention()				    *
		stopClickPrevention ()				    *
Author   : 							    *
*********************************************************************/
function clickHandler (evt) 
	{
	  if (document.layers)
	    return false;
	  else if (evt.stopPropagation) 
	  {
	    evt.stopPropagation();
	    evt.preventDefault();
	  }
	  else if (window.event)
	    return false;
	}
	
function initClickPrevention () 
	{
	  var	MAC = navigator.userAgent.indexOf("Mac") > -1 ? 1 : 0;

	  if (document.layers) 
	  {
	    window.captureEvents(Event.CLICK);
	    window.onclick = clickHandler;
	  }
	  else if (document.all && !document.getElementById)
	    document.onclick = clickHandler;
	  else if (document.all && !MAC)
	    document.attachEvent('onclick', clickHandler);
	  else if (document.addEventListener)
	    document.addEventListener('click', clickHandler, true);
	}
	
function stopClickPrevention () 
	{
		var	MAC = navigator.userAgent.indexOf("Mac") > -1 ? 1 : 0;
	 if (document.layers) 
	  {
	    window.releaseEvents(Event.CLICK);
	    window.onclick = null;
	  }
	  else if (document.all && !document.getElementById)
	    document.onclick = null;
	  else if (document.all && !MAC)
	    document.detachEvent('onclick', clickHandler);
	  else if (document.addEventListener)
	    document.removeEventListener('click', clickHandler, true);
	}
	

function RedirectURL(strURL){
	with (document.frmMain){
		if(document.frmMain.hidPosition)
			document.frmMain.hidPosition.value='';
		if(document.frmMain.hidCurrentPageOrder)
			document.frmMain.hidCurrentPageOrder.value='';
		action = strURL;submit();
	}		
}
function ChangeLang(CurrentLang){		
	document.frmMain.hidLang.value = (CurrentLang == 'EN')?'FR':'EN';RedirectURL('#');
}
function ChangeLangEnter(CurrentLang){
	document.frmMain.hidLang.value = CurrentLang;
}
function ShowCart(){
	with(document.frmMain){action = "ShowCart.asp";submit();}
}
function AddToMyFavorites(){
	var objSelectedForm = eval("document.frmHidProductInformation" + ArrAddToCartNum[0]) ; 	
	with(document.frmMain){hidProductCode.value = objSelectedForm.hidProductCode.value;action = "AddToMyFavorites.asp";method = "post";submit();}
}	
function OnlineCatalog(){
	with(document.frmMain){
		hidPosition.value = "";action = "Catalog.asp";method = "post";submit();
	}				
}
function showEuro(which){
	show("divEuroPrice"+which);
}
function popUp(url) {
	newWin=window.open(url,"win",'toolbar=1,location=1,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=700,height=500');
}