function checkAdressData()
{

	if(checkAdressFields==true) return true;
	else return false;

}


function checkAdressFields(agbcheck)
{

	
	var ok = 1;
	var agbok = 1;
	if($("name").value == "") {$("name").className = "boxred"; ok = 0;} else {$("name").className = "box";}
	if($("nachname").value == "") {$("nachname").className = "boxred"; ok = 0;} else {$("nachname").className = "box";}
	if($("strasse").value == "") {$("strasse").className = "boxred"; ok = 0;} else {$("strasse").className = "box";}
	if($("plz").value == "") {$("plz").className = "boxred"; ok = 0;} else {$("plz").className = "box";}
	if($("ort").value == "") {$("ort").className = "boxred"; ok = 0;} else {$("ort").className = "box";}
	if($("land").value == "") {$("land").className = "boxred"; ok = 0;} else {$("land").className = "box";}
	if($("telefon").value == "") {$("telefon").className = "boxred"; ok = 0;} else {$("telefon").className = "box";}
	if($("email").value == "") {$("email").className = "boxred"; ok = 0;} else {$("email").className = "box";}
	
	if(agbcheck == 1) if(document.adresse.agb.checked == false) {agbok = 0;} else {agbok = 1}
	
	if(ok == 0){
		self.scrollTo(0,0);
		$("fieldserror").innerHTML = "Vul a.u.b alle verplichte velden in.";
		$("fieldserror").className = "error";
	}
	else
	{
		$("fieldserror").innerHTML = "";
		$("fieldserror").className = "";
	}
	if(agbok == 0){
		$("agberror").innerHTML = "Ga akkoord met de algemene voorwaarden.";
		$("agberror").className = "error";
	}
	else
		{
		$("agberror").innerHTML = "";
		$("agberror").className = "";
			
		}
	
	if(ok == 0 || agbok == 0) { return false;}
	else { return true;}
		
}

function checkAGB()
{
	var agbok = 1;
	if(document.adresse.agb.checked == false) {agbok = 0;} else {agbok = 1}
	if(agbok == 0){
		$("agberror").innerHTML = "Alstublieft stemmen de algemene voorwaarden bij";
		$("agberror").className = "error";
		return false;
	}
	else {return true;}


}

function neuBerechnen()
{
//alert("party");
document.wk.jsfeld.value="1";
document.wk.submit();
}

function kommentar_eingabe_an()
{
	kommentare_button = document.getElementById("kommentar_button");
	kommentare_button.style.display = "none";
	kommentare = document.getElementById("kommentar_eingabe");
	kommentare.style.display = "";
}

function kommentar_eingabe_aus()
{
	kommentare_button = document.getElementById("kommentar_button");
	kommentare_button.style.display = "";
	kommentare = document.getElementById("kommentar_eingabe");
	kommentare.style.display = "none";
}
function showpic(loc,desc,picwidth,picheight)
{
blackbox();
myDiv = document.getElementById("bildanzeige");

htmlcode = "<table cellpadding='0' cellspacing='3' width='"+picwidth+"'><tr><td width='"+picwidth+"'>";
htmlcode += "<a href='javascript:aus(bildanzeige);aus(biggray);'><img src='" + loc + "' border='0'></a></td></tr>";
htmlcode += "<tr bgcolor='white'><td style='padding:10px;' width='"+picwidth+"'>" + desc +  "</tD></tr></table>";

myDiv.innerHTML = htmlcode;

var breite,hoehe,yoffset;
if (self.innerHeight) // all except Explorer
{
	breite = self.innerWidth;
	hoehe = self.innerHeight;
	yoffset = self.pageYOffset;
}
else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
{
	breite = document.documentElement.clientWidth;
	hoehe = document.documentElement.clientHeight;
	yoffset = document.documentElement.scrollTop;
}
else if (document.body) // other Explorers
{
	breite = document.body.clientWidth;
	hoehe = document.body.clientHeight;
	yoffset = document.body.scrollTop;
}
	
var l = (breite - picwidth) / 2;
var t = (hoehe - picheight) / 2 + yoffset;

myDiv.style.top = t;
myDiv.style.left = l;
myDiv.style.display = "";

}

