var bOver_MenuRoot = false;
var bOver_Menu = false;
var bOver_SubMenu = false;

leftBorderSize = "10px";
rightBorderSize = "10px";
topBorderSize = "10px";
bottomBorderSize = "10px";
		
leftBorderSize2 = "30px";
rightBorderSize2 = "30px";
topBorderSize2 = "30px";
bottomBorderSize2 = "30px";		
		
function form_recherche_addEvent()
{
	if ($("form_recherche") && $("motclefs"))
	{
		$("form_recherche").onsubmit = function()
		{
			/*if (trim($("motclefs").value).length < 3)
			{
				alert("Vous devez indiquer au minimum 3 caractères pour votre recherche");
				return false;
			}*/
			
			return true;
		}
	}
	else
		setTimeout("form_recherche_addEvent();", 250);
}

form_recherche_addEvent();		
		
function parmarques_build()
{
	// Menu des marques	
		
	oMenu = document.createElement("div");
	oMenu.setAttribute("id", "menu_parmarques");
	oMenu.style.display = "none";
	oMenu.style.position = "absolute";
	oMenu.style.width = "auto";
	oMenu.style.height = "auto";

	oTable = document.createElement("table");
	oTable.setAttribute("cellpadding", "0");
	oTable.setAttribute("cellspacing", "0");
	oTable.style.position = "relative";
	oTable.style.zIndex = "10";

	oTBody = document.createElement("tbody");
	
	oTopTr = document.createElement("tr");
	oTopTr.setAttribute("valign", "top");

	oTopLeftTd = document.createElement("td");
	oTopLeftTd.style.width = leftBorderSize;
	oTopLeftTd.style.height = topBorderSize;
	oTopLeftTd.style.backgroundImage = "url(images/common/parmarques/top_left.png)";

	oTopTd = document.createElement("td");
	oTopTd.style.width = "auto";
	oTopTd.style.height = topBorderSize;
	oTopTd.style.backgroundImage = "url(images/common/parmarques/top.png)";
	oTopTd.style.backgroundRepeat = "repeat-x";

	oTopRightTd = document.createElement("td");
	oTopRightTd.style.width = rightBorderSize;
	oTopRightTd.style.height = leftBorderSize;
	oTopRightTd.style.backgroundImage = "url(images/common/parmarques/top_right.png)";

	oLeftTd = document.createElement("td");
	oLeftTd.style.width = leftBorderSize;
	oLeftTd.style.height = "auto";
	oLeftTd.style.backgroundImage = "url(images/common/parmarques/left.png)";
	oLeftTd.style.backgroundRepeat = "repeat-y";
	
	oMiddleTr = document.createElement("tr");
	oMiddleTr.setAttribute("valign", "top");

	oInnerTd = document.createElement("td");
	oInnerTd.style.width = "auto";
	oInnerTd.style.height = "auto";
	oInnerTd.style.backgroundImage = "url(images/common/parmarques/inner.png)";
	oInnerTd.style.backgroundRepeat = "repeat";
	
	oInnerDiv = document.createElement("div");
	oInnerDiv.setAttribute("id", "menu_parmarques_inner");
	oInnerDiv.style.width = "auto";
	oInnerDiv.style.height = "auto";
	oInnerDiv.style.lineHeight = "20px";
	oInnerDiv.style.margin = "-10px";
	oInnerDiv.style.position = "relative";
	oInnerDiv.style.zIndex = "20";

	oRightTd = document.createElement("td");
	oRightTd.style.width = rightBorderSize;
	oRightTd.style.height = "auto";
	oRightTd.style.backgroundImage = "url(images/common/parmarques/right.png)";
	oRightTd.style.backgroundRepeat = "repeat-y";
	
	oBottomTr = document.createElement("tr");
	oBottomTr.setAttribute("valign", "top");

	oBottomLeftTd = document.createElement("td");
	oBottomLeftTd.style.width = leftBorderSize;
	oBottomLeftTd.style.height = bottomBorderSize;
	oBottomLeftTd.style.backgroundImage = "url(images/common/parmarques/bottom_left.png)";

	oBottomTd = document.createElement("td");
	oBottomTd.style.width = "auto";
	oBottomTd.style.Height = bottomBorderSize;
	oBottomTd.style.backgroundImage = "url(images/common/parmarques/bottom.png)";
	oBottomTd.style.backgroundRepeat = "repeat-x";

	oBottomRightTd = document.createElement("td");
	oBottomRightTd.style.width = rightBorderSize;
	oBottomRightTd.style.height = bottomBorderSize;
	oBottomRightTd.style.backgroundImage = "url(images/common/parmarques/bottom_right.png)";
	
	document.body.appendChild(oMenu);
	oMenu.appendChild(oTable);
	oTable.appendChild(oTBody);
	oTBody.appendChild(oTopTr);
	oTopTr.appendChild(oTopLeftTd);
	oTopTr.appendChild(oTopTd);
	oTopTr.appendChild(oTopRightTd);
	oTBody.appendChild(oMiddleTr);
	oMiddleTr.appendChild(oLeftTd);
	oMiddleTr.appendChild(oInnerTd);
	oInnerTd.appendChild(oInnerDiv);
	oMiddleTr.appendChild(oRightTd);
	oTBody.appendChild(oBottomTr);
	oBottomTr.appendChild(oBottomLeftTd);
	oBottomTr.appendChild(oBottomTd);
	oBottomTr.appendChild(oBottomRightTd);
	
	// Menu des produits
	
	oPMenu = document.createElement("div");
	oPMenu.setAttribute("id", "menu_parmarques_produits");
	oPMenu.style.display = "none";
	oPMenu.style.position = "absolute";
	oPMenu.style.width = "auto";
	oPMenu.style.height = "auto";

	oPTable = document.createElement("table");
	oPTable.setAttribute("cellpadding", "0");
	oPTable.setAttribute("cellspacing", "0");
	oPTable.style.position = "relative";
	oPTable.style.zIndex = "10";

	oPTBody = document.createElement("tbody");
	
	oPTopTr = document.createElement("tr");
	oPTopTr.setAttribute("valign", "top");

	oPTopLeftTd = document.createElement("td");
	oPTopLeftTd.style.width = leftBorderSize;
	oTopLeftTd.style.height = topBorderSize;
	oPTopLeftTd.style.backgroundImage = "url(images/common/parmarques/top_left.png)";

	oPTopTd = document.createElement("td");
	oPTopTd.style.width = "auto";
	oPTopTd.style.height = topBorderSize;
	oPTopTd.style.backgroundImage = "url(images/common/parmarques/top.png)";
	oPTopTd.style.backgroundRepeat = "repeat-x";

	oPTopRightTd = document.createElement("td");
	oPTopRightTd.style.width = rightBorderSize;
	oPTopRightTd.style.height = leftBorderSize;
	oPTopRightTd.style.backgroundImage = "url(images/common/parmarques/top_right.png)";

	oPLeftTd = document.createElement("td");
	oPLeftTd.style.width = leftBorderSize;
	oPLeftTd.style.height = "auto";
	oPLeftTd.style.backgroundImage = "url(images/common/parmarques/left.png)";
	oPLeftTd.style.backgroundRepeat = "repeat-y";
	
	oPMiddleTr = document.createElement("tr");
	oPMiddleTr.setAttribute("valign", "top");

	oPInnerTd = document.createElement("td");
	oPInnerTd.style.width = "auto";
	oPInnerTd.style.height = "auto";
	oPInnerTd.style.backgroundImage = "url(images/common/parmarques/inner.png)";
	oPInnerTd.style.backgroundRepeat = "repeat";
	
	oPInnerDiv = document.createElement("div");
	oPInnerDiv.setAttribute("id", "menu_parmarques_pinner");
	oPInnerDiv.style.width = "auto";
	oPInnerDiv.style.height = "auto";
	oPInnerDiv.style.lineHeight = "20px";
	oPInnerDiv.style.margin = "-10px";
	oPInnerDiv.style.position = "relative";
	oPInnerDiv.style.zIndex = "20";

	oPRightTd = document.createElement("td");
	oPRightTd.style.width = rightBorderSize;
	oPRightTd.style.height = "auto";
	oPRightTd.style.backgroundImage = "url(images/common/parmarques/right.png)";
	oPRightTd.style.backgroundRepeat = "repeat-y";
	
	oPBottomTr = document.createElement("tr");
	oPBottomTr.setAttribute("valign", "top");

	oPBottomLeftTd = document.createElement("td");
	oPBottomLeftTd.style.width = leftBorderSize;
	oPBottomLeftTd.style.height = bottomBorderSize;
	oPBottomLeftTd.style.backgroundImage = "url(images/common/parmarques/bottom_left.png)";

	oPBottomTd = document.createElement("td");
	oPBottomTd.style.width = "auto";
	oPBottomTd.style.Height = bottomBorderSize;
	oPBottomTd.style.backgroundImage = "url(images/common/parmarques/bottom.png)";
	oPBottomTd.style.backgroundRepeat = "repeat-x";

	oPBottomRightTd = document.createElement("td");
	oPBottomRightTd.style.width = rightBorderSize;
	oPBottomRightTd.style.height = bottomBorderSize;
	oPBottomRightTd.style.backgroundImage = "url(images/common/parmarques/bottom_right.png)";
	
	document.body.appendChild(oPMenu);
	oPMenu.appendChild(oPTable);
	oPTable.appendChild(oPTBody);
	oPTBody.appendChild(oPTopTr);
	oPTopTr.appendChild(oPTopLeftTd);
	oPTopTr.appendChild(oPTopTd);
	oPTopTr.appendChild(oPTopRightTd);
	oPTBody.appendChild(oPMiddleTr);
	oPMiddleTr.appendChild(oPLeftTd);
	oPMiddleTr.appendChild(oPInnerTd);
	oPInnerTd.appendChild(oPInnerDiv);
	oPMiddleTr.appendChild(oPRightTd);
	oPTBody.appendChild(oPBottomTr);
	oPBottomTr.appendChild(oPBottomLeftTd);
	oPBottomTr.appendChild(oPBottomTd);
	oPBottomTr.appendChild(oPBottomRightTd);
	
	// Remplissage du menu des marques
	
	 parmarques_fillmarques();
	
	// Evenements
	
	 $("block_parmarques").onmouseover = function() 
	 {
		 bOver_MenuRoot = true;
		 parmarques_position();
		 $("menu_parmarques").style.display = "block";
	 }
	 
	 $("block_parmarques").onmouseout = function() 
	 {
		 bOver_MenuRoot = false;
		 parmarques_check();
	 }
	 
	 $("menu_parmarques").onmouseover = function() 
	 {
		 bOver_Menu = true;
	 }
	 
	 $("menu_parmarques").onmouseout = function() 
	 {
		 bOver_Menu = false;
		 parmarques_check();
	 }
	 
	 $("menu_parmarques_produits").onmouseover = function() 
	 {
		 bOver_SubMenu = true;
	 }
	 
	 $("menu_parmarques_produits").onmouseout = function() 
	 {
		 bOver_SubMenu = false;
		 parmarques_check();
	 }
}

