function noPostBack(sNewFormAction)
{
    document.forms[0].action = sNewFormAction;
    document.forms[0].__VIEWSTATE.name = 'NOVIEWSTATE';
    document.forms[0].target = '_blank';
}
  
// Artikel weiterempfehlen    
function empfehlen(ausg) {
    dis = window.open(ausg,"my2","toolbar=0,resizable=0,status=no,width=420,height=550");
}

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_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


// Erweiterung FW BEGIN: 6.5.3.	Information zu den Status der Verfügbarkeit
//Abweichend vom Standardshop soll bei einem Klick auf die Verfügbarkeitsanzeige kein PopUp-Fenster erscheinen, sondern ein Infofeld mit dem Status bei Rollover.
function ShowAvailability(Ereignis){

    xPosition = Ereignis.clientX - 470;
    yPosition = Ereignis.clientY;
    
    //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';
}
// Erweiterung FW END

// Erweiterung FW: Datenblatt drucken
function printDataSheet(ausg)
{
    var win = window.open(ausg,"PrintPreview","toolbar=1,width=1200,height=800,scrollbars=yes");
}

//Erweiterung FW: Über Ihre Firma
function ChangeWebShopAddressVisibility(textBox){

    if (document.getElementById(textBox).checked)
    {    
        document.getElementById('divWebShopAddressText').style.display = 'block';
        document.getElementById('divWebShopAddressTextBox').style.display = 'block';
        document.getElementById('divWebShopAddressText2').style.display = 'block';
    }
    else
    {
        document.getElementById('divWebShopAddressText').style.display = 'none';
        document.getElementById('divWebShopAddressTextBox').style.display = 'none';
        document.getElementById('divWebShopAddressText2').style.display = 'none';
    }
    
}

/* Onlinefinanzierung BEGIN */
function OpenCalulatorPopUp(url){
    window.open(url,'Finanzierungsrechner', 'width=500px, height=500px');
}

function OpenCalculatorCustomControl(url){
    window.open(url,'Finanzierungsrechner', 'width=500px, height=500px');
}

function OpenCetelemPopUp(url){
    Onlinefinanzierung = window.open(url,'Cetelem', 'width=900px, height=800px');
    Onlinefinanzierung.focus();
}
/* Onlinefinanzierung END */

/* leitet zu einer anderen Seite weiter */
function RedirectToUrl(RedirectUrl)
{
    window.location.href = RedirectUrl;
}

/*********************************
Erweiterung Bewertungssystem BEGIN
*********************************/

/* Klasse RatingControls BEGIN */
function RatingControls()
{
    /* Variablen */
    this.Items = new Array();
}

RatingControls.prototype.addRatingControl = function(controlId)
{
    this.Items.push(controlId);
}
/* Klasse RatingControls END */

/* Globale Variablen */
var myRatingControlsItems = new RatingControls();

/* Registriert Bewertungs-Controls */
function RegisterRatingControl(controlId)
{
    myRatingControlsItems.addRatingControl(controlId);
}

/* Speichert die Bewertung zu einer Bestellung */
function SaveRatings(DivInfoId, lblInfoId, errorMessage, BelId)
{
 
    var bCheckOK = true;
    var RatingsObject = new Object();
    var keys = '';
    var i = 0;
    
    for(i = 0; i < myRatingControlsItems.Items.length; i++)
    {
        var controlId = myRatingControlsItems.Items[i];
        
        var input = document.getElementById(controlId).value;
        if (isNaN(input) || trim(input) == '')
        {
            bCheckOK = false;
            break;
        }
        else
        {
            RatingsObject[controlId.split("_")[1]] = trim(input);
            keys = keys + controlId.split("_")[1] + '|';
        }
        
    }
    
    if (bCheckOK == false)
    {
        document.getElementById(DivInfoId).style.display = 'block';
        document.getElementById(lblInfoId).innerHTML = errorMessage;
        //13.01.2010 (fw.kr): Focus in Fehlerfeld setzen
        document.getElementById(myRatingControlsItems.Items[i]).focus();
        return;
    }
    else
    {
        document.getElementById(DivInfoId).style.display = 'none';
        logicbase.Shop.LBShopWebService.SaveOrderRatings(JSON.encode(RatingsObject), keys, BelId, document.getElementById('RateOrder_Comment').value, DivInfoId, lblInfoId, CallSuccessOrderRatings, CallFailed, null);
    }

}

/*******************************
Erweiterung Bewertungssystem END
*******************************/

/* Schneidet führende und abschließende Leerzeichen einer Zeichenkette ab */
function trim(zeichenkette) {

  return zeichenkette.replace (/^\s+/, '').replace (/\s+$/, '');
  
}

