/**
* rashop.js
*
* javascript used in the rashop
*
* @author       Lars Wolff <lw@synpro-digital.de>
* @copyright    2004
* @version      1.0
* @package      rashop
*
* $Id: rashop.js 576 2007-10-13 21:56:10Z larsvegas $
*/


/**
* switchCSSPropDiplayByElementId
* switch the style property display to visible or hidden
*
* @param string id of the element
* @param string direction, default: null, possible: close (to hide element)
* @param string showtype property to use to show the element, default: inline
*
* @author       Lars Wolff <lw@synpro-digital.de>
* @copyright    2006
* @version      1.0
* @package      rashop
*/
function switchCSSPropDiplayByElementId(ID,DIRECTION,SHOWTYPE) {
	if(SHOWTYPE == null) {
		SHOWTYPE = "inline";
	}
	
	if(DIRECTION == null) {
		DIRECTION = "auto";
	}
	
	var objInlineContent = document.getElementById(ID);
	
	if(DIRECTION != "auto") {
		if(DIRECTION == "close") {
			objInlineContent.style.display = "none";
		}
		else {
			objInlineContent.style.display = SHOWTYPE;
		}
	}
	else {
		if(objInlineContent.style.display == "inline" || objInlineContent.style.display == "block") {
    	    objInlineContent.style.display = "none";
	    }
		else {
	        objInlineContent.style.display = SHOWTYPE;
		}
	}
}
										

/**
* WADIui_inlinecontent
* switch the style property display to visible or hidden
*
* @param int CONTENTID the content id of the div
*
* @author       Lars Wolff <lw@synpro-digital.de>
* @copyright    2004
* @version      1.1
* @package      rashop / WADI
* @see      	WADI
* @history 		20060920 exclude functionality of
*				switchCSSPropDiplayByElementId to
*				a extern function
*/
function WADIui_inlinecontent(CONTENTID) {
    //objInlineContent = document.getElementById("WADIui_InlineContent_" + CONTENTID);
    objSwitchOn = document.getElementById("WADIui_SwitchON_" + CONTENTID);
    objSwitchOff = document.getElementById("WADIui_SwitchOFF_" + CONTENTID);
    objID = "WADIui_InlineContent_" + CONTENTID;
	
	//	alert(objSwitchOn + "\n" + objSwitchOff);

	if(objSwitchOn.style.display == "inline" && objSwitchOff.style.display == "none") {
        //objInlineContent.style.display = "block";
		switchCSSPropDiplayByElementId(objID);
		
		//if(objSwitchOn != null && objSwitchOff != null) {
	        objSwitchOff.style.display = "inline";
       		objSwitchOn.style.display = "none";
		//}
    }
    else {
        if(objSwitchOff.style.display == "inline" && objSwitchOn.style.display == "none") {
            //objInlineContent.style.display = "none";
			switchCSSPropDiplayByElementId(objID);
			
			//if(objSwitchOn != null && objSwitchOff != null) {
            	objSwitchOn.style.display = "inline";
	            objSwitchOff.style.display = "none";
			//}
        }
    }
}


/*
function ras_formQtyCheck(QTY) {
	if(isNaN(QTY) == true || QTY < 1) {
		alert("Bitte geben Sie eine Ganzzahl an");
	}
}
*/
function ras_formQtyCheck(oQTY) {
//	alert(oQTY + "\n" + "[" + oQTY.value + "]");
	//alert(isNaN(oQTY.value));
	/*
	if(isNaN(oQTY.value) == true || oQTY.value < 1) {
		oQTY.value = 1;
		alert("Sie haben keine Anzahl eingetragen, die Anzahl für das gewünschte Produkt wurde auf 1 gesetzt.");
	}
	return true;
	*/
}

function ras_showModuleTellAFriend(PID,PROD,ITEMNR,PRICE) {
	$('divTAFprodname').innerHTML = PROD;
	$('divTAFitemnumber').innerHTML = ITEMNR;
	$('divTAFprice').innerHTML = PRICE + '&euro;';
	$('tafpid').value = PID;
	
	new Effect.BlindDown('divUItellafriend');
}



/**
* SWAP Images
*/
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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;
}

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];}
}



/**
* prodProp
*
*/
var prodProp = new Array();

/**
* updatePmProperties
* updates the product mutation properties on selection
*
*/
function updatePmProperties(ObjProps) {
	var pId = prodProp[ObjProps]['pId'];
	document.getElementById('pmItemnumber-' + pId).innerHTML = prodProp[ObjProps]['pmItemnumber'];
	document.getElementById('pmPriceBrutto-' + pId).innerHTML = prodProp[ObjProps]['pmPriceBrutto'];
	document.getElementById('pmPriceNetto-' + pId).innerHTML = prodProp[ObjProps]['pmPriceNetto'];
	new Effect.Highlight('pmPriceNetto-' + pId);
	new Effect.Highlight('pmPriceBrutto-' + pId);
	new Effect.Highlight('pmItemnumber-' + pId);
}