var serverRoot = "/penaten/"; //top.location.href.split("index.jsp")[0].split(";")[0];//without index.jsp(if attached) and then no ;jsession

//---------------------------------------------------------------------------------------------

function changePic(name,newpic){
	if (document.images) //mouseover supported
		document.images[name].src = newpic;
}

//---------------------------------------------------------------------------------------------

function checkFrameset(){
	if(!top.frames.length>0)
		top.location.href=serverRoot + "index.jsp?fs=" + document.location.href;
}

//---------------------------------------------------------------------------------------------

function isIE(){
	return(navigator.appName.indexOf("Microsoft")!=-1);
}




//---------------------------------------------------------------------------------------------


function swapLayerContent(destLayer,srcLayer) {
	if(document.layers) { // Netscape 4.x
		document.layers[destLayer].document.open();
		document.layers[destLayer].document.write("NS4");
		document.layers[destLayer].document.close();
	}
	else if(document.all) { // Internet Explorer 4+
		document.all[destLayer].innerHTML=document.all[srcLayer].innerHTML;
	}
	else if(document.getElementById) { // W3C konform zB. Opera, Mozilla, Netscape 6+
		//var temp=document.createTextNode(text);
		var div1 = document.getElementById(destLayer);
		var div2 = document.getElementById(srcLayer);
		//alert("destLayer=" + destLayer);
		//alert("srcLayer=" + srcLayer);
		//alert("div1=" + div1);
		//alert("div2=" + div2);
		while (div1.hasChildNodes()) {
			div1.removeChild(div1.lastChild);
		}
		div1.appendChild(div2.cloneNode(true));
	}
}
//---------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------

function refreshNavigation(intMenuLevel1, intMenuLevel2){
	if(top.frames["navi"]){
		currentNaviL1 = (top.frames["navi"].document.forms[0])?top.frames["navi"].document.forms[0].firstLevel.value:0;
		currentNaviL2 = (top.frames["navi"].document.forms[0])?top.frames["navi"].document.forms[0].secondLevel.value:0;
		//alert("currentNaviL1:" + currentNaviL1 + " currentNaviL2:" + currentNaviL2);
		//alert("intMenuLevel1:" + intMenuLevel1 + " intMenuLevel2:" + intMenuLevel2);
		if(currentNaviL1!=intMenuLevel1 || currentNaviL2!=intMenuLevel2){
			//alert("reload navi...");
			top.frames["navi"].location.href = serverRoot + "navi.jsp?m1="+intMenuLevel1 + "&m2="+intMenuLevel2 ;

			if(top.frames["content"].frames.length){ //if left frame exists...
				currentLeft = top.frames["content"].frames["left"].location.href.split("/");
				currentRight = this.location.href.split("/");
				//alert("currentLeft:" + currentLeft[currentLeft.length-2] + " currentRight:" + currentRight[currentRight.length-2]);
				//if left frame doesn't correspond to right -->reload left...
				if(currentLeft[currentLeft.length-2] != currentRight[currentRight.length-2]){
					//alert("reload left...");
					top.frames["content"].frames["left"].location.href ="visual.jsp";
				}

			}//if(top.frames
		}//of if(currentNaviL1
	}
	else
		top.location.href=serverRoot + "index.jsp";
}

//---------------------------------------------------------------------------------------------

function popup(url,name,width,height) {
	popup(url,name, width, height,'');
	/*
	popupWin = window.open(url,name,"width="+width+",height="+height+",scrollbars=yes");
	x_pos = screen.width/2 - width/2;
	y_pos = screen.height/2 - height/2;
	//alert(x_pos);
	popupWin.moveTo(x_pos,y_pos);
	popupWin.focus();
	*/
}


//---------------------------------------------------------------------------------------------


function popup(url,name,width,height, customProperties) {
	popupProperties = (customProperties)?"width="+width+",height="+height+",scrollbars=yes, "+ customProperties:"width="+width+",height="+height+",scrollbars=yes";
	popupWin = window.open(url,name,popupProperties);
	x_pos = screen.width/2 - width/2;
	y_pos = screen.height/2 - height/2;
	//alert(x_pos);
	popupWin.moveTo(x_pos,y_pos);
	popupWin.focus();
}


//---------------------------------------------------------------------------------------------

function openContent(site){
	top.opener.top.content.location.href= serverRoot + site;
	top.close();
}
//---------------------------------------------------------------------------------------------

function openFaq(anker) {
	popup(serverRoot + 'beratung/faq/p_index.jsp#'+anker,'faqpopup', 486, 500);
}


//---------------------------------------------------------------------------------------------
function openInhaltsstoffe(anker) {
	popup(serverRoot + 'penaten_100jahrejung/philosophie/inhaltsstoffe/p_index.jsp#'+anker,'inhaltsstoffepopup', 486, 500);
}

function openSoothingNaturals(){
	popupWin = window.open(serverRoot + 'soothing_naturals/index.jsp','soothing_naturals','width=890,height=617,scrollbars=yes');

//	popup(,'SoothingNaturals',200,200);
}

//---------------------------------------------------------------------------------------------