function checkTextAreaLength(textAreaId, maxLength)
{
    var textArea = document.getElementById(textAreaId).value;
    
    if (textArea.length >= maxLength)
    {
        document.getElementById(textAreaId).value = textArea.substring(0, maxLength);
    }
}

function SwitchVisibility(ElementId) {
    if (document.getElementById(ElementId).style.display == 'block')
        document.getElementById(ElementId).style.display = 'none';
    else
        document.getElementById(ElementId).style.display = 'block';
}

function SwitchText(ElementId) {    

    if (document.getElementById('divphAnimationsContainer').style.display == 'block')
        document.getElementById('aChangeVisibility').innerHTML = closeText;
    else
        document.getElementById('aChangeVisibility').innerHTML = openText;
    
}


/*******************************/
/* Ereiterung FactFinder BEGIN */
/*******************************/
function showAccessory(accName, showName, hideName)
{
    document.getElementById(accName).style.display='block';
    document.getElementById(showName).style.display='none';
    document.getElementById(hideName).style.display='block';
}

function hideAccessory(accName, showName, hideName)
{
    document.getElementById(accName).style.display='none';
    document.getElementById(showName).style.display='block';
    document.getElementById(hideName).style.display='none';
}
/*******************************/
/* Ereiterung FactFinder END */
/*******************************/

/**************************************/
/* Erweiterung Preis vorschlagen BEGIN */
/**************************************/

function ShowMakeOffer(evt){

    xPos = evt.clientX -470;
    yPos = evt.clientY;
    
    //Scrollposition berücksichtigen
    var docEl = (
             typeof document.compatMode != "undefined" && 
             document.compatMode        != "BackCompat"
            )? "documentElement" : "body";

    xPos    += document[docEl].scrollLeft;
    yPos    += document[docEl].scrollTop;
    
    document.getElementById("divMakeOffer").style.left = xPos + "px";
    document.getElementById("divMakeOffer").style.top = yPos + "px";
    document.getElementById("divMakeOffer").style.display = 'block';
 
}

function HideMakeOffer(){
document.getElementById("divMakeOffer").style.display = 'none';
}
/**************************************/
/* Erweiterung Preis vorschlagen END   */
/**************************************/

/**************************************/
/* Erweiterung Datenblatt BEGIN */
/**************************************/

function ShowPrintDataSheet(evt){

    xPos = evt.clientX - 470;
    yPos = evt.clientY;
    
    //Scrollposition berücksichtigen
    var docEl = (
             typeof document.compatMode != "undefined" && 
             document.compatMode        != "BackCompat"
            )? "documentElement" : "body";

    xPos    += document[docEl].scrollLeft;
    yPos    += document[docEl].scrollTop;
    
    document.getElementById("divPrintDataSheet").style.left = xPos + "px";
    document.getElementById("divPrintDataSheet").style.top = yPos + "px";
    document.getElementById("divPrintDataSheet").style.display = 'block';
 
}
function HidePrintDataSheet(){
    document.getElementById("divPrintDataSheet").style.display = 'none';
}

/**************************************/
/* Erweiterung Datenblatt vorschlagen END   */
/**************************************/

/**************************************/
/* Erweiterung Gastbestellung BEGIN    */
/**************************************/
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';
        document.getElementById('divPass5').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';
        document.getElementById('divPass5').style.display = 'block';
    }

}
/**************************************/
/* Ereiterung Gastbestellung END      */
/**************************************/


/**************************************/
/* Erweiterung FF Suchoptimierung BEGIN */
/**************************************/
function clickProduct(query, artId, artPos, artOrigPos, pageNum, artSimi, sessionId, artTitle, pageSize, origPageSize, eventName){
    if(eventName == null){eventName = 'click';}
    $.ajax({
        type: 'POST',
        url: 'FFProxyScic.aspx',
        data: {
            query: query,
            id: artId,
            pos: artPos,
            origPos: artOrigPos,
            page: pageNum,
            simi: artSimi,
            sid: sessionId,
            title: artTitle,
            event: eventName,
            pageSize: pageSize,
            origPageSize: origPageSize
        },
        contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
        cache: false,
        async: false
    });
}
/**************************************/
/* Erweiterung FF Suchoptimierung END  */
/**************************************/

function reload() {
    window.location.href = window.location.href;
}

/*********************************************/
/* Erweiterung yahoo-Tracking Preisvorschlag */
/*********************************************/
function ywaMakeOfferClick(item)
{
    var YWATracker = YWA.getTracker("10001353072637");
    YWATracker.setAction("09");
    YWATracker.setCF(1, item);
    YWATracker.submit_action();
}
