/* ProNet V 2.9.3 built 20090709 */
/*! requires prototype library !*/

/* v293:
 * - toggleClassnames - Schriftstilwechsel f�r Tabelleneffekte
 * - executeClickAction - Macht Produktlink, Sprachauswahl und Waehrungsauswahl kombinierbar
 * - Produktlink, Sprachauswahl u. Waehrungsauswahl ge�ndert
 */ 

var click_params;
click_params="";

function toggleClassnames(elem,old_classname,new_classname)
{	    
	var d = Element.descendants(elem);	
	d.each(function(item) {		
		if(item.hasClassName(old_classname)) {			
			item.removeClassName(old_classname);
			item.addClassName(new_classname);		
		} else {					
			if(item.hasClassName('L'+old_classname+old_classname+old_classname)) {
	            item.removeClassName('L'+old_classname+old_classname+old_classname);	            
	            item.addClassName('L'+new_classname+new_classname+new_classname);	         
			}
		}			
	});
}
function executeClickAction()
{    	
  if(click_params != "") {
	  if (document.getElementById)   {
		document.location.href = "index.php"+click_params;
	  } else {
		document.location.href = "index.php"+click_params;
	  }
	}
}
/* Neuer Frame-Mover */
var frames = new Array();
var resizes = new Array();
var scrollframes = new Array();
var scrollbars = new Array();

function moveSingleFrame(frameentry) {			
	if(frameentry.get('y')>=0) {				
        if($('L'+frameentry.get('p'))!=null) {        
    		distance = parseInt($('L'+frameentry.get('p')).style.top) + parseInt($('L'+frameentry.get('p')).offsetHeight) + parseInt(frameentry.get('y'));
			$('L'+frameentry.get('c')).style.top = distance;		
		}
	} 
	if(frameentry.get('x'>=0)) {
        if($('L'+frameentry.get('p'))!=null) {
            $('L'+frameentry.get('c')).style.left = $('L'+frameentry.get('p')).style.left + $('L'+frameentry.get('p')).offsetWidth + frameentry.get('x');
        }
	}		
}

function resizeSingleFrame(frameentry) {	
	ResizeIE5(frameentry.get('p'));
}

function addXMover(child,parent,x_distance) {
	frames[frames.size()] = new Hash({c: child, p: parent, x: x_distance});
}
function addYMover(child,parent,y_distance) {    
	frames[frames.size()] = new Hash({c: child, p: parent, y: y_distance});
}

function addResize(parent) {	
	resizes[resizes.size()] = new Hash({p: parent});
}

function addScrollFrame(fr) {
    scrollframes[scrollframes.size()]=  new Hash({ 'f': fr, 'b': null });
}

function makeScrollFrames() {
    scrollframes.each( function(item) {
        if((item.b==null)) {
            if(item.get('f')>0)
                item.b = new Control.ScrollBar('C'+item.get('f'),'C'+item.get('f')+'_track');
        } else {
            item.b.recalculateLayout();
        }
    });
}

function resizeFrames() {    	
	var d = document.body;
	var l = $(d).down('div');	
	if(l != null) {		
		var lframes = l.up().immediateDescendants('div');
		lframes.each( function (item) {
			pResizeFrames(item);
		});
		moveFrames();
		lframes.each( function (item) {
			pResizeFrames(item);
		});	
	}	
	makeScrollFrames();
}

function moveFrames() {		    
	frames.each(moveSingleFrame);	
}

function GetBrowserID()
{
    var browser;
    browser="2"; // default
    if (navigator.appName=="Netscape") {
        if (navigator.appVersion.substr(0,3)=="4.7") {
            browser="1";
        }
        if (navigator.appVersion.substr(0,1)=="5") {
            browser="3";
        }
    } 
    return browser;
}

function FrameMoveX(child,parent,distance)
{
	addXMover(child,parent,distance);
}

function FrameMoveY(child,parent,distance)
{
	addYMover(child,parent,distance);
}

function SetVisibility(frame)
{
    switch (GetBrowserID()) {
        case "1":
            var d;
            var doc;
            if (parent.hauptframe) {
                d=parent.hauptframe.document;
            } else {
                d=document;
            }
            doc=GetFrameByID(frame,d);
            doc.layers["L"+frame].visibility="show";
            break;
        default:
            document.getElementById("L"+frame).style.visibility="visible";
            break;
    }
}