function parmarques_fillmarques()
{
	// Remplisage du menu des Marques
	
	$("menu_parmarques_inner").innerHTML = "";
	
	bFirstRow = true;
	
	oaRows = new Array();
	
	for (i = 0 ; i < aMarques.length ; i++)
	{
		oaRows[i] = document.createElement("div");
		oaRows[i].innerHTML = "<a id=\"block_parmarques_a" + i + "\" class=\"block_parmarques_a\" href=\"" + aMarques[i]["href"] + "\">" + aMarques[i]["value"] + "</a>";

		// Evenements
		
		oaRows[i].setAttribute("id", i);

		oaRows[i].onmouseover = function() 
		{
			parmarques_produits_position(this);
			parmarques_fillmarquesproduits(this.id);
			$("menu_parmarques_produits").style.display = "block";
		}
		
		oaRows[i].onmouseout = function() 
		{
			parmarques_check();
		}

		oaRows[i].style.height = "20px";
		oaRows[i].style.lineHeight = "20px";		
		oaRows[i].style.zIndex = "30";	
		oaRows[i].style.position = "relative";	
		
		$("menu_parmarques_inner").appendChild(oaRows[i]);
	}
}

function parmarques_fillmarquesproduits(rownum)
{
	// Remplisage du menu des Produits
	
	$("menu_parmarques_pinner").innerHTML = "";
	
	bFirstRow = true;
	
	oaRows = new Array();
	for (i = 0 ; i < aMarques[rownum]["produits"].length ; i++)
	{
		oaRows[i] = document.createElement("div");
		oaRows[i].innerHTML = "<a class=\"block_parmarques_a\" href=\"" + aMarques[rownum]["produits"][i]["href"] + "\">" + aMarques[rownum]["produits"][i]["value"] + "</a>";


		oaRows[i].style.height = "20px";
		oaRows[i].style.lineHeight = "20px";		
		oaRows[i].style.zIndex = "30";	
		oaRows[i].style.position = "relative";	
		
		$("menu_parmarques_pinner").appendChild(oaRows[i]);
	}
}


