<!--

var cLastId = "";
var nProductInfoCnt_Styles = 0;
var nProductFirstStyles    = 0;

function ScrollPrevStyle() {
   
   // --- 1 Style
   nProductFirstStyles--;
   if ( nProductFirstStyles < 1 )
      nProductFirstStyles = nProductInfoCnt_Styles;

}

function ScrollNextStyle() {
   
   // --- 1 Style
   nProductFirstStyles++;
   if ( nProductFirstStyles > nProductInfoCnt_Styles )
      nProductFirstStyles = 1;

   // --- Schleife über alle Style
   for ( nStyle = 1; nStyle <= nProductInfoCnt_Styles; nStyle++  ) {
        oObj = document.getElementById('S' + nStyle);
  	    oObj.style.visibility = 'hidden';
  	    oObj.style.display    = 'none';
   }
   
   // --- Schleife über alle Style
   for ( nStyle = 0; nStyle < nProductInfoCnt_Styles; nStyle++  ) {
      
      // --- Aktuellen Style prüfen und ggf. korrigieren
      nAktStyle = nProductFirstStyles + nStyle;
      if ( nAktStyle >  nProductInfoCnt_Styles ) {
      	  nAktStyle -= nProductInfoCnt_Styles;
      }
      oObj = document.getElementById('S' + nAktStyle);
      if ( oObj != null ) {
      	 if ( nStyle < 10 ) {
      	    oObj.style.visibility = 'visible';
      	    oObj.style.display    = 'block';
            alert("SHOW=>" + oObj.id + ", " + oObj.style.left);
      	 }
      }
      else
         alert("FEHLER=>" + 'S' + nAktStyle);
      
      

   } // --- for ( nStyle = nProductFirstStyles to (nProductFirstStyles + nProductInfoCnt_Styles) ) {
}

function ProductInfoButtons() {

alert(nProductInfoCnt_Styles);
}


function printIframe( cId ) {
	if ( parent!=null && cId!=null && parent.frames[cId]!=null ) {
		parent.frames[cId].focus(); 
		parent.frames[cId].print(); 
	} else {
		alert('Your browser does not support the required objects and functions.');
	}
}

function maillink(cSubject,cBody,cUrl) {
//var url = document.URL;
cUrl = cUrl.replace (/\?/g,"%3F").replace(/\&/g,"%26");

return "mailto:?subject=" + cSubject + "&body=Hallo ,%0a%0aschau Dir das coole Teil einmal an.%0aWie findest Du das?%0a%0a" + cBody + "%0a%0aLink:%0a" + cUrl;
}


function ReloadStyle( cProducts_Model, cColor ) {


// --- Werte initialisieren
oObj = document.getElementById( 'akt_model' );
if ( oObj != null ) {
   oObj.value = cProducts_Model;
}

// --- Init Color
oObj = document.getElementById( 'init_color' );
if ( oObj != null ) 
   if ( oObj.title != "" && oObj.title != "undefined" ) 
       cColor = oObj.title;

// --- Initialiisere alle verfuegbaren Farben
loadColors( cColor, cProducts_Model );

// --- Initialiisere alle verfuegbaren Größen
loadSizeByColor( cColor, cProduct_model );

// --- Produktnummer setzen
oObj = document.getElementById( 'products_model' );
if ( oObj != null ) {
   oObj.innerHTML = "Produktnummer: " + cProducts_Model;
}

// --- Produktbeshreibung (kurz)
//loadDescription ( cProducts_Model );


// --- Produktbeshreibung (lang)

// --- Preis
}


