function lostPassword() {
		open("lost_password.jsp", "passwordWindow", "menubar=no, width=360, height=250");
	}
function checkHeader() {
    var headerName = parent.header.location.pathname;
    if (headerName.indexOf("log_header.jsp") == -1) {
        parent.header.location.href = "log_header.jsp";
    }
}
function checkUserInfoForm() {
    //TODO:
}

function clickElement( id )
{
    var el = document.getElementById( id );
    if( el != null )
    {
        el.click();
    }
}

function getElement(elID) {
    return document.getElementById( elID );
}

function getElementsByName(elName) {
    return document.getElementsByName( elName );
}

function hinweis() {
	alert("Der Artikel wird in den Warenkorb gelegt!\n\nDie Aufnahme in den Warenkorb ist keine verbindliche Bestellung.");
}

function nl_fenster() {
	popunder = window.open("tmpl/newsletter_info.php?kid=&src=", "nl_popup", "width=255,height=250,scrollbars=1,resizable=0,toolbar=0,location=0,menubar=0,status=0,directories=0");
			if(popunder) { popunder.blur(); }
			window.focus();}

function firstgate_fenster() {
	firstgatepopup = window.open("tmpl/firstgate_info.php?kid=&src=", "firstgate_popup", "width=250,height=350,scrollbars=1,resizable=0,toolbar=0,location=0,menubar=0,status=0,directories=0");
	setTimeout("firstgatepopup.focus()", 4000);
}

function submitForm( formID )
{
	var form = getElement( formID );
	if( form == null )
    {
        var forms = getElementsByName( formID );
        forms[0].submit();
    }
    else
    {
        form.submit();
    }
}

function fixPNG(element)
{
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
  {
    var src;

      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      if (src)
      {
        src = src[1];
        element.runtimeStyle.backgroundImage="none";
      }
    if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
  }
}
function openpict( screenshotUrl, imageSrc)
{
    var url = screenshotUrl + "?src=" + imageSrc;
    window.open(url,"ScreenshotDetail","top=100, left=100, width=860, height=620,scrollbars=1,resizable=0,toolbar=0,location=0,menubar=0,status=0,directories=0");
}

function enableElements(ids)
{
    for ( var i =0; i < ids.length; i++ )
    {
        var el = document.getElementById( ids[i] );
        el.disabled = false;
    }
}

function disableElements(ids)
{
    for ( var i =0; i < ids.length; i++ )
    {
        var el = document.getElementById( ids[i] );
        el.disabled = true;
    }
}

function toggleAdditionalUserInfo(
    checkboxIDs, toggleElementId, excludeParameters, excludeParametersInp, disableClassName, enableClassName )
{
    var displayedElement = document.getElementById( toggleElementId );
    var excludeElement = document.getElementById( excludeParametersInp );
    for ( var i=0; i < checkboxIDs.length; i++ )
    {
        var el = document.getElementById( checkboxIDs[i] );
        if ( el.checked )
        {
            displayedElement.className = enableClassName;
            excludeElement.value = "";
            return;
        }
    }
    displayedElement.className = disableClassName;
    excludeElement.value = excludeParameters;
}

function changecheckbox(obj, newsletterIDList)
{
    for ( var i =0; i < newsletterIDList.length; i++ )
    {
        var el = document.getElementById( newsletterIDList[i] );
        if ( obj.checked )
        {
            el.disabled = false;
        }
        else
        {
            el.disabled = true;
        }
    }
}

function hidelayer(div)
{
    document.getElementById(div).style.display = "none";
}

function showlayer(div)
{       
    document.getElementById(div).style.display = "block";
}

function userAdvisePreview( previewURL, adviseObjectName )
{
    var email = document.getElementById( "email0" );
    var firstName = document.getElementById( "firstName0" );
    var userAdviseText = document.getElementById( "userAdviseText" );
    var url = previewURL + "&adviseObjectName=" + adviseObjectName + "&email=" + email.value + "&firstName=" + firstName.value + "&userAdviseText=" + userAdviseText.value;
    window.open(url);
}

function openLostPasswordWindow( url )
{
    var el = document.getElementById( "emailInput" );
    window.open( url + "?email=" + el.value );
}

/*===========================*/
        /*Hint Box*/
/*===========================*/

var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype)
{
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
    var parentEl=what.offsetParent;
    while (parentEl!=null)
    {
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl=parentEl.offsetParent;
    }
    return totaloffset;
}

function iecompattest()
{
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge)
{
    var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
    if (whichedge=="rightedge")
    {
        var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
        dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
        if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
    }
    else
    {
        var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
        dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
        if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
    }
    return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth, tipheight)
{
    if ((ie||ns6) && document.getElementById("hintbox"))
    {
        dropmenuobj=document.getElementById("hintbox")
        dropmenuobj.innerHTML="<iframe src=" + menucontents + " frameborder=0 scrolling=no class=hintframe width=" + tipwidth + " height=" + tipheight + "/>"; //menucontents
        dropmenuobj.style.left=dropmenuobj.style.top=-500
        if (tipwidth!="")
        {
            dropmenuobj.widthobj=dropmenuobj.style
            dropmenuobj.widthobj.width=tipwidth
        }
        dropmenuobj.x=getposOffset(obj, "left")
        dropmenuobj.y=getposOffset(obj, "top")
        dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
        dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
        dropmenuobj.style.visibility="visible"
        obj.onmouseout=hidetip
    }
}

function hidetip(e)
{
    dropmenuobj.style.visibility="hidden"
    dropmenuobj.style.left="-500px"
}

function createhintbox()
{
    var divblock=document.createElement("div")
    divblock.setAttribute("id", "hintbox")
    document.body.appendChild(divblock)
}

if (window.addEventListener)
    window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
    window.attachEvent("onload", createhintbox)
else if (document.getElementById)
    window.onload=createhintbox

/*===========================*/
        /*End Hint Box*/
/*===========================*/


/*Advise Form*/

function advise_form_onfocus(txt) {
  if (txt.value == 'Type in e-mail addresses separating them with a space.') {
    txt.value = '';
    txt.className = 'textArea';
  }
}

function advise_form_onblur(txt) {
  if (txt.value == '') {
    txt.value = 'Type in e-mail addresses separating them with a space.';
    txt.className = 'defaultText';
  }
}