function parmarques_check(timecheck)
{
	if (timecheck)
	{
		if (bOver_MenuRoot == false && bOver_Menu == false && bOver_SubMenu == false)
		{
			$("menu_parmarques").style.display = "none";
			$("menu_parmarques_produits").style.display = "none";
		}
		else if (bOver_Menu == false && bOver_SubMenu == false)
		{
			$("menu_parmarques_produits").style.display = "none";
		}
	}
	else
		setTimeout("parmarques_check(true);", 50);
}

function parmarques_position()
{
	coord = cumulativeOffset($("block_parmarques"));
	size = getDimensions($("block_parmarques"));
	$("menu_parmarques").style.left = (coord["left"] + size["width"]) + "px";
	$("menu_parmarques").style.top = coord["top"] + "px";
}

function parmarques_produits_position(element)
{
	coord = cumulativeOffset(element);
	size = getDimensions(element);
	if (document.all)	// IE Hack
		$("menu_parmarques_produits").style.left = (coord["left"] + size["width"]  + (parseInt(rightBorderSize))) + "px";	
	else
		$("menu_parmarques_produits").style.left = (coord["left"] + size["width"]) + "px";
	
	$("menu_parmarques_produits").style.top = (coord["top"]) + "px";	
}

function image_popup_build()
{
	oPopup = document.createElement("div");
	oPopup.setAttribute("id", "image_popup");
	oPopup.style.display = "none";
	oPopup.style.position = "absolute";
	oPopup.style.width = "auto";
	oPopup.style.height = "auto";

	oTable = document.createElement("table");
	oTable.setAttribute("cellpadding", "0");
	oTable.setAttribute("cellspacing", "0");
	oTable.style.position = "relative";
	oTable.style.zIndex = "100";

	oTBody = document.createElement("tbody");
	
	oTopTr = document.createElement("tr");
	oTopTr.setAttribute("valign", "top");

	oTopLeftTd = document.createElement("td");
	oTopLeftTd.style.width = leftBorderSize2;
	oTopLeftTd.style.height = topBorderSize2;
	oTopLeftTd.style.backgroundImage = "url(images/common/image_popup/top_left.png)";
	
	oTopTd = document.createElement("td");
	oTopTd.style.width = "auto";
	oTopTd.style.height = topBorderSize2;
	oTopTd.style.backgroundImage = "url(images/common/image_popup/top.png)";
	oTopTd.style.backgroundRepeat = "repeat-x";

	oTopRightTd = document.createElement("td");
	oTopRightTd.style.width = rightBorderSize2;
	oTopRightTd.style.height = leftBorderSize2;
	oTopRightTd.style.backgroundImage = "url(images/common/image_popup/top_right.png)";

	oLeftTd = document.createElement("td");
	oLeftTd.style.width = leftBorderSize2;
	oLeftTd.style.height = "auto";
	oLeftTd.style.backgroundImage = "url(images/common/image_popup/left.png)";
	oLeftTd.style.backgroundRepeat = "repeat-y";
	
	oMiddleTr = document.createElement("tr");
	oMiddleTr.setAttribute("valign", "top");

	oInnerTd = document.createElement("td");
	oInnerTd.style.width = "auto";
	oInnerTd.style.height = "auto";
	oInnerTd.style.backgroundImage = "url(images/common/image_popup/inner.png)";
	oInnerTd.style.backgroundRepeat = "repeat";
	
	oInnerDiv = document.createElement("div");
	oInnerDiv.setAttribute("id", "image_popup_inner");
	oInnerDiv.style.width = "auto";
	oInnerDiv.style.height = "auto";
	oInnerDiv.style.margin = "0px";
	oInnerDiv.style.position = "relative";
	oInnerDiv.style.zIndex = "20";
	
	oInnerTitle = document.createElement("div");
	oInnerTitle.setAttribute("id", "image_popup_inner_title");
	oInnerTitle.style.width = "auto";
	oInnerTitle.style.height = "auto";
	oInnerTitle.style.margin = "0px 0px 5px 0px";
	oInnerTitle.style.padding = "0px";
	
	oInnerImg = document.createElement("img");
	oInnerImg.setAttribute("id", "image_popup_inner_img");
	oInnerImg.setAttribute("alt", ""); 
	//oInnerImg.setAttribute("src", "#"); // index.php autocall bug
	oInnerImg.style.width = "auto";
	oInnerImg.style.height = "auto";
	oInnerImg.style.margin = "0px";
	oInnerImg.style.padding = "0px";

	oRightTd = document.createElement("td");
	oRightTd.style.width = rightBorderSize2;
	oRightTd.style.height = "auto";
	oRightTd.style.backgroundImage = "url(images/common/image_popup/right.png)";
	oRightTd.style.backgroundRepeat = "repeat-y";
	
	oBottomTr = document.createElement("tr");
	oBottomTr.setAttribute("valign", "top");

	oBottomLeftTd = document.createElement("td");
	oBottomLeftTd.style.width = leftBorderSize2;
	oBottomLeftTd.style.height = bottomBorderSize2;
	oBottomLeftTd.style.backgroundImage = "url(images/common/image_popup/bottom_left.png)";

	oBottomTd = document.createElement("td");
	oBottomTd.style.width = "auto";
	oBottomTd.style.Height = bottomBorderSize2;
	oBottomTd.style.backgroundImage = "url(images/common/image_popup/bottom.png)";
	oBottomTd.style.backgroundRepeat = "repeat-x";

	oBottomRightTd = document.createElement("td");
	oBottomRightTd.style.width = rightBorderSize2;
	oBottomRightTd.style.height = bottomBorderSize2;
	oBottomRightTd.style.backgroundImage = "url(images/common/image_popup/bottom_right.png)";
	
	document.body.appendChild(oPopup);
	oPopup.appendChild(oTable);
	oTable.appendChild(oTBody);
	oTBody.appendChild(oTopTr);
	oTopTr.appendChild(oTopLeftTd);
	oTopTr.appendChild(oTopTd);
	oTopTr.appendChild(oTopRightTd);
	oTBody.appendChild(oMiddleTr);
	oMiddleTr.appendChild(oLeftTd);
	oMiddleTr.appendChild(oInnerTd);
	oInnerTd.appendChild(oInnerDiv);
	oInnerDiv.appendChild(oInnerTitle);
	oInnerDiv.appendChild(oInnerImg);
	oMiddleTr.appendChild(oRightTd);
	oTBody.appendChild(oBottomTr);
	oBottomTr.appendChild(oBottomLeftTd);
	oBottomTr.appendChild(oBottomTd);
	oBottomTr.appendChild(oBottomRightTd);
}