function showBox ( cID, nPos, nCntPos, cID_LI ) {
	oObj = document.getElementById(cID);
	if ( oObj != null ) {
       
       // --- Erstes LI aktivieren
       oObjLi = document.getElementById('MI_' + cID_LI );
       if ( oObjLi != null )
          oObjLi.className='aktiv';
              
       // --- Offset-X ermitteln
       nCntPos += 1;
       //nOffsetY = (nCntPos * 16) + 4;
       nOffsetY = 0;
       
       // --- Zeile ermitteln
       nPos = nPos-1;
       nRow =parseInt(nPos / 8);
       
       // --- Spalte ermitteln
       nCol = nPos - (nRow*8);

       // --- Letzte Box wieder schliessen
       if ( cLastId != cID ) {
          hideBox ( cLastId  );
       }
       cLastId = cID;

       // --- Navi darstellen und positionieren
       oObj.style.left = 24 + (118 * nCol)+ "px";
       oObj.style.top  = 4 + (149 * nRow) - nOffsetY +  "px";
       oObj.style.display = 'block';
       
    }
}
function hideBox ( cID  ) {
	   
	   if ( cID == '#' )
	      cID = cLastId;
  	   oObjHideBox = document.getElementById(cID);
	   if ( oObjHideBox != null ) {
          oObjHideBox.style.display = 'none';
       }
}


function NaviImageIn ( oObj, cRolloverImage ) {

 if ( oObj != null ) {
    oObj.src = cRolloverImage;
 }
}
function NaviImageOut ( oObj, cImage ) {

 if ( oObj != null ) {
       oObj.src = cImage;
 }
}


var http_request = false;
var ajax_ready = true;
var ajax_oObj = null;
var ajax_Value = null;
var cAjaxId = "";

function SetObjVisibility( cObjId, cObjValue ) {

   oObj = document.getElementById(cObjId);
   if ( oObj != null ) 
   {
      if ( cObjValue == "0" )
      { 
   	     oObj.style.visibility = 'hidden'; 
   	     oObj.style.display    = 'none';
      }
      else 
      {
         oObj.style.visibility = 'visible'; 
         oObj.style.display    = 'inline';
      }
   }
}