function aus(x) 
{ 
x.style.display = "none";
} 

function blackbox()
{
	biggray.style.display = ""
	setOpacity(biggray,0.7);
	
	var x,y;
var test1 = document.body.scrollHeight;
var test2 = document.body.offsetHeight
if (test1 > test2) // all but Explorer Mac
{
	x = document.body.scrollWidth;
	y = document.body.scrollHeight;
}
else // Explorer Mac;
     //would also work in Explorer 6 Strict, Mozilla and Safari
{
	x = document.body.offsetWidth;
	y = document.body.offsetHeight;
}
	
	biggray.style.width = x;
	biggray.style.height = y;
}

function setOpacity( element, alpha ) {
	var style = element.style;
	if( style.MozOpacity != undefined ) { //Moz and older
		style.MozOpacity = alpha;
		
	
	}
	else if( style.filter != undefined ) { //IE
		style.filter = "alpha(opacity=0)";
		element.filters.alpha.opacity = ( alpha * 100 );
			
		
	}
	else if( style.opacity != undefined ) { //Opera
		style.opacity = alpha;
		
	}
}

function ImageView(TheImage)
{
	var neu = new Image();
	var border = 30;
	neu.src = TheImage;
	var BildMitteX = (screen.width / 2);
	var BildMitteY = (screen.Height / 2);
	//'resizable=1,location=0,directories=1,status=1,menubar=1,scrollbars=1,toolbar=1,width=200,height=200'
	meinTOFenster = window.open("about:blank","meinTOFensterName","resizable=1,location=0,directories=0,status=0,menubar=1,scrollbars=1,toolbar=0,width=600,height=400");
	meinTOFenster.resizeTo( neu.width + border, neu.Height + border + 50 );
	meinTOFenster.moveTo(BildMitteX - ((neu.width + border) / 2), BildMitteY - ((neu.Height +border+50) / 2));	
	meinTOFenster.document.write("<html><head><title>Detailansicht<\/title>");
	meinTOFenster.document.write("<script language=\"JavaScript\">");
	meinTOFenster.document.write("function zu(){close();}");
	meinTOFenster.document.write("<\/script>");
	meinTOFenster.document.write("<\/head><body>");
	meinTOFenster.document.write("<img src=\""+TheImage+"\">");
	meinTOFenster.document.write("<center><input type='submit' onClick='zu();' value='Fenster schliessen'><\/center>");
	meinTOFenster.document.write("<\/body><\/html>");
	
}

function BeschreibungView(id, art)
{
	meinBeschreibungsFenster = window.open("beschreibung.php?zusatzart="+art+"&id="+id+" ","meinBeschreibungsFensterName",
	"width=300,height=300,scrollbars=no,resizable=yes,status=yes");
	
	
	
}


function ZusatzViewAjax(id,TilesPerRow,zusatzcounter)
{
	//alert('1');

	var newDiv = document.createElement("div");
	var newTextNode = document.createTextNode("");
				
	newDiv.className = "zusatzoverlay";
	newDiv.style.display = "none";
	newDiv.id = "derzusatzoverlay";
	newDiv.appendChild(newTextNode);
	$('thebody').appendChild(newDiv);

	//alert('2');

	var screenSize = getSize();
	newDiv.style.left = screenSize[0]/2-450;
	newDiv.style.top = screenSize[2]+50;

	//alert(id+"-"+TilesPerRow+"-"+zusatzcounter);

	//alert('3');

	getZusaetzeProdukt(id,TilesPerRow,zusatzcounter)
}