function image_popup_position()
{
	if ($("image_popup_inner_img").complete)
	{
		size = getDimensions($("image_popup"));
	
		var iInnerWidth = document.documentElement.clientWidth;
		var iInnerHeight = document.documentElement.clientHeight;
		
		var aScrollXY = getPageScrollXY();
		
		$("image_popup").style.left = (iInnerWidth + aScrollXY["x"] - size["width"]) + "px";
		$("image_popup").style.top = (iInnerHeight + aScrollXY["y"] - size["height"]) + "px";
		
		$("image_popup").style.display = "block";
	}
	else
		setTimeout("image_popup_position();", 50);
}

function image_popup_show(title, filename)
{
	if ($("image_popup_inner_title") && $("image_popup_inner_img")) 
	{
		$("image_popup_inner_title").innerHTML = title;
		$("image_popup_inner_img").setAttribute("src", "");
		$("image_popup_inner_img").setAttribute("src", filename);
			
		image_popup_position();	
	}
}

function image_popup_hide()
{
	$("image_popup").style.display = "none";
}

function moncompte_addEvents()
{
	if ($("login_email") && $("login_mot_passe") && $("login_ok"))
	{
		$("login_ok").onsubmit = function ()
		{
			
		}
	}
	else
		setTimeout("moncompte_addEvents();", 250);
}