function GetFrameByID(id,d)
{
    var i;
    for (i=0;i<=d.layers.length-1;i++) {
        if(d.layers[i].id=="L"+id) {
            return d;
        } else {
            doc=GetFrameByID(id,d.layers[i].document);
        }
    }
    return doc;
}

/* Resize-Routinen */

function Resize(ID)
{
	addResize(ID);
}

function LayerResizeNS4(layer) 
{
    // resizing of the parent layer
    var width;
    var height;
    var parent;    
    
    parent=layer.parentLayer;

    if (parent.clip) {
        width=layer.left+layer.clip.width;
        height=layer.top+layer.clip.height;
        if (width<parent.clip.width) width=parent.clip.width;
        if (height<parent.clip.height) height=parent.clip.height;
               
        parent.resizeTo(width,height);
        
    }
    if (parent.parentLayer) {
        LayerResizeNS4(parent);
    }
}

function ResizeIE5(ID)
{	
    frame=document.getElementById('L'+ID).firstChild;
    if (frame) {
        do {
            if (frame.id) {
                if (frame.id.substr(0,1)=='L') {
                    LayerResizeIE5(frame);
                }
            }
            frame=frame.nextSibling;
        }
        while (frame);
    }
    return;
}

function LayerResizeIE5(frame) 
{
    var parent;    
    var height;
    var width;    
    if (frame.style.visibility!="hidden") {
        parent=frame.offsetParent;     
        if(parent!=null) {          
	        if ((parent.style.overflow!="scroll")&&(parent.style.overflow!="auto")&&(parent.id.substr(parent.id.length-8,8)!='_content')) { // LW 20061107 (!)
	        	height=parseInt(frame.offsetHeight);        	
	        	if( parseInt(frame.style.height)>height) height=parseInt(frame.style.height);        	        	
	            if (parseInt(parent.style.height)<parseInt(frame.style.top)+parseInt(height))   {            	
	                parent.style.height=parseInt(frame.style.top)+parseInt(height)+5;                    
	            } else {
	            	
	            }
	            if (parseInt(parent.style.width)<parseInt(frame.style.left)+parseInt(frame.style.width))   {
	                parent.style.width=parseInt(frame.style.left)+parseInt(frame.style.width)+5;    
	            }
	            if (parent.offsetParent) {
	            	if(parent.offsetParent.id.substr(0,1)=='L') {
	                	LayerResizeIE5(parent);
	                }
	            }
	        }
	    }
    }
}


function pResizeFrames(parent) {
	
	var l = parent.down('div');
	
	if(l != null) {
		var lframes = l.up().immediateDescendants('div');
		var height = parent.getHeight();
		var width = parent.getWidth();
		var w=0;    
		var h=0;
		lframes.each(function(item) {
			pResizeFrames(item);        
			h = item.positionedOffset().top + item.getHeight();
			w = item.positionedOffset().left + item.getWidth();
			if(height<h) height = h;
			if(width<w) width = w;        
		});    
		if((width>0)&&(height>0)&&(parent.id.startsWith("L"))) {
			parent.style.width=width;
			parent.style.height=height;
		}
	}
}

/* Action-Routinen */

function PopOn(elementid)
{
    if (document.getElementById) {
        if (document.getElementById("L"+elementid)) {
            document.getElementById("L"+elementid).style.visibility='visible';
            document.getElementById("L"+elementid).style.zIndex='10000';
        }
    } else {
        if (parent.hauptframe.document) {
            d=parent.hauptframe.document;
        } else {
            d=document;
        }
        doc=GetFrameByID(elementid,d);
        doc.layers["L"+elementid].visibility="show"; 
    }
	moveFrames();
}

function PopOff(elementid)
{
    if (document.getElementById) {
        if (document.getElementById("L"+elementid)) {
            document.getElementById("L"+elementid).style.visibility='hidden';
        }
    } else {
        if (parent.hauptframe.document) {
            d=parent.hauptframe.document;
        } else {
            d=document;
        }
        doc=GetFrameByID(elementid,d);
        doc.layers["L"+elementid].visibility="hide"; 
    }
	moveFrames();
}

