function Resize(name)
{
	// popUpName = name;
	popUpName = "popUp";
	thisHeight = screen.availHeight - 50;
	thisWidth = screen.availWidth - 10;
	// alert(screen.availHeight + " / " + thisHeight);
	window.open('showStamp.php?img='+name,popUpName,'height='+thisHeight+',width='+thisWidth);
}

//-------------------------------------------

function setFocus(formName, formField)
{	
	form = window.document.forms[formName];	
	if(form.elements[formField])
	{
		window.document.forms[formName].elements[formField].focus();
	}
}

//-------------------------------------------

function searchWord(formName, formField)
{
	var submitThis = false;
	
	if(formField == "lookForWord1")
	{
		if(window.document.forms[formName].elements[formField].value != "")
		{
			submitThis = true;
		}
	}
	else if(formField == "lookForWord2")
	{
		if(window.document.forms[formName].elements[formField].options[window.document.forms[formName].elements[formField].selectedIndex].value != "")
		{			
			submitThis = true;
		}
	}
	if(submitThis)
	{
		window.document.forms[formName].submit();
	}
}

//-------------------------------------------

function openWindow(file, name, width, height, top, left, scroll, resizable)
{
	window.open(file, name, "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + ",scrollbars=" + scroll + ",resizable=" + resizable + ",status=yes");
}

//-------------------------------------------

function detectIfPopUp(openFile)
{
	if(!opener) { window.document.location.href = openFile; }	
}

//-------------------------------------------

function submitThis(caller, page, path)
{
	var form = window.document.forms[caller];
	var sess = form.sess.value;
	var mode = form.mode.value;
	var url = page + "?sess=" + sess;
	//alert(mode);
	
	if(mode == "edit")
	{
		alert('Bitte speichern Sie erst oder klicken Sie "Abbrechen"!');
	}
	else 
	{
		if(path != "links" && path != "create")
		{
			editCountryCode = form.elements["editCountryCode"].options[form.elements["editCountryCode"].selectedIndex].value;
			url = url + "&editCountryCode=" + editCountryCode;
		}
		
		if((path == 'images1') || (path == 'links'))
		{
			editID = form.elements["editID"].options[form.elements["editID"].selectedIndex].value;
			url = url + "&editID=" + editID;
		}
		
		if(path == "create")
		{
			domainId = form.elements["domainId"].options[form.elements["domainId"].selectedIndex].value;
			url = url + "&domainId=" + domainId;
		}
						
		window.location.href = url;	
	}
}

//-------------------------------------------

function showWarning(name)
{
	var warning = "Möchten Sie " + name + " wirklich löschen?";
	var antwort = false;
	meldung = confirm(warning);
	if(meldung) { antwort = true;}
	return antwort;
}

//-------------------------------------------

function showWarningInShop(warning)
{
    var antwort = false;
	meldung = confirm(warning);
	if(meldung) { antwort = true;}
	return antwort;
}


//-------------------------------------------

function auslesen(auswahl, motivland, sess)
{
	if(auswahl != "nichts" && auswahl != "")
	{
		var adresse = "result.php?sess=" + sess + "&auswahl=" + auswahl + "&motivland=" + motivland;	
		parent.frames["content"].location.href = adresse;
		//alert(adresse);
	}
}


//-------------------------------------------

function checkValue(formName)
{
	form = window.document.forms[formName];
	answer = false;
	alertText = "Die Seite kann nicht hochgeladen werden: Sie haben keine Domain ausgewählt!";
	
	if(form.elements["domainId"].options[form.elements["domainId"].options.selectedIndex].value != "")
	{
		answer = true;
	}
	
	if(!answer) { alert (alertText); }
	
	return answer;	
}

//-------------------------------------------

function checkFormFields(formName, warningEmail, warningOthers)
{ 
	answer = true;
	alertText = warningOthers;
	arrCheckFields = new Array("Vorname", "Nachname", "Strasse", "Hausnummer", "PLZ", "Ort", "Land", "E_Mail", "Vorwahl", "Telefon", "AGB");
	arrCheckFieldsCreditCard = new Array("Anrede", "Karteninhaber", "Kartennummer[0]", "Kartennummer[1]", "Kartennummer[2]", "Kartennummer[3]", "cardVerificationCode", "gueltig[0]", "gueltig[1]");
	
	emptyFields = "";
	
	var form = window.document.forms[formName];
	
	for(i = 0 ; i < arrCheckFields.length ; i++)
	{
		if(document.getElementById) { form.elements[arrCheckFields[i]].style.backgroundColor = ""; }
		
		if(form.elements[arrCheckFields[i]].value == "")
		//if(form.elements[arrCheckFields[i]].value.replace(/ /gi, "") == "")
		{
			answer = false;
			emptyFields += arrCheckFields[i] + ", ";
		}
		/*
		else if(arrCheckFields[i] == "E_Mail")
		{
			regMail = new RegExp("^[a-z0-9-_]+([\.]{1}[a-z0-9-_]+)*@{1}[a-z0-9-_]{3,}[\.]{1}[a-z]{2,3}$","gi");		
			if(!regMail.exec(form.elements[arrCheckFields[i]].value))
			{
				answer = false;
				alertText = warningEmail;
				emptyFields += arrCheckFields[i] + ", ";
				form.elements[arrCheckFields[i]].select();
			}
		}
		*/
		if(arrCheckFields[i] == "AGB")
		{
			if(!form.elements["AGB"].checked)
			{
				answer = false;
				emptyFields += arrCheckFields[i] + ", ";
			}
		}
	}
	
	if(form.elements["Bezahlart"][0].checked)
	{
		for(i = 0 ; i < arrCheckFieldsCreditCard.length ; i++)
		{
			if(document.getElementById) { form.elements[arrCheckFieldsCreditCard[i]].style.backgroundColor = ""; }
			if(arrCheckFieldsCreditCard[i] == "Anrede")
			{	
				form.elements["Anrede"].selectedIndex = 0;
			}
			else
			{				
				form.elements[arrCheckFieldsCreditCard[i]].value = "";
			}	
		}
		
	}
	
	if(form.elements["Bezahlart"][1].checked)
	{
		for(i = 0 ; i < arrCheckFieldsCreditCard.length ; i++)
		{
			if(document.getElementById) { form.elements[arrCheckFieldsCreditCard[i]].style.backgroundColor = ""; }
			
			if(form.elements[arrCheckFieldsCreditCard[i]].value == "")
			//if(form.elements[arrCheckFieldsCreditCard[i]].value.replace(/ /gi, "") == "")
			{
				answer = false;
				emptyFields += arrCheckFieldsCreditCard[i] + ", ";
			}
		}
	}
	
	if(!answer)
	{
		emptyFields = emptyFields.substring(0, (emptyFields.length - 2));
		arrEmptyFields = emptyFields.split(", ");
		form.elements[arrEmptyFields[0]].focus();
		for( i = 0 ; i < arrEmptyFields.length ; i++ )
		{
			if(document.getElementById)
			{
				if(arrEmptyFields[i] == "AGB") {form.elements[arrEmptyFields[i]].style.backgroundColor = "#FF0000"; }
				else { form.elements[arrEmptyFields[i]].style.backgroundColor = "#F7C9C9"; }
			}
		}
		alert (alertText);
	}
	else
	{
		window.document.forms[formName].action = "control.php";
		window.document.forms[formName].submit();
	}
	
	
}

//-------------------------------------------


function checkBasketPrice(formName, totalBasketPrice, minimalPrice, warningEmail, warningOthers, message)
{
	sess = window.document.forms[formName].elements["sess"].value;
	if((totalBasketPrice * 1) < (minimalPrice * 1))
	{
		alert(message + ' (' + minimalPrice + ' EUR)!');
		return false;
	}
	else
	{
		checkFormFields(formName, warningEmail, warningOthers);
	}
}

//-------------------------------------------

function checkIfCookiesEnabled(message)
{
	/*
	if(navigator.cookieEnabled == false)
	{
		strMessage = "";
		arrMessage = message.split("%");
		for(i = 0 ; i < arrMessage.length ; i++)
		{
			strMessage += arrMessage[i] + "\n";
		}
		window.alert(strMessage);
	}
	*/
}

//-------------------------------------------

function setLookForWord1(search)
{
	if(window.opener)
	{
		if(window.opener.name == "navigation" || window.opener.name == "content")
		{		
			window.opener.parent.frames[0].document.forms["formSearch1"].elements["lookForWord1"].value = search;
			formSubmit = window.opener.parent.frames[0].document.forms["formSearch1"].submit();
			
			//this.close();	
		}
	}	
}

//-------------------------------------------

function checkFrameset()
{
	if(parent.frames.length == 0) { window.document.location.href = "index.htm"; }
}

//-------------------------------------------

function checkContactFields(formName)
{	
	answer = true;	
	arrCheckFields = new Array("name", "mitteilung");
	emptyFields = "";	
		
	var form = window.document.forms[formName];
	
	for(i = 0 ; i < arrCheckFields.length ; i++)
	{
		if(document.getElementById) { form.elements[arrCheckFields[i]].style.backgroundColor = ""; }
		
		if(form.elements[arrCheckFields[i]].value == "")
		//if(form.elements[arrCheckFields[i]].value.replace(/ /gi, "") == "")
		{
			answer = false;
			emptyFields += arrCheckFields[i] + ", ";
		}		
	}
	
	if(!answer)
	{
		emptyFields = emptyFields.substring(0, (emptyFields.length - 2));
		arrEmptyFields = emptyFields.split(", ");
		form.elements[arrEmptyFields[0]].focus();
		for( i = 0 ; i < arrEmptyFields.length ; i++ )
		{
			if(document.getElementById)
			{
				if(arrEmptyFields[i] == "AGB") {form.elements[arrEmptyFields[i]].style.backgroundColor = "#FF0000"; }
				else { form.elements[arrEmptyFields[i]].style.backgroundColor = "#F7C9C9"; }
			}
		}
		// alert (alertText);
	}
	
	return answer;
}
