//wird in der Default.aspx gefüllt
var noimagePic;

function handleImgError(imgCtrl) {
    imgCtrl.src = noimagePic;
}

function noPostBack(sNewFormAction)
{
    document.forms[0].action = sNewFormAction;
    document.forms[0].__VIEWSTATE.name = 'NOVIEWSTATE';
    document.forms[0].target = '_blank';
    setTimeout('resetPostBack()', 0);
}

// Bug-Fix um nach Absenden des Trusted-Shop-Money-Back Formulars noch Postback-Buttons nutzen zu können
function resetPostBack() {
    document.forms[0].action = "Default.aspx";
    document.forms[0].__VIEWSTATE.name = '__VIEWSTATE';
    document.forms[0].target = '';
}
  
// Artikel weiterempfehlen    
function empfehlen(ausg) {
     dis = window.open(ausg,"my2","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=420,height=500,top=150,left=250");
}

function printWindow() {
Browser = parseInt(navigator.appVersion);
if (Browser >= 4) window.print();
}

// Mouse-Over für Detailansicht
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

// ändert den Wert des VariantenDropDowns
function changeDropDownValue(dropDownId,indexToSelect){
    document.getElementById(dropDownId).selectedIndex = indexToSelect;
}

// Umstellung IPayment auf CGI BEGIN
function showInfo(divName,e)
{
  document.getElementById(divName).style.display='block';
}

function hideInfo(divName)
{
    document.getElementById(divName).style.display='none';
}

function submitIPaymentForm(formAction, nextButton, prevButton)
{
    var sImage = document.getElementById("imgWait").src;
    document.getElementById(nextButton).disabled = true;
    document.getElementById(prevButton).disabled = true;
    document.getElementById("divIPaymentWait").style.display='block';
    document.forms[0].action = formAction;
    document.forms[0].__VIEWSTATE.value = '';
    document.forms[0].__EVENTVALIDATION.value = '';
    document.forms[0].method = 'POST';   
    document.forms[0].submit();  
    document.getElementById("imgWait").src = sImage;
    return false;
}
// Umstellung IPayment auf CGI END

// Verfügbarkeitsdarstellung
function ShowAvailability(Ereignis) {

    xPosition = Ereignis.clientX -400;
    yPosition = Ereignis.clientY -480;

    //Scrollposition berücksichtigen
    var docEl = (
             typeof document.compatMode != "undefined" &&
             document.compatMode != "BackCompat"
            ) ? "documentElement" : "body";

    xPosition += document[docEl].scrollLeft;
    yPosition += document[docEl].scrollTop;

    document.getElementById("divAvailability").style.left = xPosition + "px";
    document.getElementById("divAvailability").style.top = yPosition + "px";
    document.getElementById("divAvailability").style.display = 'block';
}

function HideAvailability() {
    document.getElementById("divAvailability").style.display = 'none';
}

// firefox update-defaul-button fix
function addClickFunction(id) {

    {
        var b = document.getElementById(id);
        if (b && typeof (b.click) == 'undefined') b.click = function() {

            {
                var result = true; if (b.onclick) result = b.onclick();
                if (typeof (result) == 'undefined' || result) { { eval(b.getAttribute('href')); } }
            }
        }
    }
};

/*******************************/
/* Ereiterung FactFinder BEGIN */
/*******************************/
function showAccessory(accName, accName2, accName3, showName, hideName) {
    document.getElementById(accName).style.display = 'block';
    document.getElementById(accName2).style.display = 'block';
    document.getElementById(accName3).style.display = 'block';
    document.getElementById(showName).style.display = 'none';
    document.getElementById(hideName).style.display = 'block';
}

function hideAccessory(accName, accName2, accName3, showName, hideName) {
    document.getElementById(accName).style.display = 'none';
    document.getElementById(accName2).style.display = 'none';
    document.getElementById(accName3).style.display = 'none';
    document.getElementById(showName).style.display = 'block';
    document.getElementById(hideName).style.display = 'none';
}
/*******************************/
/* Ereiterung FactFinder END */
/*******************************/

/* ändert die Sichtbarkeit */
function SwitchVisibility(id)
{
    document.getElementById(id).style.display == 'none' ? document.getElementById(id).style.display = 'block' : document.getElementById(id).style.display = 'none';
}

/* ändert die Sichtbarkeit */
function SwitchAccessoryVisibility(DivId, img, shoppingCartPositionId)
{
    var element = document.getElementById(DivId);
    if (element.style.display == 'none')
    {
        element.style.display = 'block';
        element.innerHTML = "<img id='imgAccessoryWait' />";
        document.getElementById('imgAccessoryWait').src = img;
        GetAccessoryItems(shoppingCartPositionId, DivId);
    }
    else
    {
        element.style.display = 'none';
    }
}

function SwitchGuestAccountVisibility(isGuestAccount) {

    if (isGuestAccount == 'true') {
        document.getElementById('divPassHeadline').style.display = 'none'
        document.getElementById('divPass1').style.display = 'none';
        document.getElementById('divPass2').style.display = 'none';
        document.getElementById('divPass3').style.display = 'none';
        document.getElementById('divPass4').style.display = 'none';
    }
    else {
        document.getElementById('divPassHeadline').style.display = 'block';
        document.getElementById('divPass1').style.display = 'block';
        document.getElementById('divPass2').style.display = 'block';
        document.getElementById('divPass3').style.display = 'block';
        document.getElementById('divPass4').style.display = 'block';
    }

}

function ItemsListPaging(url, DDLpages, ddlItemsPerPage, ddlOrderBy) { 
    var FIT = document.getElementById(DDLpages).value;
    var IPP = document.getElementById(ddlItemsPerPage).value;
    var ORD = document.getElementById(ddlOrderBy).value;
    location.href = url + '&FIT=' + FIT + '&IPP=' + IPP + '&ORD=' + ORD;
}


/* Erweiterung Zubehoergruppen */
function blendDIV(controlID) {
    if (document.getElementById(controlID).style.display == 'none') {
        document.getElementById(controlID).style.display = 'inline';
    }
    else {
        document.getElementById(controlID).style.display = 'none';
    }
}

/* Prüfen ob Cookies aktiviert sind: falls nicht entsprechende Warnmeldung in Warenkorb und Mein Konto - Seiten */
function checkCookie() {
    var cookieEnabled = (navigator.cookieEnabled) ? true : false;

    //if navigator,cookieEnabled is not supported
    if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
        document.cookie = "checkCookie";
        cookieEnabled = (document.cookie.indexOf("checkCookie") != -1) ? true : false;
    }

    if (cookieEnabled)
        document.getElementById("divSystemMessage").style.display = 'none';
    else
        document.getElementById("divSystemMessage").style.display = 'block';

}