function Produktlink(productid)
{
  if(click_params=="") {click_params="?";} else {click_params+="&";} 
  click_params += "pid="+productid;
  window.location.href = click_params;
}

function Sprachauswahl(languageid,productid)
{
  if(click_params=="") {click_params="?";} else {click_params+="&";}
  if (document.getElementById) {
    click_params += "pid="+productid+"&languageid="+languageid;
  } else {
    click_params += "pid="+productid+"&languageid="+languageid; return;
  }  
}

function Waehrungsauswahl(waehrungid,productid)
{
  if(click_params=="") {click_params="?";} else {click_params+="&";}
  if (document.getElementById) {
    click_params += "pid="+productid+"&currencyid="+waehrungid;
  } else {
    click_params += "pid="+productid+"&currencyid="+waehrungid; return;
  }
}

function Externerlink(link)
{  
  window.location.href = link;
}

function Drucken()
{
  window.print(); return;
}

function Download(file)
{
  window.location.href = file;
}

function Zurueck()
{
  history.back(); return;
}

function OpenWin(productid, width, height) {
  window.open("index.php?pid="+productid,"Info","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width="+width+",height="+height+"");
}

function OpenWinLink(link) {
  window.open(link,"Info","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=580,height=560");
}

function OpenWinMax(productid, width, height) {
  width=screen.availWidth-12;
  height=screen.availHeight-30;
  window.open("index.php?productid="+productid,"Vorschau","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+width+",height="+height+",left=0,top=0");
}

function ProduktlinkWarenkorb(productid, action) {
  window.location.href = "index.php?pid="+productid+"&action="+action;
}

function windowconfirm(text,productid,action){
  Check = confirm(text);
  if(Check == true) top.location.href = "index.php?pid="+productid+"&action="+action;
}

function SetTitle(title)
{
//    top.document.title=title;
}

function LoadFlash(url,width,height,options) {
        document.write('<EMBED src="'+url+'" width="'+width+'" height="'+height+'" pluginspage="http://www.macromedia.com/shockwave/download/ingex.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" '+options+'>');
}

function Merken()
{   
  if(click_params=="") {click_params="?";} else {click_params+="&";}
  if (document.getElementById) {
    click_params += "action=40";
  } else {
    click_params += "action=40"; return;
  }
}

function MerkzettelLeeren()
{
    if( window.location.href.indexOf("?")==-1) {
        window.location.href = window.location.href+"?action=41";

    } else {
        window.location.href = window.location.href+"&action=41";
    }
}

function MerkzettelSenden()
{
    if( window.location.href.indexOf("?")==-1) {
        window.location.href = window.location.href+"?action=42";

    } else {
        window.location.href = window.location.href+"&action=42";
    }
}

/* AJAX */

function createRequest(rahmen, url) {
	var req;
    
    try{
          req = new XMLHttpRequest();
     }
     catch (e){
         try{
              req = new ActiveXObject("Msxml2.XMLHTTP");
         } 
         catch (e){
            try{
                req = new ActiveXObject("Microsoft.XMLHTTP");
           } 
           catch (failed){
               req = null;
           }
        }  
     }
     
     if(req) { 
	     document.getElementById(rahmen).innerHTML = '<DIV style="width:100%;text-align:center;"><IMG SRC="system/images/wait.gif" border="0"></DIV>';
	     
	     req.onreadystatechange = function(){            
	     switch(req.readyState) {
	        case 4:
	         	if(req.status!=200) {
		             //alert("Fehler:"+req.status); 
	        	 }else{    
	            	 //document.getElementById(rahmen).innerHTML = req.responseText;
	            	 $(rahmen).update(req.responseText);
	            	 req.responseText.evalScripts();
	            	 MoveFrames();
	    	    }
		        break;
	        default:
	            return false;	
	            break;     
	    	}   
	   	};      
	     
	    req.open("GET", url, true);
	    req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		req.send(null);
	}
}

function LogOut()
{
	window.location.href="index.php?action=21";
}

