window.defaultStatus = "web development by dg2";
var doAlerts=false;

function hand(theId) {
	if (document.all) {
		document.all(theId).style.cursor ='hand';
	}
	else {
		document.getElementById(theId).style.cursor ='pointer';
	}
}

function openPopup (width, height, image, title) {
	options = "width=" + (width + 20) + ",height=" + (height + 30) + ",location=no,menubar=no,status=no,resizable=yes,scrollbars=auto,toolbar=no";
	image = "images/" + image;
	window.open (image, title, options)
}

function changeButton(theId, state) {
	if (state == 'over') {
		document.getElementById(theId).style.color = '#666666';
		if (theId == 'loginButton') {
			document.getElementById(theId).style.border = '1px solid #666666';
		}
	}
	else {
		document.getElementById(theId).style.color = '#999999';
		if (theId == 'loginButton') {
			document.getElementById(theId).style.border = '1px solid #999999';
		}
		
	}
}

function checkClientNo(theId) {
	clientCount = theId.substring(11,12);
	if (document.getElementById(theId).checked == true) {
		for (var i = 2; i <= clientCount; i++) {
			showhide = "container_" + i;
			checkboxId = "teilnehmer_" + i;
			document.getElementById(showhide).style.display = 'inline';
		}
	}
	else {
		for (var i = 5; i >= clientCount; i--) {
			showhide = "container_" + i;
			checkboxId = "teilnehmer_" + i;
			document.getElementById(showhide).style.display = 'none';
			document.getElementById(checkboxId).checked = false;
		}
	
	}
}

function getPassword() {
	window.location.href = "index.php?id=40&no_cache=1&tx_newloginbox_pi1[forgot]=1";
}

/*function changeSheets(state){
alert (state);
	if(document.styleSheets){
	var c = document.styleSheets.length;
		if (doAlerts) alert(state + ' legend? - stylesheets: ' + c);
		if (state == 'show') {
			document.styleSheets[4].disabled=true;
			document.styleSheets[5].disabled=false;
		}
		else {
			document.styleSheets[4].disabled=false;
		}
		
	}
}*/

// 'getElementsWithClass' function
function getElementsWithClass(containingEl, tagName, className){
    
    var returnedCollection = new Array(0);

    var collection  = (containingEl.all && tagName == "*") ? 
     containingEl.all : containingEl.getElementsByTagName(tagName);
     
    for(var i = 0; i < collection.length; i++)
        if(collection[i].className == className)
            returnedCollection[returnedCollection.length] = collection[i];

    return returnedCollection;
}

// example 1: set display of 'elements with class' to a given style
 function setBgColor(tagName, className, theStyle) {
 
 	var theElements = getElementsWithClass(document, tagName, className);
 	
 	//alert (theElements.length)
 	
 	for(i = 0;i<theElements.length;i++) {
		
		theElements[i].style.backgroundColor = theStyle;
	}
}

function changeSheets(state){
	if(state == 'show') {
		document.body.style.backgroundColor = '#DDDDDD';
		document.getElementById('level_1_List').style.backgroundColor = '#99FF88';
		if (document.getElementById('level_2_List')) {
			document.getElementById('level_2_List').style.backgroundColor = '#AAFF88';
		}
		document.getElementById('centerContent').style.backgroundColor = '#FFFF66';
		document.getElementById('footer').style.backgroundColor = '#BBFFFF';
		document.getElementById('noLegend').style.display = 'none';
		document.getElementById('legend').style.display = 'block';
		setBgColor('div', 'floatLeft metaNav1', '#55FF99');
		setBgColor('div', 'floatRight metaNav2', '#99FFAA');
		setBgColor('div', 'teaserBoxSingle', '#BBFFFF');
		setBgColor('div', 'teaserBox', '#FFBBBB');
		document.getElementById('allContainer').style.top = '145px';
		document.getElementById('logoArea').style.top = '163px';
		document.getElementById('logoArea').style.backgroundColor = '#FFFFFF';
		document.getElementById('topVisualHolder').style.backgroundColor = '#FFFFFF';
		document.getElementById('topVisual').style.display = 'none';
		document.getElementById('legendContainer').style.backgroundColor = '#DDDDDD';
	}
	else {
		document.body.style.backgroundColor = '#0088E0';
		document.getElementById('level_1_List').style.backgroundColor = '#0088E0';
		if (document.getElementById('level_2_List')) {
			document.getElementById('level_2_List').style.backgroundColor = 'transparent';
		}
		document.getElementById('centerContent').style.backgroundColor = '#0079C2';
		document.getElementById('footer').style.backgroundColor = '#0088E0';
		document.getElementById('legend').style.display = 'none';
		document.getElementById('noLegend').style.display = 'block';
		setBgColor('div', 'floatLeft metaNav1', '#29AAEA');
		setBgColor('div', 'floatRight metaNav2', '#29AAEA');
		setBgColor('div', 'teaserBoxSingle', '#FFFFFF');
		setBgColor('div', 'teaserBox', '#FFFFFF');
		document.getElementById('allContainer').style.top = '40px';
		document.getElementById('logoArea').style.top = '60px';
		document.getElementById('logoArea').style.backgroundColor = 'transparent';
		document.getElementById('topVisualHolder').style.backgroundColor = '#0079C2';
		document.getElementById('topVisual').style.display = 'block';
		document.getElementById('legendContainer').style.backgroundColor = '#FFFFFF';
	}
}

function changeTemplateImg() {
	templateImageName = new Array("Amsterdam", "Paris", "London");
	changeTo = document.getElementById('template').value;
	path = "fileadmin/templates/template_images/template_" + templateImageName[changeTo] + ".jpg";
	document.getElementById('templateImage').src = path;
}

function applyTemplate() {
	pageLocation = window.location.href;
	pageLocationClean = pageLocation.replace(/&type=0/, "");
	pageLocationClean = pageLocationClean.replace(/&type=1/, "");
	pageLocationClean = pageLocationClean.replace(/&type=2/, "");
	//alert (pageLocation + " - " + pageLocationClean)
	pageLocationEnd = pageLocation.substr((pageLocation.length -1), 1);
	if (pageLocationEnd == '/') {
		stringToAppend = "index.php?type=" + document.getElementById('template').value;
	}
	else {
		stringToAppend = "&type=" + document.getElementById('template').value;
	}
	//alert (stringToAppend);
	newLoc = pageLocationClean + stringToAppend;
	location.href = newLoc;;
}