moncompte_addEvents();

iActivationTime = 2000;
var oStartDate = new Date();

function addPopupImagesEvents()
{
	var aPopupImages = getElementsByClassName("imagepopup");

	for (var i in aPopupImages)
	{
		aPopupImages[i].onmouseover = imagepopup_onmouseover;			
		aPopupImages[i].onmouseout = imagepopup_onmouseout;			
	}
	
	var oCurrentDate = new Date();
	
	if (oCurrentDate.getTime() < (oStartDate.getTime() + iActivationTime))
		setTimeout("addPopupImagesEvents();", 250);
}

function imagepopup_onmouseover()
{
	if (this.tagName.toLowerCase() == "a")
	{							
		for (i in this.childNodes)
		{
			if (this.childNodes[i].nodeType == 1) //  Node.ELEMENT_NODE
			{
				if (this.childNodes[i].tagName.toLowerCase() == "img")
				{
					if (this.childNodes[i].complete)
					{
						if (this.childNodes[i].src.indexOf("blank.gif") == (-1))
						{
							if (this.childNodes[i].src.indexOf("imageproduit") != (-1))
							{
								image_popup_show("", "images/db/imageproduit/350_350/" + getFileName(this.childNodes[i].src));
							}
						}
					}
				}
				else if (this.childNodes[i].tagName.toLowerCase() == "div")
				{
					if (this.childNodes[i].style.backgroundImage.indexOf("blank.gif") == (-1))
					{						
						if (this.childNodes[i].style.backgroundImage.indexOf("imageproduit") != (-1))
						{
							var sUrl = this.childNodes[i].style.backgroundImage.replace("url(", "");
							sUrl = sUrl.replace(")", "");
							image_popup_show("", "images/db/imageproduit/350_350/" + getFileName(sUrl));						
						}
					}
				}
			}
		}
	}
	else if (this.tagName.toLowerCase() == "img")
	{
		if (this.childNodes[i].src.indexOf("blank.gif") == (-1))
		{
			if (this.src.indexOf("imageproduit") != (-1))
				image_popup_show("", "images/db/imageproduit/350_350/" + getFileName(this.src));
		}
	}
	else if (this.tagName.toLowerCase() == "div")
	{
		if (this.style.backgroundImage.indexOf("blank.gif") == (-1))
		{
			if (this.style.backgroundImage.indexOf("imageproduit") != (-1))
			{
				var sUrl = this.style.backgroundImage.replace("url(", "");
				sUrl = sUrl.replace(")", "");
				image_popup_show("", "images/db/imageproduit/350_350/" + getFileName(sUrl));						
			}
		}
	}
	else
	{
		alert(this.tagName);
	}
}