function loadColors ( cColor, cProduct_model ) {

   	  // --- Mouse-Cursor aendern
   	  oAktCursor = document.getElementsByTagName("body")[0].style.cursor;
   	  //document.getElementsByTagName("body")[0].style.cursor = "wait";

      // --- Setze aktuelle Farbe
      oObj = document.getElementById('akt_color');
      cPrevColor = oObj.value;
      if (oObj != null ) oObj.value = cColor;
      
      // --- Object setzen
      oObjColor = document.getElementById('colors_content');
      ajax_oObj = oObjColor;
      cAjaxId   = "akt_color";
      
      // --- Ajax-Request
      AjaxRequest("/ajax.php?handler=loadcolor&products_model=" + cProduct_model + "&color=" + cColor, ajax_fill_container_color );
      
      // --- Image (Button)
      oObj = document.getElementById('img_color_' + cPrevColor.toLowerCase() );
      if ( oObj != null ) 
         oObj.src='/templates/touchlines/img/' + cPrevColor.toLowerCase().replace(".","") + '.gif';
      oObj = document.getElementById('img_color_' + cColor.toLowerCase() );
      if ( oObj != null ) 
         oObj.src='/templates/touchlines/img/' + cColor.toLowerCase().replace(".","") + '_aktiv.gif';


  	  // --- Mouse-Cursor zuruecksetzen
   	  document.getElementsByTagName("body")[0].style.cursor = oAktCursor;
}
function loadSizeByColor( cColor, cProduct_model ) {
   	  // --- Mouse-Cursor aendern
   	  oAktCursor = document.getElementsByTagName("body")[0].style.cursor;
   	  //document.getElementsByTagName("body")[0].style.cursor = "wait";
      // --- Setze aktuelle Farbe
      oObj = document.getElementById('akt_color');
      cPrevColor = oObj.value;
      if (oObj != null ) oObj.value = cColor;    
      // --- Object setzen
      oObjSize  = document.getElementById('size_content');
      ajax_oObj = oObjSize;
      cAjaxId   = "akt_size";
      
      cSizeObj = document.getElementById('act_size');
      cSize = (cSizeObj != null) ? cSizeObj.options[cSizeObj.selectedIndex].getAttribute('name') : '';
    
      // --- Ajax-Request
      AjaxRequest("/ajax.php?handler=loadsize&products_model=" + cProduct_model + "&color=" + cColor + "&size=" + cSize, ajax_fill_container_size );
      
      // --- Bild austauschen
      oObjPfad    = document.getElementById('imagepfad');
      oObjColor   = document.getElementById('color_' + cColor.toLowerCase() );
      oObjImg     = document.getElementById('products_image');
      oObjImg.src = oObjPfad.title + oObjColor.title;
      
        
        oObjBigSrc = document.getElementById('imagesrc');
        oObjBigImg = document.getElementById('products_bigImg');
        if (oObjBigImg != null) oObjBigImg.src = oObjBigSrc.title + oObjColor.title;
      
      // --- Image (Button)
      oObj = document.getElementById('img_color_' + cPrevColor.toLowerCase() );
      if ( oObj != null ) 
         oObj.src='/templates/touchlines/img/' + cPrevColor.toLowerCase().replace(".","") + '.gif';
      oObj = document.getElementById('img_color_' + cColor.toLowerCase() );
      if ( oObj != null ) 
         oObj.src='/templates/touchlines/img/' + cColor.toLowerCase().replace(".","") + '_aktiv.gif';

    oObjForm = document.getElementById('cart_quantity');
    action = oObjForm.getAttribute('action');
    parts = action.split('initcolor=');
    parts2 =  parts[1].split('&');
    action = parts[0] + 'initcolor=' + cColor;
    for (var i=1; i<parts2.length; i++) {
        action += '&'+parts2[i];
    }
    oObjForm.setAttribute('action', action);

  	  // --- Mouse-Cursor zuruecksetzen
   	  document.getElementsByTagName("body")[0].style.cursor = oAktCursor;
}
function loadDescription ( cProduct_model ) {

   	  // --- Mouse-Cursor aendern
   	  oAktCursor = document.getElementsByTagName("body")[0].style.cursor;
   	  //document.getElementsByTagName("body")[0].style.cursor = "wait";

      // --- Object setzen
      oObjAjax = document.getElementById('products_name');
      ajax_oObj = oObjAjax;

      // --- Ajax-Request
      AjaxRequest("/ajax.php?handler=loadsize&products_model=" + cProduct_model, ajax_fill_container_description );
      
  	  // --- Mouse-Cursor zuruecksetzen
   	  document.getElementsByTagName("body")[0].style.cursor = oAktCursor;
}
function initSize( cSize ) {

   // --- Initialize
   cProductsID = "";
   
   // --- 
   oObj = document.getElementById('size_' + cSize.toLowerCase() );
   if ( oObj != null ) 
      cProductsID = oObj.title;
   //alert(cSize);
//alert(cProductsID);
   // --- Hole den Lieferstatus und setze Ampel
   oObjStatus        = document.getElementById('status_' + cProductsID);
   if ( oObjStatus != null )
      cStatusID = "AMPEL" + oObjStatus.firstChild.nodeValue;
   else
      cStatusID = "AMPEL1";
   if ( oObjStatus == null || cSize == "" ) cStatusID = "AMPEL3";
   for ( nAmpel = 1; nAmpel <= 10; nAmpel++ ) {
      cAmpelID = "AMPEL" + nAmpel;
	  if ( document.getElementById(cAmpelID) == null )
	    break;
	  else
		document.getElementById(cAmpelID).style.display="none";
   }
   oObjAmpel = document.getElementById(cStatusID);
   oObjAmpel.style.display="block";
//alert(oObjAmpel + "/"+cStatusID + "/" + oObjStatus + "/" + cProductsID);

   
   // --- Hole den Preis und setze diesen
   oObjPrice        = document.getElementById('price_' + cProductsID);
   oObjPriceSpecial = document.getElementById('sprice_' + cProductsID);
   //alert(cProductsID + ", " + oObj.firstChild.nodeValue);
   oObjContent = document.getElementById('products_price');
   if ( oObjPriceSpecial != null ) {
      oObjContent.innerHTML = "Angebot: <font color='red'>EUR " + oObjPriceSpecial.firstChild.nodeValue + "</font> anstatt EUR " +  oObjPrice.firstChild.nodeValue;
   }
   else
      oObjContent.innerHTML =  "EUR " + oObjPrice.firstChild.nodeValue;
   
   // --- Setze aktuelle Grösse
   oObj = document.getElementById('akt_size');
   cPrevSize = oObj.value;
   if ( oObj != null ) 
      oObj.value = cSize;

   // --- Image (Button)
   oObj = document.getElementById('img_size_' + cPrevSize.toLowerCase() );
   if ( oObj != null ) 
      oObj.src='/templates/touchlines/img/size_' + cPrevSize.toLowerCase() + '.gif';
   oObj = document.getElementById('img_size_' + cSize.toLowerCase() );
   if ( oObj != null ) 
      oObj.src='/templates/touchlines/img/size_' + cSize.toLowerCase() + '_aktiv.gif';
   
   // --- Product-ID
   oObj = document.getElementById('products_id');
   if ( oObj != null ) 
      oObj.value = cProductsID;
}

