/* -----------------------------------------------------------*/
/*
*	Copyright 2004 bildunion.de
*	global.js - global js file
*
*	AUTHOR:
*	goma - Gordon Marshall - marshall(at)bildunion(dot)de
*
*	LAST MODIFIED:
*	goma, 11.02.2007
*/
/* -----------------------------------------------------------*/


// ------------------------- globale Variablen ---------------------------------------------------

var strings = new Array();
strings["de"] = new Object();
strings["en"] = new Object();

strings["de"]["checkall"]		= "Alle markieren";
strings["de"]["checknone"]		= "Keine markieren";

strings["en"]["checkall"]		= "Select all";
strings["en"]["checknone"]		= "Select none";



function addLoadEvent(func) {
	var oldonload = window.onload;
	if(typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() { 
			oldonload();
			func();
		}
	}
}

function addResizeEvent(func) {
	var oldonresize = window.onresize;
	if(typeof window.onresize != 'function') {
		window.onresize = func;
	}
	else {
		window.onresize = function() { 
			oldonresize();
			func();
		}
	}
}

// Flag für Internet Explorer
var ie = (document.all && navigator.appVersion.substring(0,1) >= 4) ? true : false;



// Kategorien selektieren/deselektieren
function checkCats() {
	var myForm = document.searchform;
	if (myForm.cat0.checked) {
		for (i=0; i < myForm.elements.length; i++) {
			if (myForm[i].type == 'checkbox' && myForm[i].name.indexOf('cat') != -1) {
				myForm[i].checked = true;
			}
		}
	}
	else {
		for (i=0; i < myForm.elements.length; i++) {
			if (myForm[i].type == 'checkbox' && myForm[i].name.indexOf('cat') != -1) {
				myForm[i].checked = false;
			}
		}
	}
}



// Checkbox "Alle Kategorien" selektieren/deselektieren
function checkAllCats(elem) {
	var myForm = document.searchform;
	var dontCheck = false;
	if (myForm.elements[elem].checked) {
		for (i=0; i < myForm.elements.length; i++) {
			if (myForm[i].type == 'checkbox' &&
				myForm[i].name.indexOf('cat') != -1 &&
				myForm[i].name != 'cat0') {
				if (myForm[i].checked == false) {
					dontCheck = true;
					break;
				}
			}
		}
		if (dontCheck == false) myForm.cat0.checked = true;
	}
	else {
		myForm.cat0.checked = false;
	}
}



// Anti-Spam
function buAntiSpam(addy,subj) {
	if (addy != "") {
		document.write ('<a href="mailto:' + addy + '@' + 'bildunion' + '.de?subject=' +
						subj + '">' + addy + '@' + 'bildunion' + '.de</a>');
	}
}



// Registrierungsseite anzeigen
function mainWinGo(url) {
	sw = screen.availWidth;
	sh = screen.availHeight-50;
	if (ie) {
		sw -= 12;
		sh -= 115;
	}
	if (window.opener != null && window.opener.location && !window.opener.closed) {
		if (window.opener.name != "detailWin") {
			window.opener.location.href = url;
			window.opener.focus();
		}
		else if (window.opener.opener != null && window.opener.opener.location && !window.opener.opener.closed) {
			window.opener.opener.location.href = url;
			window.opener.opener.focus();
		}
		else {
			newMainWin = window.open(url,'newMainWin','width='+sw+',height='+sh+',scrollbars=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes,location=yes');
			newMainWin.window.moveTo(0,0);
			if (newMainWin.focus) newMainWin.focus();
		}
	}
	else {
		newMainWin = window.open(url,'newMainWin','width='+sw+',height='+sh+',scrollbars=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes,location=yes');
		newMainWin.window.moveTo(0,0);
		if (newMainWin.focus) newMainWin.focus();
	}
}



var newWin = '';
// Popup oeffnen
function openWindow(url,winName,w,h,sb) {
	if (h == 0) {
		h = screen.availHeight-50;		
	}
	newWin = window.open(url, winName, 'width=' + w + ', height=' + h + ', scrollbars=' + sb + ', toolbar=no, location=no, status=yes, menubar=no, resizable=no, left=0, top=0');
	//newWin.window.moveTo(0,0);
	if (newWin.focus) newWin.focus();
	return false;
}




function checkPrivateCustomer(theForm) {
	if (theForm.isPrivateCustomer.value == "1") {
		document.getElementById('companyPlaceholder').style.display = 'none';
	}
	else {
		document.getElementById('companyPlaceholder').style.display = 'block';
	}
}


// alle checkboxen selektieren/deselektieren
function checkCheckBoxes(myForm, prefix, myButton, myLang) {
	eval("myForm = document." + myForm);
	eval("myButton = myForm." + myButton);
	action = myButton.value;

	if (action == strings[myLang]["checkall"]) {
		blnAction = true;
		strAction = strings[myLang]["checknone"];
	}
	else {
		blnAction = false;
		strAction = strings[myLang]["checkall"];
	}
	for (i=0; i < myForm.elements.length; i++) {
		if (myForm[i].type == 'checkbox' && myForm[i].name.indexOf(prefix) != -1) {
			myForm[i].checked = blnAction;
			myButton.value = strAction;
		}
	}
}