function externalLink(url) {
	//alert(url);
	popup(serverRoot + 'site_utilities/p_externalLink.jsp?url=' + url,'externalLink', 1000, 589, 'menubar=1, toolbar=1, locationbar=1,location=1, personalbar=1, status=1, ,resizable=1');
}


function openNeuVonPenaten(){
	popup(serverRoot + 'produkte/neuvonpenaten/p_index.jsp','neuvonpenaten', 486, 500);
}
//---------------------------------------------------------------------------------------------
function openHomePageTeaser(lcation) {
	if ("mid") { //
		document.location.href = "produkte/reinigung_haut_haar/details/index.jsp?id=17";
	}
}


function openTeilnahmebedingungen(){
	popup(serverRoot + 'site_utilities/teilnahmebedingungen/p_index.jsp','teilnahmebedingungen', 486, 500);
}
//---------------------------------------------------------------------------------------------


function openFaqFamilienbuchAnmeldung(){
	popup(serverRoot + 'site_utilities/faq_familienbuchanmeldung/p_index.jsp','faq_familienbuchanmeldung', 486, 500);
}

//---------------------------------------------------------------------------------------------

function openFaqFotowettbewerb(){
	popup(serverRoot + 'site_utilities/faq_fotowettbewerb/p_index.jsp','faq_fotowettbewerb', 486, 500);
}
//---------------------------------------------------------------------------------------------
function openJunior(){
	document.location.href = serverRoot + "produkte/junior/index.jsp";
	//popup(serverRoot + 'junior/p_index.jsp','junior', 1013, 590);
	//window.open("http://www.penaten-junior.de");
}
//---------------------------------------------------------------------------------------------
function openJuniorHTML(){
	document.location.href = serverRoot + "produkte/junior/index.jsp";
	//popup(serverRoot + 'junior/html/p_index.jsp','junior_html', 953, 560);
	//window.open("http://www.penaten-junior.de");
}
//---------------------------------------------------------------------------------------------


function sendChristmasEcard(){
	popup(serverRoot + 'site_utilities/ecards/index_christmascard.jsp', 'christmasecard',600, 598);
}

//---------------------------------------------------------------------------------------------



function checkRadio(radioName, radiosAmount, radioNr, radioValue){
	//set the form value
	document.forms['formular'].elements[radioName].value = radioValue;
	//alert(document.forms[0].elements[radioName].value);

	radioImageHi = serverRoot + "art/btns/b_radiobutton_hi.gif";
	radioImageLo = serverRoot + "art/btns/b_radiobutton_lo.gif";

	//reset all
	for(i=1;i<=radiosAmount;i++){
		changePic(radioName+i,radioImageLo);
	}

	//highlight the clicked one
	changePic(radioName+radioNr,radioImageHi);
}



//---------------------------------------------------------------------------------------------

function checkCheckbox(cboxName){
	//set the form value
	cboxValue = document.forms['formular'].elements[cboxName].value;
	//alert(document.forms[0].elements[cboxName].value);
	if(cboxValue=="1"){

		document.forms['formular'].elements[cboxName].value = "0";
		cboxImage = serverRoot + "art/btns/b_checkbox_lo.gif";
	}
	else{
		document.forms['formular'].elements[cboxName].value = "1";
		cboxImage = serverRoot + "art/btns/b_checkbox_hi.gif";
	}
	//alert(document.forms[0].elements[cboxName].value);
	changePic(cboxName,cboxImage);
}

//---------------------------------------------------------------------------------------------
function tab(obj,nextobj,chars){

	if(!chars) chars = obj.size;
	if(obj.value.length>=chars){
		obj.value = obj.value.substr(0,chars);
		nextobj.focus();
	}
}

//---------------------------------------------------------------------------------------------
		/*
		Disable right click script II (on images)- By Dynamicdrive.com
		For full source, Terms of service, and 100s DTHML scripts
		Visit http://www.dynamicdrive.com
		*/

		var clickmessage="Right click disabled on images!"

		function disableclick(e) {

			/*if (document.all) {*/
				//alert("disableclick event.button=" + event.button );
				//alert("disableclick event.srcElement.tagName=" + event.srcElement.tagName);
/*
				if (event.button==2||event.button==3) {
					if (event.srcElement.tagName=="IMG"){
					alert(clickmessage);
					return false;
					}
				}
  */
			/*	
			}
			else if (document.layers) {
				//alert("disableclick e.button=" + e.button );

				if (e.which == 2 || e.which == 3) {
				alert(clickmessage);
				return false;
				}
			}
			else if (document.getElementById){
				//alert("disableclick e.button=" + e.button );
				//alert("disableclick event.srcElement.tagName=" + e.target.tagName);
				if ((e.button == 2 || e.button == 3)&&e.target.tagName=="IMG"){
				alert(clickmessage)
				return false
				}
			}
			*/
		}

		function associateimages(){
			for(i=0;i<document.images.length;i++)
			document.images[i].onmousedown=disableclick;
		}

		if (document.all)
			document.onmousedown=disableclick;
		else if (document.getElementById)
			document.onmouseup=disableclick;
		else if (document.layers)
			associateimages();

	function CreateFlash(DivID,content)
	{
		var d = document.getElementById(DivID);
		d.innerHTML = content;
	}
//---------------------------------------------------------------------------------------------

