
var minWinHeight = 600;
var topmargin = 55;
var headerHeight = 205;
var naviHeight = 85;
var indexHeight = 373;


var staticLinksCounr = 0;
var cat1 = "";
var cat2 = "";
var topFilename = "";

var myImages = new Array();


function calculateHeight() {
    if(window.innerHeight) {
        height = window.innerHeight;        
    }
    else if(document.body) {
        height = document.documentElement.clientHeight;
    }
        
    if(height < (minWinHeight+40)) {
        contentHeight = 245;
    } 
    else {
    	contentHeight = height - (2*topmargin) - headerHeight - 35;
    }  
    
    if(document.getElementById("starttextcontainer") && (contentHeight > indexHeight)) {
    	contentHeight = indexHeight;
    }
    
    return(contentHeight);
}

function setHeight() {
    contentHeight = calculateHeight();
      
	//alert(height);
    totalHeight = contentHeight + headerHeight;
      
    contentBox = document.getElementById("content");
    contentDiv = document.getElementById("contentdiv");
    spacer = document.getElementById("leftred");
    
    contentBox.style.height = contentHeight + "px";
    contentDiv.style.height = totalHeight + naviHeight + "px";
    spacer.style.height = totalHeight + "px";
    
    //document.getElementById("navicontainer").style.display="none";
    document.getElementById("navicontainer").style.display="";    
}

function navOver(theElement) {
	theSource = theElement.src;
	newSource = theSource.replace(/_pas./,"_act.");
	theElement.src = newSource;
}

function navOut(theElement) {
	theSource = theElement.src;
	sourceArray = theSource.split("/");
    arrayLength = sourceArray.length - 1;
    var thisFilename = sourceArray[arrayLength];
    filenameArray = thisFilename.split("_");
    thisFilename = filenameArray[0];
    	
	if((thisFilename != extractFilename()) && (thisFilename != topFilename)) {
		newSource = theSource.replace(/_act./,"_pas.");
		theElement.src = newSource;
	}
}

function nav1active(topFilename) {
	if(topFilename) {
		theFilename = topFilename;				
	}
	else {
		theFilename = extractFilename();
	}
	
	if(document.getElementById(theFilename)) {
		document.getElementById(theFilename).src = "img/navi/" + theFilename + "_act.gif";
	}
	
	if(document.getElementById("nav_"+theFilename)) {					//zugehoerige subnavi ausklappen
		document.getElementById("nav_"+theFilename).style.display = "";
	}
}

function prenav2() {
	for(i=1; i<document.links.length; i++) {
		if(document.links[i].className) {	
			linkClass = document.links[i].className;
			if((linkClass == "sublink") && (document.links[i].href == window.location.href)) {
				linkText = document.links[i].firstChild.data;
				cat1 = linkText;
			}
		}
	}	
}

function resetForm() {
	killCookie();	
	document.forms[0].reset();	
	document.getElementById("theTextarea").value = "Anfrage Produkt(e), Ihre Nachricht";
}


///////////////////////////////////////////////////////

function textareaPop(newSrc) {
	var links = document.getElementsByTagName('a');
	for(var i = 0; tag = links[i]; ++i) {
		if(tag.className == 'poplink') {
			tag.target = 'popwindow';
			tag.onclick = openPwin;
	  	}
	  	else if(tag.className == 'querverweis') {
			tagData = tag.firstChild.data;
	  	
	  		if(tag.innerHTML) {
				tag.innerHTML = '<img src="' + newSrc + '">' + tagData;
	  		}
	  		else {	  		
				theLink = tag.firstChild;
				theArrow = document.createElement('img');
				arrowSrc = document.createAttribute('src');
				arrowSrc.nodeValue = newSrc;
				theArrow.setAttributeNode(arrowSrc);
				tag.insertBefore(theArrow,theLink);
	  		}
	  	}	  		  	     
	}		
}

function openPwin() {
	var pwin = window.open(this.href, 'popwindow', 'width=950,height=600,scrollbars=no');
	try { pwin.focus(); } catch(e) {}
	return false;
}

//preload!!
var myImages = new Array();
function preloadImages() {
    for (i=0;i<preloadImages.arguments.length;i++) {
        myImages[i] = new Image();
        myImages[i].src = preloadImages.arguments[i];
    }
}

function extractFilename() {
    var thisUrl = window.location.href;

    urlArray = thisUrl.split("/");
    arrayLength = urlArray.length - 1;
    var thisFilename = urlArray[arrayLength];
    filenameArray = thisFilename.split(".");
    thisFilename = filenameArray[0];
    
    if(!thisFilename) {
        thisFilename = "index";
    }
    
    if(thisFilename == "start") {
        thisFilename = "index";
    }
       
    return(thisFilename);
}

function preloadEverything() {
	preloadImages("img/navi/aktuelles_act.gif","img/navi/hauskrankenpflege_act.gif","img/navi/kontakt_act.gif","img/navi/landesverband_act.gif","img/navi/leistungsangebot_act.gif","img/navi/vereine_act.gif","img/navi/hkv_btn_07_act.gif","img/navi/hkv_btn_09_act.gif");
}


function popNewsletter(inout) {
    address = document.forms["optinout"].elements[0].value;
    if(address && (address!="Ihre E-Mailadresse")) {
        var url = "http://www.247hosting.at/newsletter/schraml/optinout.php?inOut="+inout+"&address="+address;
        window.open(url,"optWin","width=300,height=180,top=50,left=100,scrollbars=no");
    }
    else {
        alert("Bitte geben Sie eine Adresse ein.");
    }
}


function prodDetails(id,cat2) {
	prodDetWin = window.open("produktdetails.php?id="+id+"&cat2="+cat2,"detWin","width=760,height=380,top=50,left=60,scrollbars=yes");
	prodDetWin.focus();
}

function newsDetails(id) {
	newsDetWin = window.open("newsdetails.php?id="+id,"detWin","width=610,height=380,top=50,left=60,scrollbars=yes");
	newsDetWin.focus();
}