function imagepopup_onmouseout()
{
	image_popup_hide();
}

addPopupImagesEvents();

// Prototype Functions

function $(element)
{
	if (arguments.length > 1)
	{
		for (var i = 0, elements = [], length = arguments.length; i < length; i++)
		elements.push($(arguments[i]));
		return elements;
	}
	element = document.getElementById(element);
	return (element);
}

function getDimensions(element)
{
    var display = element.style.display;
    if (display != 'none' && display != null) // Safari bug
      return {width: element.offsetWidth, height: element.offsetHeight};

    // All *Width and *Height properties give 0 on elements with display none,
    // so enable the element temporarily
    var els = element.style;
    var originalVisibility = els.visibility;
    var originalPosition = els.position;
    var originalDisplay = els.display;
    els.visibility = 'hidden';
    els.position = 'absolute';
    els.display = 'block';
    var originalWidth = element.clientWidth;
    var originalHeight = element.clientHeight;
    els.display = originalDisplay;
    els.position = originalPosition;
    els.visibility = originalVisibility;
    return {width: originalWidth, height: originalHeight};
}

function cumulativeOffset(element)
{
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      element = element.offsetParent;
    } while (element);
    return _returnOffset(valueL, valueT);
}

function _returnOffset(l, t)
{
	var result = [l, t];
	result.left = l;
	result.top = t;
	return result;	
}

function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

function getFilePath(sFile)
{
	sPath = sFile.substring(sFile.lastIndexOf("\/"));
	sPath = sFile.replace(sPath, "");
	return sPath;
}

function getFileName(sFile)
{
	sPath = sFile.substring(sFile.lastIndexOf("\/"));
	sPath = sPath.replace("\/", "");
	return sPath;
}

function getPageScrollXY()
{
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' )
	{
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	}
	else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
	{
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	}
	else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
	{
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	
	var aXY = new Array();	
	aXY["x"] = scrOfX; 
	aXY["y"] = scrOfY; 
	
	return (aXY);
}

function trim(myString)
{
	return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
} 