﻿var __isFireFox = navigator.userAgent.match(/gecko/i);  
var __lastFocus = 0;

function putInBasket3 ( theform, color, size, thetype ) {
	theform['tx_geshop_pi1[color][0]'].value=color;
	theform['tx_geshop_pi1[size][0]'].value=size;
	theform['tx_geshop_pi1[_submit_]'].value="1";
	theform.submit();
	if (thetype) {
		return true;
	}
	return;
}

function putInBasket( theform, thetype ) {

	var i,s,fehler;
	i=0;
	fehler="Bitte eine Farbe wählen";
	s = theform['tx_geshop_pi1[color]'].selectedIndex;
	if ( theform['tx_geshop_pi1[color]'].options[s].value!='') {
		fehler="";
	}
	if (fehler!="") { 
		window.alert(fehler); 
		if (thetype) {
			return false;
		} else {
			return;
		}
	}
		
	fehler="Bitte Größe angeben";
	s = theform['tx_geshop_pi1[size]'].selectedIndex;
	if ( theform['tx_geshop_pi1[size]'].options[s].value!='') {
		fehler="";
	}
	if (fehler!="") { 
		window.alert(fehler); 
		if (thetype) {
			return false;
		} else {
			return;
		}
	}
	
	fehler="Bitte Menge angeben";

	if (isNaN(eval("theform['tx_geshop_pi1[quantity]'].value"))==false) {
		if (eval("theform['tx_geshop_pi1[quantity]'].value")>0) {
			fehler="";
		}
	}
	if (fehler!="") { 
		window.alert(fehler); 
		if (thetype) {
			return false;
		} else {
			return;
		}
	}
	theform['tx_geshop_pi1[_submit_]'].value="1";
	theform.submit();
	if (thetype) {
		return true;
	}
}

function putInBasket2( theform, thetype ) {

	var i,s,fehler,fehlercount,field;

	fehler="Bitte eine Farbe wählen";
	fehlercount=0;
	i=0;
	while (true) {
		field = 'tx_geshop_pi1[color]['+i+']';
		if (theform[field]==null) {
			break;
		}
		if (theform[field].type=='hidden') {
		} else {		
			s = theform[field].selectedIndex;
			if ( theform[field].options[s].value=='!') {
				fehlercount++;
			}
		}
		i++;
	}
	
	if (fehlercount==i) { 
		window.alert(fehler); 
		if (thetype) {
			return false;
		} else {
			return;
		}
	}
		
	fehler="Bitte Variante angeben";

	fehlercount=0;
	i=0;
	while (true) {
		field = 'tx_geshop_pi1[size]['+i+']';
		if (theform[field]==null) {
			break;
		}

		if (theform[field].type=='hidden') {
		} else {		
			s = theform[field].selectedIndex;
			if ( theform[field].options[s].value=='!') {
				fehlercount++;
			}
		}
		i++;
	}

	if (fehlercount==i) { 
		window.alert(fehler); 
		if (thetype) {
			return false;
		} else {
			return;
		}
	}
		
	fehler="Bitte Menge angeben";

	if (isNaN(eval("theform['tx_geshop_pi1[quantity]'].value"))==false) {
		if (eval("theform['tx_geshop_pi1[quantity]'].value")>0) {
			fehler="";
		}
	}
	if (fehler!="") { 
		window.alert(fehler); 
		if (thetype) {
			return false;
		} else {
			return;
		}
	}
	theform['tx_geshop_pi1[_submit_]'].value="1";
	theform.submit();

	if (thetype) {
		return true;
	}
}

function autoFocus( theform, pos ) {
	var i,color,size;
	i=0;
	while (true) {
		color = 'tx_geshop_pi1[color]['+i+']';
		size  = 'tx_geshop_pi1[size]['+i+']';
		if (theform[color]==null) {
			break;
		}
		if (pos!=i) {
			theform[color].selectedIndex=0;
			theform[size].selectedIndex=0;
		}
		i++;
	}
}