function AjaxRequest(cAjaxRequestUrl, ajax_fill_container) {

        ajax_ready = false;
        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // zu dieser Zeile siehe weiter unten
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
            return false;
        }
        
        cAjaxRequestUrl = cAjaxRequestUrl + '&ts=' + new Date().getTime()
        http_request.onreadystatechange = ajax_fill_container;
        http_request.open('GET', cAjaxRequestUrl, true);
        http_request.send(null);
}
function ajax_fill_container_description () {

        if (http_request.readyState == 4) {

            ajax_ready = true;

            if (http_request.status != 200) {
               alert('Bei dem Request ist ein Problem aufgetreten.' + 'Fehlercode:'+ http_request.status);
            }
            else {
                if (http_request.responseText.length > 0) {
                   var json_array = http_request.responseText;
                   ajax_Value = eval("(" + json_array + ")");

                   if ( ajax_oObj != null ) {
                   	  // --- Kurbeschreibung
   	                  ajax_oObj.innerHTML = ajax_Value[0];
                      
                   } // --- if ( ajax_oObj != null ) {

                }
            }
        }
}
function ajax_fill_container_size() {

        if (http_request.readyState == 4) {
            ajax_ready = true;
            if (http_request.status != 200) {
                alert('Bei dem Request ist ein Problem aufgetreten.' + 'Fehlercode:'+ http_request.status);
            }
            else {
                if (http_request.responseText.length > 0) {
                   var json_array = http_request.responseText;
                   ajax_Value = eval("(" + json_array + ")");
                   if ( ajax_oObj != null ) {
   	                  ajax_oObj.innerHTML = ajax_Value[0];
					  
					  // --- Lieferstatus (Button fuer Warenkorb ein/ auschalten) -------------------------------
					  strStatus = ajax_Value[2];
					  oObjWarenkorb = document.getElementById("warenkorb");
 					  oObjKasse = document.getElementById("kasse");
					  if ( strStatus==0 ) {
						oObjWarenkorb.style.display = "none"; 
						oObjKasse.style.display     = "none"; 
					 }
					 else { 
						oObjWarenkorb.style.display = "block" ;
						oObjKasse.style.display     = "block" ;
					  }
					  // --- Lieferstatus (Button fuer Warenkorb ein/ auschalten) -------------------------------
					  
					  // --- Groesse ----------------------------------------------------------------------------
					  cSize = ajax_Value[3];
					  // --- Groesse ----------------------------------------------------------------------------
					  
                      // --- Produkt-ID anhand der Size setzen
                      oObj = document.getElementById("akt_size");
                      //if ( oObj != null ) 
					  initSize( cSize );
                      
                   } // --- if ( ajax_oObj != null ) {
      
                }
            }
        }
}
function ajax_fill_container_color() {

        if (http_request.readyState == 4) {
            ajax_ready = true;
            if (http_request.status != 200) {
                alert('Bei dem Request ist ein Problem aufgetreten.' + 'Fehlercode:'+ http_request.status);
            }
            else {
                if (http_request.responseText.length > 0) {
                   var json_array = http_request.responseText;
                   ajax_Value = eval("(" + json_array + ")");
                   if ( ajax_oObj != null ) {
   	                  ajax_oObj.innerHTML = ajax_Value[0];

                      // --- Bild austauschen
                      oObjColorName = document.getElementById('akt_color');
                      oObjPfad    = document.getElementById('imagepfad');
                      oObjColor   = document.getElementById('color_' + oObjColorName.value.toLowerCase() );
                      oObjImg     = document.getElementById('products_image');
                      oObjImg.src = oObjPfad.title + oObjColor.title;

                      // --- Image (Button)
                      oObj = document.getElementById('img_color_' + oObjColorName.value.toLowerCase() );
                      if ( oObj != null ) 
                         oObj.src='/templates/touchlines/img/' + oObjColorName.value.toLowerCase() + '_aktiv.gif';

                      // --- beschreibung 
                      oObjDesc = document.getElementById('products_name');
                      oObjDesc.innerHTML = ajax_Value[1];

                      // --- LangBeschreibung
                      oObjDesc = document.getElementById('products_description');
                      oObjDesc.innerHTML = ajax_Value[2];

                      // --- Preis
                      oObjDesc = document.getElementById('products_price');
                      oObjDesc.innerHTML = ajax_Value[3];

                   } // --- if ( ajax_oObj != null ) {
      
                }
            }
        }
}
	
	
function transferValue( cIdSrc, cIdDest ) {

   // --- Value holen
   cHtmlSnippet = _getTitle ( cIdSrc );

   // --- Value ersetzen
   oObj = document.getElementById( cIdDest );
   if ( oObj != null ) {
   	   oObj.title =cHtmlSnippet;
   	   oObj.alt =cHtmlSnippet;
   }
}
function _getTitle ( cIdSrc ) {
   // --- Value holen
   cHtmlSnippet = "";
   oObj = document.getElementById( cIdSrc );
   if ( oObj != null )
      cHtmlSnippet = oObj.title;
   return cHtmlSnippet;
}

