
    function ChangePage(pageNum)
    {
    
        document.getElementById("ListArt1_PageNumber").value = pageNum;
    }

    function checkInteger(txt){ 
      if  (txt.value.toString().search(/^-?[0-9]+$/) == 0){
        return true;
      }
      else{
        alert("incorrect value");
        txt.focus();
        return false;
      }
    } 

//=========================================
//functions for catalogue menu
//=========================================

		var cm=null;
		document.onclick = new Function("show(null)")
		
		function getPos(el,sProp) {
			var iPos = 0
			
			while (el!=null) {
				iPos+=el["offset" + sProp]
				el = el.offsetParent
			}
			return iPos
		
		}
		
		function show(m,src_event) {
			var el = document.getElementById("td_left")
			if (document.getElementById(m)) {
				if((document.getElementById(m).style.display=='' && src_event=='resize_event')||(src_event=='click_event')) {
					document.getElementById(m).style.display='';
					document.getElementById(m).style.left =  (getPos(el,"Left") - document.getElementById(m).offsetWidth) + "px" 
					
				}
			}
			if ((document.getElementById(m)!=cm) && (cm)) cm.style.display='none'
			cm=document.getElementById(m)
		}

//=========================================
//functions for crossbox
//=========================================

var inactiveEntry = '';
var activeEntry = '';
var activeEntryContent = '';
tabArray = new Array();

function switchBox(whichBox) {
	
	if (activeEntry) {
		document.getElementById(activeEntry).style.visibility = "hidden";
		document.getElementById(activeEntry).style.display = "none";
		document.getElementById(activeEntryContent).style.visibility = "hidden";
		document.getElementById(activeEntryContent).style.display = "none";
		if (activeEntry.indexOf("worldwide")!= -1) {
			document.getElementById('crossbox_world').style.visibility = "hidden";
			document.getElementById('crossbox_world').style.display = "none";
		}
		document.getElementById(inactiveEntry).style.visibility = "visible";
		document.getElementById(inactiveEntry).style.display = "block";
		if (navigator.appVersion.indexOf("MSIE") == -1) {
			document.getElementById(inactiveEntry).style.height = 17 + "px";
			document.getElementById(inactiveEntry).style.borderTop = "solid 1px #262626";
			document.getElementById(inactiveEntry).style.paddingTop = "2px";
		}
	}
	var myEntry = whichBox + "_a";
	var myEntryContent = whichBox + "_b";
	activeEntry = myEntry;
	activeEntryContent = myEntryContent;
	inactiveEntry = whichBox;
	if (navigator.appVersion.indexOf("MSIE") == -1) {
		document.getElementById(whichBox).style.height = 0 + "px";
		document.getElementById(whichBox).style.border = 0 + "px";
		document.getElementById(whichBox).style.padding = 0 + "px";
	} else {
		document.getElementById(whichBox).style.visibility = "hidden";
		document.getElementById(whichBox).style.display = "none";   
	}
	document.getElementById(activeEntry).style.visibility = "visible";
	document.getElementById(activeEntry).style.display = "block";
	document.getElementById(activeEntryContent).style.visibility = "visible";
	document.getElementById(activeEntryContent).style.display = "block";
	if (whichBox.indexOf("worldwide")!= -1) {
		document.getElementById('crossbox_world').style.visibility = "visible";
		document.getElementById('crossbox_world').style.display = "block";
	}

}

var crossboxInitialized = false;

function initCrossbox(whichCB) {

	var CBnum = tabArray.length;
	for (i=0;i<CBnum;i++) {
		var myEntry = tabArray[i] + "_a";
		var myEntryContent = tabArray[i] + "_b";
		document.getElementById(myEntry).style.visibility = "hidden";
		document.getElementById(myEntry).style.display = "none";
		document.getElementById(myEntryContent).style.visibility = "hidden";
		document.getElementById(myEntryContent).style.display = "none"; 
	}

	if (document.getElementById(whichCB)) {
		var myEntry = whichCB + "_a";
		var myEntryContent = whichCB + "_b";
		activeEntry = myEntry;
		activeEntryContent = myEntryContent;
		inactiveEntry = whichCB;
		document.getElementById(whichCB).style.visibility = "hidden";
		document.getElementById(whichCB).style.display = "none";
		document.getElementById(activeEntry).style.visibility = "visible";
		document.getElementById(activeEntry).style.display = "block";
		document.getElementById(activeEntryContent).style.visibility = "visible";
		document.getElementById(activeEntryContent).style.display = "block";
	}
	//special case for worldwide
	if (whichCB == "worldwide") {
		document.getElementById('crossbox_world').style.visibility = "visible";
		document.getElementById('crossbox_world').style.display = "block";
	}

	crossboxInitialized = true;  
}

//counting tabs for default ibox display
function countTab(whichTab) {
	tabArray[tabArray.length] = whichTab;
}

/**
 * Defines a link reference.
 * @param pTitle Link title.
 * @param pURL for link. Can be URL or javascript: call (optional).
 */
var crossbox_link = function(pTitle, pURL) {
  this.title = pTitle;
  this.url = pURL;
}