function getSize() {  
    var myWidth = 0, myHeight = 0, yoffset = 0;  
  
    if( typeof( window.innerWidth ) == 'number' ) {  
        //Non-IE  
        myWidth = window.innerWidth;  
        myHeight = window.innerHeight;  
		yoffset = self.pageYOffset;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {  
        //IE 6+ in 'standards compliant mode'  
        myWidth = document.documentElement.clientWidth;  
        myHeight = document.documentElement.clientHeight;  
		yoffset = document.documentElement.scrollTop;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {  
        //IE 4 compatible  
        myWidth = document.body.clientWidth;  
        myHeight = document.body.clientHeight;  
		yoffset = document.body.scrollTop;
    }  
    return [ myWidth, myHeight, yoffset];  
}  




function getZusaetzeProdukt(id,TilesPerRow,zusatzcounter){

	//alert('ajax/getssatz.php?projekt_ref='+theoption.value;);

	//alert('aaaaaaaaaaaaaaaaaa');

	//alert(id+"-"+TilesPerRow+"-"+zusatzcounter);

	var subdir = $('hiddensubdir').value;

	var url = subdir+'/getzusatzliste.php?zusatz_kat_ref='+id+'&tiles='+TilesPerRow+'&counter='+zusatzcounter;

	//alert(url);

	//alert('bbbb');
	new Ajax.Request(url, {
  method: 'get',
  onFailure: function() {alert('Beim Laden der Zusätze ist ein Fehler aufgetreten!');},
  onSuccess: function(transport) {
   
	//alert('cccc');
	xmlResponse = transport.responseXML;
	xmlDocumentElement = xmlResponse.documentElement;


	zusatz_titel_Array = xmlDocumentElement.getElementsByTagName("zusatz_titel");
	zusatz_bild_kleinArray = xmlDocumentElement.getElementsByTagName("zusatz_bild_klein");
	zusatz_bild_grossArray = xmlDocumentElement.getElementsByTagName("zusatz_bild_gross");
	zusatz_bruttoArray = xmlDocumentElement.getElementsByTagName("zusatz_brutto");
	zusatz_idArray = xmlDocumentElement.getElementsByTagName("zusatz_id");
	zusatz_nameArray = xmlDocumentElement.getElementsByTagName("zusatz_name");
	zusatz_preisArray = xmlDocumentElement.getElementsByTagName("zusatz_preis");
	zusatz_wertArray = xmlDocumentElement.getElementsByTagName("zusatz_wert");
	zusatz_counterArray = xmlDocumentElement.getElementsByTagName("zusatz_counter");
	

	var inhalt = "";
	var last = "";
	

	for(var i=0; i<zusatz_idArray.length; i++)
			{

				//alert(zusatz_bild_kleinArray.item(i).firstChild.data);

				inhalt += "<div style='float:left; margin-right:20px; margin-bottom:10px;'><img src='"+zusatz_bild_kleinArray.item(i).firstChild.data+"'><br>"+zusatz_titel_Array.item(i).firstChild.data+"<br><b>"+zusatz_bruttoArray.item(i).firstChild.data+" &euro;</b><br>";
				inhalt += "<input type='submit' value='W&auml;hlen' onclick='zusatzUebernehmen(\""+zusatz_counterArray.item(i).firstChild.data+"\",\""+htmlentities(zusatz_wertArray.item(i).firstChild.data)+"\",\""+zusatz_nameArray.item(i).firstChild.data+"\",\""+zusatz_idArray.item(i).firstChild.data+"\",\""+zusatz_preisArray.item(i).firstChild.data+"\",\""+htmlentities(zusatz_titel_Array.item(i).firstChild.data)+"\")'>";
				inhalt += "</div>";

				last = zusatz_counterArray.item(i).firstChild.data;

			}

	//alert('dddd');
	//alert(id+"-"+TilesPerRow+"-"+zusatzcounter);
	
	inhalt += "<div class='clear'></div><br><img src='"+subdir+"/grafiken/system/pokale_hauptmenu_item2.png' style='margin-bottom:-4px;'>&nbsp;&nbsp;<a href='#' onclick='closeZusatzView(\""+last+"\");' class='zusatzlinkclose'>Keinen Zusatz W&auml;hlen</a></p>";


	$('derzusatzoverlay').innerHTML = inhalt;
	$('derzusatzoverlay').style.display = "";
  }
});		
	
	
}

function closeZusatzView(counter) {

	$('derzusatzoverlay').style.display = "none";
	$('derzusatzoverlay').parentNode.removeChild($('derzusatzoverlay'));

	$('label'+counter).innerHTML = "-";
	$('name'+counter).value = "";
	$('table'+counter).value = "";
	$('id'+counter).value = "";
	$('wert'+counter).value = "";
	$('preis'+counter).value = "";


}

function zusatzUebernehmen(counter,wert,name,theid,preis,titel)
{

	//alert(name+'xxxxxxxxxxxxxxxxxxxxxxxx'+titel);
	$('label'+counter).innerHTML = titel+": "+preis+" &euro;";
	$('name'+counter).value = name;
	$('table'+counter).value = "zusatz_link";
	$('id'+counter).value = theid;
	$('wert'+counter).value = wert;
	$('preis'+counter).value = preis;
	$('derzusatzoverlay').style.display = "none";
	$('derzusatzoverlay').parentNode.removeChild($('derzusatzoverlay'));

/*
	
	$('table'+counter).value = "zusatz_link";
	$('id'+counter).value = id;
	$('wert'+counter).value = wert;
	$('preis'+counter).value = preis;


	opener.document.getElementById("label{ZUSATZ_COUNTER}").innerText = "{ZUSATZ_WERT}" ;
		x1 = opener.document.getElementById("name{ZUSATZ_COUNTER}") ;
		x1.value="{ZUSATZ_NAME}" ;
		x2 = opener.document.getElementById("table{ZUSATZ_COUNTER}") ;
		x2.value="{ZUSATZ_TABLE}" ;
		x3 = opener.document.getElementById("id{ZUSATZ_COUNTER}") ;
		x3.value="{ZUSATZ_ID}" ;
		x4 = opener.document.getElementById("wert{ZUSATZ_COUNTER}") ;
		x4.value="{ZUSATZ_WERT}" ;
		x5 = opener.document.getElementById("preis{ZUSATZ_COUNTER}") ;
		x5.value="{ZUSATZ_PREIS}" ;
*/

}



function ZusatzView(id, TilesPerRow,zusatzcounter)
{
	var BildMitteX = (screen.width / 2);
	var BildMitteY = (screen.height / 2);
	meinZusatzFenster = window.open("zusatzliste.php?zusatz_kat_ref="+id+"&tiles="+TilesPerRow+"&counter="+zusatzcounter,"meinZusatzFensterName",
	"width=780,scrollbars=yes,resizable=yes,status=yes");
	/* meinZusatzFenster.resizeTo( 1024,600 ); */
	meinZusatzFenster.moveTo(BildMitteX - (780 / 2), BildMitteY - (meinZusatzFenster.height / 2) );	
}



function SelectZusatz(id,kategorie)
{
	self.close;
}


function htmlentities (string, quote_style) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: nobbler
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlentities('Kevin & van Zonneveld');
    // *     returns 1: 'Kevin &amp; van Zonneveld'
    // *     example 2: htmlentities("foo'bar","ENT_QUOTES");
    // *     returns 2: 'foo&#039;bar'
 
    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
    
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
    
    return tmp_str;
}

function get_html_translation_table(table, quote_style) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // +   bugfixed by: Alex
    // +   bugfixed by: Marco
    // +   bugfixed by: madipta
    // +   improved by: KELAN
    // +   improved by: Brett Zamir (http://brettz9.blogspot.com)
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js. Meaning the constants are not
    // %          note: real constants, but strings instead. integers are also supported if someone
    // %          note: chooses to create the constants themselves.
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, histogram = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';
 
    useTable     = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
 
    if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
        throw Error("Table: "+useTable+' not supported');
        // return false;
    }
 
    // ascii decimals for better compatibility
    entities['38'] = '&amp;';
    if (useQuoteStyle !== 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';
    }
    if (useQuoteStyle === 'ENT_QUOTES') {
        entities['39'] = '&#039;';
    }
    entities['60'] = '&lt;';
    entities['62'] = '&gt;';
 
    if (useTable === 'HTML_ENTITIES') {
      entities['160'] = '&nbsp;';
      entities['161'] = '&iexcl;';
      entities['162'] = '&cent;';
      entities['163'] = '&pound;';
      entities['164'] = '&curren;';
      entities['165'] = '&yen;';
      entities['166'] = '&brvbar;';
      entities['167'] = '&sect;';
      entities['168'] = '&uml;';
      entities['169'] = '&copy;';
      entities['170'] = '&ordf;';
      entities['171'] = '&laquo;';
      entities['172'] = '&not;';
      entities['173'] = '&shy;';
      entities['174'] = '&reg;';
      entities['175'] = '&macr;';
      entities['176'] = '&deg;';
      entities['177'] = '&plusmn;';
      entities['178'] = '&sup2;';
      entities['179'] = '&sup3;';
      entities['180'] = '&acute;';
      entities['181'] = '&micro;';
      entities['182'] = '&para;';
      entities['183'] = '&middot;';
      entities['184'] = '&cedil;';
      entities['185'] = '&sup1;';
      entities['186'] = '&ordm;';
      entities['187'] = '&raquo;';
      entities['188'] = '&frac14;';
      entities['189'] = '&frac12;';
      entities['190'] = '&frac34;';
      entities['191'] = '&iquest;';
      entities['192'] = '&Agrave;';
      entities['193'] = '&Aacute;';
      entities['194'] = '&Acirc;';
      entities['195'] = '&Atilde;';
      entities['196'] = '&Auml;';
      entities['197'] = '&Aring;';
      entities['198'] = '&AElig;';
      entities['199'] = '&Ccedil;';
      entities['200'] = '&Egrave;';
      entities['201'] = '&Eacute;';
      entities['202'] = '&Ecirc;';
      entities['203'] = '&Euml;';
      entities['204'] = '&Igrave;';
      entities['205'] = '&Iacute;';
      entities['206'] = '&Icirc;';
      entities['207'] = '&Iuml;';
      entities['208'] = '&ETH;';
      entities['209'] = '&Ntilde;';
      entities['210'] = '&Ograve;';
      entities['211'] = '&Oacute;';
      entities['212'] = '&Ocirc;';
      entities['213'] = '&Otilde;';
      entities['214'] = '&Ouml;';
      entities['215'] = '&times;';
      entities['216'] = '&Oslash;';
      entities['217'] = '&Ugrave;';
      entities['218'] = '&Uacute;';
      entities['219'] = '&Ucirc;';
      entities['220'] = '&Uuml;';
      entities['221'] = '&Yacute;';
      entities['222'] = '&THORN;';
      entities['223'] = '&szlig;';
      entities['224'] = '&agrave;';
      entities['225'] = '&aacute;';
      entities['226'] = '&acirc;';
      entities['227'] = '&atilde;';
      entities['228'] = '&auml;';
      entities['229'] = '&aring;';
      entities['230'] = '&aelig;';
      entities['231'] = '&ccedil;';
      entities['232'] = '&egrave;';
      entities['233'] = '&eacute;';
      entities['234'] = '&ecirc;';
      entities['235'] = '&euml;';
      entities['236'] = '&igrave;';
      entities['237'] = '&iacute;';
      entities['238'] = '&icirc;';
      entities['239'] = '&iuml;';
      entities['240'] = '&eth;';
      entities['241'] = '&ntilde;';
      entities['242'] = '&ograve;';
      entities['243'] = '&oacute;';
      entities['244'] = '&ocirc;';
      entities['245'] = '&otilde;';
      entities['246'] = '&ouml;';
      entities['247'] = '&divide;';
      entities['248'] = '&oslash;';
      entities['249'] = '&ugrave;';
      entities['250'] = '&uacute;';
      entities['251'] = '&ucirc;';
      entities['252'] = '&uuml;';
      entities['253'] = '&yacute;';
      entities['254'] = '&thorn;';
      entities['255'] = '&yuml;';
    }
    
    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal);
        histogram[symbol] = entities[decimal];
    }
    
    return histogram;
}
