﻿//JavaScript - Library
// All rights reserved on concept, design and solution as well as on attached files
// Copyright by medialink 2010 - v9.05.010/22.11.2010
// -----------------------------------------------------------------------------------



//----- init-section ---------------------------------------------------------------------------


//setting the header images
function doinit(){
	z = getRandom();
	if (document.images){
		document.images['headimage'].src =  "/fileadmin/resources/various/header/headimage" + z + ".jpg";
	}
}


function getRandom(){
	var zMax = 9;
	var z = Math.random();
	z = Math.floor(z*10) + 1;
	if (z > zMax){
		z = zMax;
	}
	return z;
}


function writeHeadtext(){
	z = getRandom();
	document.write(headimagetext[z]);
}



//----- image section ------------------------------------------------------------------
if (document.images){

	var imageov = new Array();
	var imageof = new Array();
	
	//other icons/signs
	imageov['bgButtonOv']      = new Image();
	imageov['bgButtonOv'].src  = "/fileadmin/resources/various/header/bgButtonOv.jpg";
	imageof['bgButtonOf']      = new Image();
	imageof['bgButtonOf'].src  = "/fileadmin/resources/various/header/bgButtonOf.jpg";
}


function imgov(i){
	if (document.images){
		document.images[i].src = imageov[i].src;
	}		
}

function imgof(i){
	if (document.images){
		document.images[i].src = imageof[i].src;
	}
}





//-----form-functions---------------------------------------------------------------------------


//form-send
function formSend(t){

	if (t == "search"){		
		if (document.formSearch.searchterm.value == ""){
			alert(msgFormNoSearchEntry);
		}else{
			document.formSearch.submit();
		}
	}

}





//-----various---------------------------------------------------------------------------
function buttonBgChange(divId,p){
	document.getElementById(divId).style.backgroundImage = "url(/fileadmin/templates/images/bgButton" + p + ".jpg)";
}






//-----cookie-functions
//Derived from the Bill Dortch code at http://www.hidaho.com/cookies/cookie.txt
//Adapted by medialink Switzerland - Version 1.01a / 30.05.2006
//-----------------------------------------------------------------------------------

var today = new Date();
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
	}

function GetCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return getCookieVal (j);
			}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
		}
	return null;
	}

function DeleteCookie(name,path,domain) {
	if (GetCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	}

function SetCookie(name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
	}

var cookieOK = false;
function cookieCheck(){
	SetCookie("cookieChecker","CheckingForCookieFunction",0,"/");	//when setting expTime: attn. GTM-problem NS4.05WIN
	if (GetCookie("cookieChecker") != null){						//no Time set: is a session cookie
		cookieOK = true;
	}
}



//--- end of file