function renderLoginArea(pLoggedOutLinks, pLoggedInLinks, pText) {
	var name = getCookie("myAudi.name");
	if (name != null) {
		pText = pText.replace(/\{0\}/, name);
		document.write("<div class=\"crossbox_text\">");
		document.write(pText);
		document.write("</div>");
		for (var i in pLoggedInLinks) {
			renderLink(pLoggedInLinks[i]);
		}
		initCrossbox('login');
	} else {
		for (var i in pLoggedOutLinks) {
			renderLink(pLoggedOutLinks[i]);
		}
	}
}

function renderLink(pLink) {
	document.write("<div class=\"crossbox_link\">");
	if (pLink.url.length > 0) {
		document.write("<a href=\"" + pLink.url + "\">");
	}
	document.write("<img src=\"" + global_staticpath_images + "/arrow_orange.gif\" width=\"9\" height=\"9\" alt=\"&gt;\" class=\"crossbox_arrow\">");
	if (pLink.url.length > 0) {
		document.write("</a>");
	}
	if (pLink.url.length > 0) {
		document.write("<a href=\"" + pLink.url + "\">");
	}
	document.write(pLink.title);
	if (pLink.url.length > 0) {
		document.write("</a>");
	}
	document.write("</div>");
}

/** This variable can be overriden to provide an alternative redirect URL */
var cms4imp_base_sso_redirect_url = location.href;

/**
 * Constructs a SSO redirect URL from the given standard login
 * URL and the contents of cms4imp_base_sso_redirect_url.
 * @param pLoginURL Login URL
 */
function getLoginURL(pLoginURL) {
	var loginURL = pLoginURL.substring(0, pLoginURL.lastIndexOf("redirect_url") + "redirect_url".length);
	loginURL += encodeURIComponent(encodeURIComponent("=" + cms4imp_base_sso_redirect_url));
	return loginURL;
}

/**
 * Functions for the route tab of the crossbox.
 */
function openRoute(pURL, pPartnerID, pStreetDummy, pZipDummy, pCityDummy, pNewWindow) {
	var street	= document.forms["routeform"]["street"].value;
	var zip		= document.forms["routeform"]["zip"].value;
	var city	= document.forms["routeform"]["city"].value;
	
	if (street == pStreetDummy) street = "";
	if (zip == pZipDummy) zip = "";
	if (city == pCityDummy) city = "";
	
	var params = "ID=" + pPartnerID;
	if (street || zip || city) {
		params += "&ZS=" + street;
		params += "&ZP=" + zip;
		params += "&ZO=" + city;
		params += "&BUTTON=SEARCH";
	}
	
	var targetUrl = pURL;
	if (targetUrl.indexOf("?") > 0) {
	  targetUrl += "&" + params;
	}
	else {
	  targetUrl += "?" + params;
	}
	
	if (pNewWindow) {
		fenster=window.open(targetUrl,"Anfahrtsroute","width=639,height=545,top=120,left=210");
		if (typeof(fenster.focus) == "function" || typeof(fenster.focus) == "object"){
			fenster.focus();
		}
	}
	else {
	  window.location = targetUrl;
	}
}

function crossboxRouteSubmitEnter(pField, pEvent, pURL, pPartnerID, pStreetDummy, pZipDummy, pCityDummy, pNewWindow) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (pEvent) keycode = pEvent.which;
	else return true;
	if (keycode == 13) {
		openRoute(pURL, pPartnerID, pStreetDummy, pZipDummy, pCityDummy);
		return false;
	} else {
		return true;
	}
}


			
function hideDivInfo(){
	new Effect.Fade('divInfo',{duration:0.5});
	if (document.getElementById("fondNoir")!= null ){
		new Effect.Fade('fondNoir',{duration:0.5});
	}
}


function showDivInfo(ID, type, lg){
	document.getElementById("divInfo").style.top=230+document.documentElement.scrollTop;
	document.getElementById("divInfoTitle").innerHTML = '';
	document.getElementById("divInfoText").innerHTML = '';

	var resp;
	var ds;
	if (type == 'art'){
		resp = Ajax_Meth.getInfoArt(ID);
	}
	else{
		resp = Ajax_Meth.getInfoCat(ID);
	}
	ds = resp.value;
	if(ds != null && typeof(ds) == "object" && ds.Tables != null){
		var s = new Array();
		if (ds.Tables[0].Rows.length>0){
			if (ds.Tables[0].Rows[0].LINFORM != null){
				document.getElementById("divInfoTitle").innerHTML = ds.Tables[0].Rows[0].LINFORM;
			}
			if (ds.Tables[0].Rows[0].TINFORM != null){
				document.getElementById("divInfoText").innerHTML = ds.Tables[0].Rows[0].TINFORM;
			}
		}
	}
	new Effect.Appear('fondNoir',{duration:0.5, from:0.0, to:0.5});
	new Effect.Appear('divInfo',{duration:0.5, from:0.0, to:1});
}