function submitBasket( theform, thetype ) {
	theform['tx_geshop_pi1[submitBasket]'].value="1";
	theform.submit();
	if (thetype) {
		return true;
	}
}

function closeBasket( theform, thetype, action ) {
	theform['tx_geshop_pi1[submitBasket]'].value="2";
	theform['tx_geshop_pi1[action]'].value=action;
	theform.submit();
	if (thetype) {
		return true;
	}
}

function removeFromBasket( theform, thefield ) {
	if (theform[thefield]!=null) {
		theform[thefield].value=0;
		theform['tx_geshop_pi1[submitBasket]'].value="1";
		theform.submit();
	}	
}

function makeBundle( theform, thefield ) {
	if (theform[thefield]!=null) {
		theform[thefield].value=1;
		theform['tx_geshop_pi1[submitBasket]'].value="1";
		theform.submit();
	}	
}

function zoom( small, big,ow,oh,w,h,vw,vh,view ) {
	e1= document.getElementById("img1");
	e2 = document.getElementById("img2");
	e3 = document.getElementById("img3");
	if (view==1) {
		e2.zoomit=false;
	}
	if (e2.zoomit) {
		e1.className="gehop-img";
		e2.src = small;
		e2.style.width =  ow+'px';
		e2.style.height = oh+'px';
		e2.style.position =  'static';
		e2.style.left =  0;
		e3.style.position = 'static';
		e3.style.width = '';
		e1.style.width =  '';
		e3.style.height =  '';
// e1.style.overflow = '';
// e1.style.background = 'none';
		e2.zoomit = false;
	} else {
		e1.className="gehop-img geshop-img-zoom";
		e2.src = big;		
		e2.style.width =  w+'px';
		e2.style.height = h+'px'; 
		e2.style.left = (vw-w>0?(vw-w)/2:0)+'px';
		e3.style.width = 'auto';
		e2.style.position = 'absolute';
		e3.style.height = (h>vh?vh:h)+'px';
		e3.style.position = 'relative';
		e1.style.width = vw+'px';
// e1.style.background = '#ffffff';
// e1.style.overflow = 'auto';
		
		// e.src = neues Bild;
		e2.zoomit = true;
	}
}


function showPrice( p, id ) {
	if (__lastFocus!=0) {
		__lastFocus.style.display="none";
	}
	e = document.getElementById(id);
	if (e.left !='' && e.top != '') {
		pos = GetElementAbsolutePos(p);
		e.style.left = pos.x-13+'px';
		e.style.top = pos.y-36+'px';
	}
	e.style.display='block';
	__lastFocus=e;
}
function showPrice2( id ) {
	e = document.getElementById(id);
	e.style.display='block';
}
function hidePrice( id ) {
	e = document.getElementById(id);
	e.style.display='none';
}   
   
 //returns the absolute position of some element within document  
 function GetElementAbsolutePos(element) {  
     var res = new Object();  
     res.x = 0; res.y = 0;  
     if (element !== null) {  
         res.x = element.offsetLeft;   
         res.y = element.offsetTop;   
           
         var offsetParent = element.offsetParent;  
         var parentNode = element.parentNode;  
   
         while (offsetParent !== null) {  
             res.x += offsetParent.offsetLeft;  
             res.y += offsetParent.offsetTop;  
   
             if (offsetParent != document.body && offsetParent != document.documentElement) {  
                 res.x -= offsetParent.scrollLeft;  
                 res.y -= offsetParent.scrollTop;  
             }  
             //next lines are necessary to support FireFox problem with offsetParent  
             if (__isFireFox) {  
                 while (offsetParent != parentNode && parentNode !== null) {  
                     res.x -= parentNode.scrollLeft;  
                     res.y -= parentNode.scrollTop;  
                       
                     parentNode = parentNode.parentNode;  
                 }      
             }  
             parentNode = offsetParent.parentNode;  
             offsetParent = offsetParent.offsetParent;  
         }  
     }  
     return res;  
 }
