var shopInfo = false;

function popup(url,name,params) {
	var sizeX = 0;
	var sizeY = 0;
	var winX = screen.availWidth;
	var winY = screen.availHeight;
	var tmpArray = params.split(',');
	for (var i = 0; i < tmpArray.length; i++) {
		if (tmpArray[i].indexOf('width') != -1) {
			var tmpArray2 = tmpArray[i].split('=');
			sizeX = tmpArray2[1];
		}
		if (tmpArray[i].indexOf('height') != -1) {
			var tmpArray2 = tmpArray[i].split('=');
			sizeY = tmpArray2[1];
		}
	}
	var centerX = Math.round(winX / 2 - sizeX / 2);
	var centerY = Math.round(winY / 2 - sizeY / 2);
	params += ',left=' + centerX + ',top=' + centerY;
	var pWindow = open(url,name,params).focus();
}

function openLink(o) {
	var link = o.getElementsByTagName('a')[o.getElementsByTagName('a').length - 1];
	if (!link.onclick) location.href = link.href;
	else link.onclick();
}

function switchImage(destination,source) {
	if (imgArray && imgArray[source]) document.images[destination].src = imgArray[source].src;
}

function toggleShopInfo() {
	if (shopInfo) {
		document.getElementById('shop_info').style.display = 'none';
		document.getElementById('shopInfoLi').style.background = 'transparent url("/de/shop/images/bt_arrow_right.gif") no-repeat top left';
		shopInfo = false;
	}
	else {
		document.getElementById('shop_info').style.display = 'inline';
		document.getElementById('shopInfoLi').style.background = 'transparent url("/de/shop/images/bt_arrow_down.gif") no-repeat top left';
		shopInfo = true;
	}
}
function toggleShopImpr() {
	if (shopInfo) {
		document.getElementById('shop_impr').style.display = 'none';
		document.getElementById('shopImprLi').style.background = 'transparent url("/de/shop/images/bt_arrow_right.gif") no-repeat top left';
		shopInfo = false;
	}
	else {
		document.getElementById('shop_impr').style.display = 'inline';
		document.getElementById('shopImprLi').style.background = 'transparent url("/de/shop/images/bt_arrow_down.gif") no-repeat top left';
		shopInfo = true;
	}
}
function subForm(imgNr){
	document.ecard.image.value = imgNr;
	//document.ecard.changeImage.value = 1;
	document.ecard.submit();
}

function showPK(nr){
	document.paten.showMore.value = '1';
	if (nr == 2) document.paten.pk2.value = '1';
	if (nr == 3) document.paten.pk3.value = '1';
	document.paten.submit();
}

function hidePK(nr){
	document.paten.showMore.value = '1';
	if (nr == 2) document.paten.pk2.value = '0';
	if (nr == 3) document.paten.pk3.value = '0';
	document.paten.submit();
}

function showSearch(){
	document.getElementById('searchBox').style.visibility = 'visible';
}

function hideSearch(){
	document.getElementById('searchBox').style.visibility = 'hidden';
}

function clearCell(el){
	var str1 = 'Erzählen Sie beispielsweise, was Sie beruflich und/oder in Ihrer Freizeit machen. Oder sind Sie vielleicht ehrenamtlich in einer Aktionsgruppe aktiv?';
	var str2 = 'Erzählen Sie zum Beispiel, was Ihr Beweggrund für eine Patenschaft bei Plan ist.';
	var str3 = 'Erzählen Sie etwas über Ihr Patenkind. Wichtiger Hinweis zum Schutz der Kinder: Bitte vermeiden Sie die Nennung des Familiennamens des Kindes sowie Angaben über seinen genauen Wohnort.';
	var str4 = 'Erzählen Sie in welchem Land Ihr Patenkind lebt, welche Umstände zum Alltag gehören. Wie groß ist die Familie? Haben Sie es sogar schon einmal besucht? Berichten Sie.';
	var str5 = 'Erzählen Sie in welchem Land Ihr Patenkind lebt, welche Umstände zum Alltag gehören. Wie groß ist die Familie? Haben Sie es sogar schon einmal besucht? Berichten Sie.';
	if (el == '1' && str1 == document.getElementById('por_ueber').value) document.getElementById('por_ueber').value = '';
	if (el == '2' && str2 == document.getElementById('por_warum').value) document.getElementById('por_warum').value = '';
	if (el == '3' && str3 == document.getElementById('pk_1_ueber').value) document.getElementById('pk_1_ueber').value = '';
	if (el == '4' && str4 == document.getElementById('pk_2_ueber').value) document.getElementById('pk_2_ueber').value = '';
	if (el == '5' && str5 == document.getElementById('pk_3_ueber').value) document.getElementById('pk_3_ueber').value = '';
}

function kontrolle1(num){
	var x = document.paten.por_ueber.value;
	if( x.length > num ) x = x.substring( 0, num );
	document.paten.por_ueber.value = x;
	document.getElementById("por_ueber").style.color = "#000000";
}

function kontrolle2(num){
	var x = document.paten.por_warum.value;
	if( x.length > num ) x = x.substring( 0, num );
	document.paten.por_warum.value = x;
	document.getElementById("por_warum").style.color = "#000000";
}

function kontrolle3(num){
	var x = document.paten.pk_1_ueber.value;
	if( x.length > num ) x = x.substring( 0, num );
	document.paten.pk_1_ueber.value = x;
	document.getElementById("pk_1_ueber").style.color = "#000000";
}

function kontrolle4(num){
	var x = document.paten.pk_2_ueber.value;
	if( x.length > num ) x = x.substring( 0, num );
	document.paten.pk_2_ueber.value = x;
	document.getElementById("pk_2_ueber").style.color = "#000000";
}

function kontrolle5(num){
	var x = document.paten.pk_3_ueber.value;
	if( x.length > num ) x = x.substring( 0, num );
	document.paten.pk_3_ueber.value = x;
	document.getElementById("pk_3_ueber").style.color = "#000000";
}