function showDivInfoID(IDInfo,divInfo){
	document.getElementById("divInfo").style.top=230+document.documentElement.scrollTop;
	document.getElementById("divInfoTitle").innerHTML = '';
	document.getElementById("divInfoText").innerHTML = '';

	var resp;
	var ds;

	resp = Ajax_Meth.getInfo(IDInfo);

	ds = resp.value;
	
	if(ds != null && typeof(ds) == "object" && ds.Tables != null){
		var s = new Array();
		if (ds.Tables[0].Rows.length>0){
			if (ds.Tables[0].Rows[0].LINFORM != null){
				document.getElementById("divInfoTitle").innerHTML = ds.Tables[0].Rows[0].LINFORM;
			}
			if (ds.Tables[0].Rows[0].TINFORM != null){
				document.getElementById("divInfoText").innerHTML = ds.Tables[0].Rows[0].TINFORM;
			}
		}
	}
  document.getElementById(divInfo).style.display="none";
	new Effect.Appear('fondNoir',{duration:0.5, from:0.0, to:0.5});
	new Effect.Appear('divInfo',{duration:0.5, from:0.0, to:1});
	
}

function showDivTypeAcc(lg)
{
	if (lg == 'nl'){
		document.getElementById("TypeAccClose").innerHTML = '<a href="javascript:closeDivTypeAcc();">Sluiten</a>';
	}
	else{
		document.getElementById("TypeAccClose").innerHTML = '<a href="javascript:closeDivTypeAcc();">Fermer</a>';
	}
	new Effect.Appear('fondNoir',{duration:0.5, from:0.0, to:0.5});
	new Effect.Appear('contTypeAcc',{duration:0.5, from:0.0, to:1});
}

function closeDivTypeAcc()
{
new Effect.Fade(contTypeAcc,{duration:0.5});
	if (document.getElementById("fondNoir")!= null ){
		new Effect.Fade(fondNoir,{duration:0.5});
	}
}

function ShowCategoriesDiv(divId,btnId)
{
   var currentDiv = $(divId);
     //alert(currentDiv);
  if (currentDiv)
  {
    currentDiv.style.display = "block";
  }
  showElt(divId,btnId);
 currentDiv.observe('mouseleave',function(){
  currentDiv.style.display = "none";
 });
}
function showElt(elt,btn){
	var nav_flottant = document.getElementById(elt);

	if(nav_flottant != null){		
		//alert(getPosition(btn)[0]  + "/" + getPosition(btn)[1]);
		nav_flottant.style.left = getPosition(btn)[0]+"px";
		nav_flottant.style.top = (getPosition(btn)[1]+14)+"px";
		nav_flottant.style.display="block";
	}
}
function getPosition(element)
{
    var left = 0;
    var top = 0;
    /*On récupère l'élément*/
    var e = document.getElementById(element);
    /*Tant que l'on a un élément parent*/
    while (e.offsetParent != undefined && e.offsetParent != null)
    {
        /*On ajoute la position de l'élément parent*/
        left += e.offsetLeft + (e.clientLeft != null ? e.clientLeft : 0);
        top += e.offsetTop + (e.clientTop != null ? e.clientTop : 0);
        e = e.offsetParent;
    }
    return new Array(left,top);
}
function showDivPromo(idPromo,lg){
	
	var resp;
	var ds;
	resp = Ajax_Meth.getInfoPromo(idPromo, lg);
	ds = resp.value;
	if(ds != null && typeof(ds) == "object" && ds.Tables != null){
		var s = new Array();
		if (ds.Tables[0].Rows.length>0){
			if (ds.Tables[0].Rows[0].LTITLEX != null){
				document.getElementById("divInfoTitle").innerHTML = ds.Tables[0].Rows[0].LTITLEX;
			}
			if (ds.Tables[0].Rows[0].LCONTENT != null){
				document.getElementById("divInfoText").innerHTML = ds.Tables[0].Rows[0].LCONTENT;
			}
		}
	}
  
	new Effect.Appear('fondNoir',{duration:0.5, from:0.0, to:0.5});
	new Effect.Appear('divInfo',{duration:0.5, from:0.0, to:1});
}

function changeDeliveryMethod(choice){
   document.getElementById('Paragraphe').style.display="block";
   if(choice == 'D'){
    document.getElementById('tblDealerDelivery').style.display="block";
    document.getElementById('divHomeDelivery').style.display="none";
    document.getElementById('tdTConfirmDet').style.visibility="visible";
    if(document.getElementById('chkDeliveryI') != null){
      document.getElementById('chkDeliveryI').checked = false;
      document.getElementById('chkDeliveryD').checked = true;
    }
  }else{
   document.getElementById('tblDealerDelivery').style.display="none";
    document.getElementById('divHomeDelivery').style.display="block";
    document.getElementById('tdTConfirmDet').style.visibility="hidden";
    if(document.getElementById('chkDeliveryI') != null){
      document.getElementById('chkDeliveryI').checked = true;
      document.getElementById('chkDeliveryD').checked = false;
    }
  }
}
function callBadCompatibility (){
		// Dialog			
		jQuery(function(){
			jQuery('#dialog').dialog('open');
			});
} 