function ReloadIframe( cAktId, cInitColor, cInitSize ) {

   // --- Iframe holen und laden
   //cUrl = _getTitle(cAktId);
   cUrl ='/product_info_touchlines.php?css=stylesheet_detail&products_id=' + cAktId + "&initcolor=" + cInitColor + "&initsize=" + cInitSize;
   oObj = document.getElementById( 'popup_iframe' );
   if ( oObj != null )
	  oObj.src = cUrl;

}

function ShowProductPopup( cAktId, cInitColor, cInitSize ) {

  
   // --- Iframe fuellen
   ReloadIframe( cAktId, cInitColor, cInitSize );
   
   
   // --- Popup anzeigen
   oObj = document.getElementById('popup_product');
   if ( oObj != null ) {
      oObj.style.display="block";
      if (navigator.appName.indexOf('Netscape') != -1) { 
	FensterBreite = self.innerWidth;
	oObj.style.left = ((FensterBreite - 885) / 2) + "px";
	oObj.style.top = window.pageYOffset + "px";
      } else {
      	if ( navigator.appName.indexOf('Microsoft') != -1 ) {
      	   FensterBreite = document.body.clientWidth;
   	   oObj.style.left = (FensterBreite - 885) / 2;
   	   var toppos = (mousey >= 300) ? mousey - 300 : 0;
	   if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
		toppos = document.documentElement.scrollTop + "px";
	   } else if (typeof document.body != 'undefined') {
   		toppos = document.body.scrollTop + "px";
	   }
   	   oObj.style.top = toppos;
        }
      }
   }
      
   // --- Hintergrund ausblender
   oObj = document.getElementById('cd_shop_frame');
   if ( oObj != null ){
   	  oObj.className="opacity_on";
   }
}

function HideProductPopup(elem) {
   oObj = parent.document.getElementById(elem);
   if ( oObj != null ){
   	  oObj.style.display="none";
   }
   oObj = parent.document.getElementById('cd_shop_frame');
   if ( oObj != null ){
   	  oObj.className="opacity_off";
   }
}


//-->

