// JavaScript Document
function img_over(img){
	var image = img;
	img_on = new Image();
	img_on.src ="/en/images/bookmark/"+image+"_over.gif";
	//alert(img_on.src);
	document.images[image].src=img_on.src;

}
function img_out(img){
	var image = img;
	img_on = new Image();
	img_on.src ="/en/images/bookmark/"+image+".gif";
	//alert(img_on.src);
	document.images[image].src=img_on.src;

}
function download (datei) {
  URL = "./download/downloadcount.php?datei="+datei;
//  alert (URL);
  doIt(URL);
}

function doIt(URL){
	 
 var req = null;
	try{
		req = new XMLHttpRequest();
	}
	catch (ms){
		try{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (nonms){
			try{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (failed){
				req = null;
			}
		}  
	}

	if (req == null)
		  alert("Error creating request object!");
	  
	  //anfrage erstellen (GET, url ist localhost,
	  //request ist asynchron      
	  req.open("GET", URL , true);

	//Beim abschliessen des request wird diese Funktion ausgeführt
	req.onreadystatechange = function(){            
		switch(req.readyState) {
				case 4:
				if(req.status!=200) {
//						alert("Fehler:"+req.status); 
				}else{    
//						alert(req.responseText);
					//schreibe die antwort in den div container mit der id content 
					
				}
				break;
		
				default:
					return false;
				break;     
			}
		};

	  req.setRequestHeader("Content-Type",
						  "application/x-www-form-urlencoded");
	req.send(null);
}
function openwin(pid){
	if(pid=='foto'){
		var height = "500";
		var width = "455";
	}
	if(pid=='datenschutz' || pid=='privacy-policy'){
		var height = "680";
		var width = "790";
	}
	var height1="height="+height;
	var width1="width="+width;
	var gr = height1+","+width1+",left=50,top=50,screenX=50,screenY=50,location=no,menubar=no,scrollbars=no,resizable=no,status=no";
	var win=window.open('http://www.suchy-mips.de/'+pid+'.php',pid,gr);
}
//Wenn der Kunde einen BENS besitzt oder nicht
function BensJaNein () {
  if (document.getElementsByName("bens_ja_nein")[0].checked == true) {
	   document.getElementById("macdiv").style.display="block";
  } 
  else if (document.getElementsByName("bens_ja_nein")[1].checked == true) {
    document.getElementById("macdiv").style.display="none";
  }
}
//Check wenn nichts ausgewählt wurde dann alert Meldung

function check(){
	if(document.getElementById('preis_netto_ges').value == "" || document.getElementById('preis_mwst_ges').value == "" || document.getElementById('preis_brutto_ges').value == ""){
		alert("Bitte wählen Sie Ihr Produkt aus!");
		return false;
	}
}
/*
// Zahlen werden formatiert
function formatZahl(id, zahl, zahl1, zahl2, zahl3, k, fix) {
	if(zahl=="0"){
		document.getElementById('nr_'+id).value = "";
	}else{
		document.getElementById('nr_'+id).value = "nr_"+document.getElementById('nr_'+id).value;
	}
    if(!k) k = 0;
    var neu = '';
	var neu1 = '';
	var neu2 = '';
	var neu3 = '';
	
	var dec_point = '.';
	var thousands_sep = '';

    // Runden
    var f = Math.pow(10, k);
    zahl = '' + parseInt(zahl * f + (.5 * (zahl > 0 ? 1 : -1)) ) / f ;
	zahl1 = '' + parseInt(zahl1 * f + (.5 * (zahl1 > 0 ? 1 : -1)) ) / f ;
	zahl2 = '' + parseInt(zahl2 * f + (.5 * (zahl2 > 0 ? 1 : -1)) ) / f ;
	zahl3 = '' + parseInt(zahl3 * f + (.5 * (zahl3 > 0 ? 1 : -1)) ) / f ;
	//alert(zahl);
    // Komma ermittlen
    var idx = zahl.indexOf('.');
	var idx1 = zahl1.indexOf('.');
	var idx2 = zahl2.indexOf('.');
	var idx3 = zahl3.indexOf('.');

    // fehlende Nullen einfügen
    if(fix)    {
         zahl += (idx == -1 ? '.' : '' )+ f.toString().substring(1);
		 zahl1 += (idx1 == -1 ? '.' : '' )+ f.toString().substring(1);
		 zahl2 += (idx2 == -1 ? '.' : '' )+ f.toString().substring(1);
		 zahl3 += (idx3 == -1 ? '.' : '' )+ f.toString().substring(1);
    }
	var sign = zahl < 0;
	var sign1 = zahl1 < 0;
	var sign2 = zahl2 < 0;
	var sign3 = zahl3 < 0;
	
	if(sign) zahl = zahl.substring(1);{
		idx = zahl.indexOf('.');
	}
	if(sign1) zahl1 = zahl1.substring(1);{
		idx1 = zahl1.indexOf('.');
	}
	if(sign2) zahl2 = zahl2.substring(1);{
		idx2 = zahl2.indexOf('.');
	}
	if(sign3) zahl3 = zahl3.substring(1);{
		idx3 = zahl3.indexOf('.');
	}
    
	// Nachkommastellen ermittlen
    if( idx == -1) {
		idx = zahl.length;
	}
    else {
		neu = dec_point + zahl.substr(idx + 1, k);
	}
	if( idx1 == -1) {
		idx1 = zahl1.length;
	}
    else {
		neu1 = dec_point + zahl1.substr(idx1 + 1, k);
	}
	if( idx2 == -1) {
		idx2 = zahl2.length;
	}
    else {
		neu2 = dec_point + zahl2.substr(idx2 + 1, k);
	}
	if( idx3 == -1) {
		idx3 = zahl3.length;
	}
    else {
		neu3 = dec_point + zahl3.substr(idx3 + 1, k);
	}
	
    while(idx > 0)    {
        if(idx - 3 > 0){
        	neu = thousands_sep + zahl.substring( idx - 3, idx) + neu;
		}
        else{
			neu = zahl.substring(0, idx) + neu;
			if(neu!="0.00"){
				document.getElementById(id+'_ges').value=neu;
			}else{
				document.getElementById(id+'_ges').value="";
			}
		}
        idx -= 3;
    }
    //return (sign ? '-' : '') + neu;
	while(idx1 > 0)    {
        if(idx1 - 3 > 0){
        	neu1 = thousands_sep + zahl1.substring( idx1 - 3, idx1) + neu1;
		}
        else{
        neu1 = zahl1.substring(0, idx1) + neu1;
		document.getElementById('preis_netto_ges').value=neu1;
		}
        idx1 -= 3;
    }
    //return (sign1 ? '-' : '') + neu1;
	while(idx2 > 0)    {
        if(idx2 - 3 > 0){
        	neu2 = thousands_sep + zahl.substring( idx2 - 3, idx2) + neu2;
		}
        else{
        neu2 = zahl2.substring(0, idx2) + neu2;
		document.getElementById('preis_mwst_ges').value=neu2;
		}
        idx2 -= 3;
    }
   // return (sign2 ? '-' : '') + neu2;
	while(idx3 > 0)    {
        if(idx3 - 3 > 0){
        	neu3 = thousands_sep + zahl3.substring( idx3 - 3, idx3) + neu3;
		}
        else{
        neu3 = zahl3.substring(0, idx3) + neu3;	
		document.getElementById('preis_brutto_ges').value=neu3;
		}
        idx3 -= 3;
    }
    //return (sign3 ? '-' : '') + neu3;
	return (sign ? '-' : '') + neu;
	return (sign1 ? '-' : '') + neu1;
	return (sign2 ? '-' : '') + neu2;
	return (sign3 ? '-' : '') + neu3;
}
*/
// Zahlen werden formatiert
function formatZahl(id, zahl, k, fix) {
	//alert(zahl);

	
    if(!k) k = 0;
    var neu = '';
	
	var dec_point = '.';
	var thousands_sep = '';

    // Runden
    var f = Math.pow(10, k);
    zahl = '' + parseInt(zahl * f + (.5 * (zahl > 0 ? 1 : -1)) ) / f ;
	//alert(zahl);
    // Komma ermittlen
    var idx = zahl.indexOf('.');

    // fehlende Nullen einfügen
    if(fix)    {
         zahl += (idx == -1 ? '.' : '' )+ f.toString().substring(1);
    }
	var sign = zahl < 0;
	
	if(sign) zahl = zahl.substring(1);{
		idx = zahl.indexOf('.');
	}
    
	// Nachkommastellen ermittlen
    if( idx == -1) {
		idx = zahl.length;
	}
    else {
		neu = dec_point + zahl.substr(idx + 1, k);
	}
	
    while(idx > 0)    {
        if(idx - 3 > 0){
        	neu = thousands_sep + zahl.substring( idx - 3, idx) + neu;
		}
        else{
			neu = zahl.substring(0, idx) + neu;
			if(neu!="0.00"){
				document.getElementById(id).value=neu;
			}else{
				document.getElementById(id).value="";
			}
		}
        idx -= 3;
    }
    return (sign ? '-' : '') + neu;
}

function check_preis(id, st, st_preis){
	//alert(st_preis);
	//alert(id);
	//alert(id+'_ges');
	// id wird übergeben
	//wertid1=document.getElementById(id).value;
	if(st!="0"){
		document.getElementById('wert_'+id.substring(4)).value = (st_preis * st)+'.00';
	}else{
		document.getElementById('wert_'+id.substring(4)).value = "";
	}
	//Account 69025288
	//wert = document.getElementById(id+'_ges').value;
	//wert=(eval(parseInt(wertid1)*parseInt(st_preis)))+'.00';
	//alert(wert);
	//gesamt wert des produktes wird ermittelt
	//wenn wert 0 dann kein gesamtwert 
	//if(wertid=="0"){
		//document.getElementById(id+'_ges').value = "0";
	//} else{
		//document.getElementById(id+'_ges').value = wertid+".00";
		//document.getElementById(id).value = wertid;
	//}
	var frm = document.forms.form;
	var wert = "";
	for(var i=0;i<frm.elements['multival[]'].length;i++) {
		if(document.forms['form'].elements['multival[]'][i].value!=""){
			wert_art = document.forms['form'].elements['multival[]'][i].value;
			//alert(wertabc);
			if(i=="0"){
				wert = parseInt(wert_art);
			}else{
				wert +="+"+parseInt(wert_art);
			}
		}
	}
	
	wertnetto = eval(wert);
	//alert(wertnetto);
	document.getElementById('preis_netto_ges').value = wertnetto+'.00';
	document.getElementById('preis_mwst_ges').value = (eval((document.getElementById('preis_netto_ges').value * 19)/100));
	//wertbrutto = (eval((wertnetto + wertmwst)));
	var z= document.getElementById('preis_mwst_ges').value;
	formatZahl('preis_mwst_ges', z, 2, 1);
	var y= eval(document.getElementById('preis_netto_ges').value +"+"+document.getElementById('preis_mwst_ges').value);
	formatZahl('preis_brutto_ges', y, 2, 1);
}
function FlashMovie(src, movie, width, height, version, quality, menu, bgcolor, flashvars)
{
	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+version+",0,0,0' width='" +width+ "' height='" +height+ "' id='" +movie+ "'>");
	document.write("<param name='movie' value='" +src+ "' />");
	document.write("<param name='FlashVars' value='" +flashvars+ "'>");
	document.write("<param name='quality' value='" +quality+ "' />");
	document.write("<param name='menu' value='" +menu+ "' />");
	document.write("<param name='bgcolor' value='" +bgcolor+ "' />");
	document.write("<embed src='" +src+ "' swLiveConnect='true' menu='" +menu+ "' FlashVars='" +flashvars+ "' quality='" +quality+ "' bgcolor='" +bgcolor+ "' width='" +width+ "' height='" +height+ "' name='" +movie+ "' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.write("</object>");
}


	var win = "";
	var hoehe = "";
	var breite = "";
	
	function checkNews(){
		
		function validEmail(email) {
			var strReg = "^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$";
			var regex = new RegExp(strReg);
			return(regex.test(email)); 
		}
				
		search = "EMail=" + document.news.EMail.value;
		search += "&";
		
		if (!validEmail(document.news.EMail.value)) {
				search += "Action=subscribe";
				hoehe = 200;
				breite = 300;
			}else{
				search += "Action=subscribe";
				hoehe = 255;
				breite = 425;
			}
		
		search += "&";
		search += "SubmitBtn=" + document.news.SubmitBtn.value;

		if(!win || win.closed){
			win = window.open("http://suchymips.tld/en/newsletter.php?" + search, "News", "height="+hoehe+", width="+breite+", left=250, top=250, screenX=100, screenY=100, location=no, menubar=no, scrollbars=no, resizable=no, status=no, toolbar=no");
			document.news.EMail.value="Your e-mail address";
			document.news.Action.value='subscribe';
		}else{
			win.location.href="http://suchymips.tld/en/newsletter.php?"  + search;
			win.focus();
		}
		return false;
	}
	
	function hideEmailtext(){
		if (document.news.EMail.value == 'Your e-mail address'){
			document.news.EMail.value='';
		}
		return true;
	}

function OpenImg(img){
	var win=window.open('./swf/img.php?img='+img,img,'height=564,width=795,left=150,top=100,screenX=100,screenY=100,location=no,menubar=no,scrollbars=no,resizable=no,status=no');
}
