var passData = "";

function filterInput(evt){
    var keyCode, Char, inputField, filter = '';
    // Get the Key Code of the Key pressed if possible else - allow
    if(window.event){
        keyCode = window.event.keyCode;
        evt = window.event;
    }else if (evt)keyCode = evt.which;
    else return true;
    inputField = evt.srcElement ? evt.srcElement : evt.target || evt.currentTarget;

    if(keyCode == 39 || keyCode == 34) 
  	{
  		alert('Dieses Zeichen kann leider nicht verwendet werden.');
  		return false;
  	} else 
  	{
  		return true;
  	}
}

function Start(URL, WIDTH, HEIGHT) 
{
	var winleft = (screen.width - 500) / 2;
  var wintop = (screen.height - 200) / 2;
  //alert("DE DESCHIS : "+URL);
  
	windowprops = "left=" +winleft + ",top=" + wintop + ",width=" + WIDTH + ",height=" + HEIGHT;
	preview = window.open(URL, "preview", windowprops);
	//if (closetime) setTimeout("preview.close();", closetime*1000);
}

function doPopup()
{
	document.custom.submit();
  if(document.custom.img_file.value != '')
	{
		closetime = 5; // Close window after __ number of seconds?
		// 0 = do not close, anything else = number of seconds

		url = "?menu_popup=popup";
		width = 500;  // width of window in pixels
		height = 200; // height of window in pixels
		delay = 0;    // time in seconds before popup opens
		timer = setTimeout("Start(url, width, height)", delay*1000);
	}
}

function doPopup_nli()
{
document.custom.submit();
if(document.custom.img_file_nli.value != '')
	{
		closetime = 5; // Close window after __ number of seconds?
		// 0 = do not close, anything else = number of seconds

		url = "?menu_popup=popup";
		width = 500;  // width of window in pixels
		height = 200; // height of window in pixels
		delay = 0;    // time in seconds before popup opens
		timer = setTimeout("Start(url, width, height)", delay*1000);
	}		
}
 
function doPopup_upload()
{
	if(document.upload_img.img_file.value != '')
	{   
		closetime = 5; // Close window after __ number of seconds?
		// 0 = do not close, anything else = number of seconds

		url = "?menu_popup=popup";
		width = 500;  // width of window in pixels
		height = 200; // height of window in pixels
		delay = 0;    // time in seconds before popup opens
		timer = setTimeout("Start(url, width, height)", delay*1000);
	}
}

function doPopup_nli_upload()
{
  if(document.upload_img.img_file_nli.value != '')
	{
		closetime = 5; // Close window after __ number of seconds?
		// 0 = do not close, anything else = number of seconds

		url = "?menu_popup=popup";
		width = 500;  // width of window in pixels
		height = 200; // height of window in pixels
		delay = 0;    // time in seconds before popup opens
		timer = setTimeout("Start(url, width, height)", delay*1000);
	}
	
}
 
function show_popup_gallery(imageSRC)
{ 
  if(!imageSRC)
  {
    return false;
  }
  var img = new Image();
  img.src = imageSRC;

  nx=window.parent.screen.width;
  ny=window.parent.screen.height;


  var winleft = (screen.width - 500) / 2;
  var wintop = (screen.height - 500) / 2;

  var newWin = window.open('', 'zoom', 'width=500,height=500,left='+winleft+',top='+wintop+',align=center,toolbar=no, statusbar=no, location=no, directories=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no');
  newWin.document.open();
  newWin.document.write('<html>\n');
  newWin.document.write('<head>\n');
  newWin.document.write('<title>');
  newWin.document.write('[ Zoom ]');
  newWin.document.write('</title>\n');
  newWin.document.write('</head>\n');
  newWin.document.write('<body>\n');
  newWin.document.write('<br/><br/><center><img src="' +escape(imageSRC)+ '"></center\n');
  newWin.document.write('<br/><br/><center><a style="align:center; color: red; font-size: 12px; font weight: bold;" href="javascript: window.close()">Close</a></center>');
  newWin.document.write('</body>\n');
  newWin.document.write('</html>\n');
  newWin.document.close();
  newWin.focus();

}

function show_popup(imageSRC)
{
  if(!imageSRC)
  {
    return false;
  }
  var img = new Image();
  img.src = imageSRC;
  
  nx=window.parent.screen.width;
  ny=window.parent.screen.height;
  
  
  var winleft = (screen.width - 450) / 2;
  var wintop = (screen.height - 400) / 2;

  var newWin = window.open('', 'zoom', 'width=450,height=400,left='+winleft+',top='+wintop+',align=center,toolbar=no, statusbar=no, location=no, directories=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no');
  newWin.document.open();
  newWin.document.write('<html>\n');
  newWin.document.write('<head>\n');
  newWin.document.write('<title>');
  newWin.document.write('[ Zoom ]');
  newWin.document.write('</title>\n');
  newWin.document.write('</head>\n');
  newWin.document.write('<body>\n');
  newWin.document.write('<br/><br/><center><img src="' +imageSRC+ '"></center\n');
  newWin.document.write('<br/><br/><center><a style="align:center; color: red; font-size: 12px; font weight: bold;" href="javascript: window.close()">Close</a></center>');
  newWin.document.write('</body>\n');
  newWin.document.write('</html>\n');
  newWin.document.close();
  newWin.focus();
}

function GoToBasketCross(formName,quantity)
{
  
  if (AddToBasketCross(formName,quantity))
  {
    var winleft = (screen.width - 391) / 2;
    var wintop = (screen.height - 170) / 2;  
    var newWin = window.open('', 'warenkorb', 'width=391,height=170,left='+winleft+',top='+wintop+',align=center,toolbar=no, status=no, location=no, directories=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no');
    newWin.document.open();
    newWin.document.write('<html>');
    newWin.document.write('<head>');
    newWin.document.write('<title>');
    newWin.document.write('[ In Den Warenkorb ]');
    newWin.document.write('</title>');
    newWin.document.write('</head>');
    newWin.document.write('<style type="text/css">');
      newWin.document.write('.link');
      newWin.document.write('{');
      	newWin.document.write('font-family: Verdana,sans-serif, Arial, Helvetica;');
      	newWin.document.write('font-weight: normal;');
      	newWin.document.write('font-size: 12px;');
      	newWin.document.write('color: #000000;');
      	newWin.document.write('text-decoration: underline;');
      newWin.document.write('}');
      newWin.document.write('.link:hover');
      newWin.document.write('{');
      	newWin.document.write('font-family: Verdana,sans-serif, Arial, Helvetica;');
      	newWin.document.write('font-weight: normal;');
      	newWin.document.write('font-size: 12px;');
      	newWin.document.write('color: #000000;');
      	newWin.document.write('text-decoration: none;');
      newWin.document.write('}');
    newWin.document.write('</style>');
    newWin.document.write('<body style="margin:0px;">');
    newWin.document.write('<table style="width:391px;" border="0" cellpadding="0" cellspacing="0">');
      newWin.document.write('<tr>');
        newWin.document.write('<td style="padding-top:6px;padding-bottom:6px;text-align:center;background-color:#638CB8;color:#FFFFFF;font-family:sans-serif,Arial,Verdana; font-size:15px;font-weight:bold">Hinweis</td>');
      newWin.document.write('</tr>');
      newWin.document.write('<tr>');
        newWin.document.write('<td valign="top" bgcolor="#CAE4FF" style="padding-top:17px;padding-bottom:17px;">');
          newWin.document.write('<table>');
            newWin.document.write('<tr>');
              newWin.document.write('<td style="width:150px;text-align:center"><img alt="" src="images/basketpopup/cart_logo.jpg" /></td>');
              newWin.document.write('<td style="padding-left:10px;font-family:sans-serif,arial,Verdana;font-size:14px;color:#638CB8;font-weight:bold">Der Artikel wurde in<br />Ihren Warenkorb gelegt</td>');
            newWin.document.write('</tr>');
          newWin.document.write('</table>');
        newWin.document.write('<td>');
      newWin.document.write('</tr>');
      newWin.document.write('<tr>');
        newWin.document.write('<td valign="top">');
          newWin.document.write('<table>');
            newWin.document.write('<tr>');
              newWin.document.write('<td style="width:195px;text-align:center;">');
                newWin.document.write('<table align="center">');
                  newWin.document.write('<tr>');
							      newWin.document.write('<td onmouseover="document.getElementById(\'to_home\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_home\').style.textDecoration=\'underline\';" style="cursor:pointer;padding-left:5px;padding-top:2px;"><img onclick="window.close();" src="images/basketpopup/to_shop.jpg" alt="" /></td>');
							      newWin.document.write('<td><a onmouseover="document.getElementById(\'to_home\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_home\').style.textDecoration=\'underline\';" id="to_home" class="link" href="javascript: window.close();"><strong>weitershoppen</strong></a></td>');
							    newWin.document.write('</tr>');
                newWin.document.write('</table>');
              newWin.document.write('</td>');
              newWin.document.write('<td style="width:195px;text-align:center;">');
                 newWin.document.write('<table align="center">');
                  newWin.document.write('<tr>');
							      newWin.document.write('<td onmouseover="document.getElementById(\'to_login\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_login\').style.textDecoration=\'underline\';" style="cursor:pointer;padding-left:5px;padding-top:2px;"><img onclick="window.opener.location.href = \'?menu=basket\'; self.close();" src="images/basketpopup/to_cart.jpg" alt="" /></td>');
							      newWin.document.write('<td><a onmouseover="document.getElementById(\'to_login\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_login\').style.textDecoration=\'underline\';" id="to_login" class="link" href="javascript:window.opener.location.href = \'?menu=basket\'; self.close();"><strong>zum Warenkorb</strong></a></td>');
							    newWin.document.write('</tr>');
                newWin.document.write('</table>');
              newWin.document.write('</td>');
            newWin.document.write('</tr>');
          newWin.document.write('</table>');
        newWin.document.write('</td>');
      newWin.document.write('</tr>');
    newWin.document.write('</table>');
    newWin.document.write('</body>');
    newWin.document.write('</html>');
    newWin.document.close();   
  }
  
  return false;
}

function AddToBasketCross(formName,quantity) {
  
  //alert("Form name : "+formName);
  //alert("Quantity name : "+quantity);
  var val = document.getElementById(quantity).value;
  
  if (isNaN(val) || val.length == 0) {
		ok = false;
	} else if (val < 1 || val > 99999) {
		ok = false;
	} else {
		return true;
	}
	
  document.getElementById(quantity).focus();
	return false;	
}

function GoToBasket()
{
  //alert("Suntem in GoToBasket()0")
  var form = document.forms['basket'];
  
  if (AddToBasket(form))
  {
    var winleft = (screen.width - 391) / 2;
    var wintop = (screen.height - 170) / 2;  
    var newWin = window.open('', 'warenkorb', 'width=391,height=170,left='+winleft+',top='+wintop+',align=center,toolbar=no, status=no, location=no, directories=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no');
    newWin.document.open();
    newWin.document.write('<html>');
    newWin.document.write('<head>');
    newWin.document.write('<title>');
    newWin.document.write('[ In Den Warenkorb ]');
    newWin.document.write('</title>');
    newWin.document.write('</head>');
    newWin.document.write('<style type="text/css">');
      newWin.document.write('.link');
      newWin.document.write('{');
      	newWin.document.write('font-family: Verdana,sans-serif, Arial, Helvetica;');
      	newWin.document.write('font-weight: normal;');
      	newWin.document.write('font-size: 12px;');
      	newWin.document.write('color: #000000;');
      	newWin.document.write('text-decoration: underline;');
      newWin.document.write('}');
      newWin.document.write('.link:hover');
      newWin.document.write('{');
      	newWin.document.write('font-family: Verdana,sans-serif, Arial, Helvetica;');
      	newWin.document.write('font-weight: normal;');
      	newWin.document.write('font-size: 12px;');
      	newWin.document.write('color: #000000;');
      	newWin.document.write('text-decoration: none;');
      newWin.document.write('}');
    newWin.document.write('</style>');
    newWin.document.write('<body style="margin:0px;">');
    newWin.document.write('<table style="width:391px;" border="0" cellpadding="0" cellspacing="0">');
      newWin.document.write('<tr>');
        newWin.document.write('<td style="padding-top:6px;padding-bottom:6px;text-align:center;background-color:#638CB8;color:#FFFFFF;font-family:sans-serif,Arial,Verdana; font-size:15px;font-weight:bold">Hinweis</td>');
      newWin.document.write('</tr>');
      newWin.document.write('<tr>');
        newWin.document.write('<td valign="top" bgcolor="#CAE4FF" style="padding-top:17px;padding-bottom:17px;">');
          newWin.document.write('<table>');
            newWin.document.write('<tr>');
              newWin.document.write('<td style="width:150px;text-align:center"><img alt="" src="images/basketpopup/cart_logo.jpg" /></td>');
              newWin.document.write('<td style="padding-left:10px;font-family:sans-serif,arial,Verdana;font-size:14px;color:#638CB8;font-weight:bold">Der Artikel wurde in<br />Ihren Warenkorb gelegt</td>');
            newWin.document.write('</tr>');
          newWin.document.write('</table>');
        newWin.document.write('<td>');
      newWin.document.write('</tr>');
      newWin.document.write('<tr>');
        newWin.document.write('<td valign="top">');
          newWin.document.write('<table>');
            newWin.document.write('<tr>');
              newWin.document.write('<td style="width:195px;text-align:center;">');
                newWin.document.write('<table align="center">');
                  newWin.document.write('<tr>');
							      newWin.document.write('<td onmouseover="document.getElementById(\'to_home\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_home\').style.textDecoration=\'underline\';" style="cursor:pointer;padding-left:5px;padding-top:2px;"><img onclick="window.close();" src="images/basketpopup/to_shop.jpg" alt="" /></td>');
							      newWin.document.write('<td><a onmouseover="document.getElementById(\'to_home\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_home\').style.textDecoration=\'underline\';" id="to_home" class="link" href="javascript: window.close();"><strong>weitershoppen</strong></a></td>');
							    newWin.document.write('</tr>');
                newWin.document.write('</table>');
              newWin.document.write('</td>');
              newWin.document.write('<td style="width:195px;text-align:center;">');
                 newWin.document.write('<table align="center">');
                  newWin.document.write('<tr>');
							      newWin.document.write('<td onmouseover="document.getElementById(\'to_login\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_login\').style.textDecoration=\'underline\';" style="cursor:pointer;padding-left:5px;padding-top:2px;"><img onclick="window.opener.location.href = \'?menu=basket\'; self.close();" src="images/basketpopup/to_cart.jpg" alt="" /></td>');
							      newWin.document.write('<td><a onmouseover="document.getElementById(\'to_login\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_login\').style.textDecoration=\'underline\';" id="to_login" class="link" href="javascript:window.opener.location.href = \'?menu=basket\'; self.close();"><strong>zum Warenkorb</strong></a></td>');
							    newWin.document.write('</tr>');
                newWin.document.write('</table>');
              newWin.document.write('</td>');
            newWin.document.write('</tr>');
          newWin.document.write('</table>');
        newWin.document.write('</td>');
      newWin.document.write('</tr>');
    newWin.document.write('</table>');
    newWin.document.write('</body>');
    newWin.document.write('</html>');
    newWin.document.close();   
  }
}

function AddToBasket(form) {
  if (isNaN(form.quantity.value) || form.quantity.value.length == 0) {
		ok = false;
	} else if (form.quantity.value < 1 || form.quantity.value > 99999) {
		ok = false;
	} else {
		return true;
	}
	form.quantity.focus();
	return false;	
}

function GoToMemo() {
	var form = document.forms['memo'];
	//if (AddToMemo()) {
	form.submit();
	//}
}

/*function AddToMemo() {
	if (isNaN(document.basket.quantity.value) || document.basket.quantity.value.length == 0) {
		ok = false;
	} else if (document.basket.quantity.value < 1 || document.basket.quantity.value > 99999) {
		ok = false;
	} else {
		return true;
	}
	document.basket.quantity.focus();
	return false;	
}
*/

function show_list()
{
	var user_type = document.register.usertype.value;
	if(user_type == "direct_cust")
	{
		document.register.customertype.style.display = 'block';
		document.getElementById("cust_type").style.display = 'block';
	}else{
		document.register.customertype.style.display = 'none';
		document.getElementById("cust_type").style.display = 'none';
	}
	if(user_type == "via_dealer")
	{
		document.register.dealer_code.style.display = 'block';
		document.getElementById("dealer_type").style.display = 'block';
		document.getElementById("dealer_type").focus()
		document.register.dealer_code.focus()
	}else{
		document.register.dealer_code.style.display = 'none';
		document.getElementById("dealer_type").style.display = 'none';
	}
}
function go_to_shop()
{
	window.location = "http://www.wadoo.de/?menu=product"
}

function GoToBasketGutscheine()
{
  var form = document.forms.gutschein;
  
  if (AddGutscheineToBasket(form))
  {
    var winleft = (screen.width - 391) / 2;
    var wintop = (screen.height - 170) / 2;  
    var newWin = window.open('', 'warenkorb', 'width=391,height=170,left='+winleft+',top='+wintop+',align=center,toolbar=no, status=no, location=no, directories=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no');
    newWin.document.open();
    newWin.document.write('<html>');
    newWin.document.write('<head>');
    newWin.document.write('<title>');
    newWin.document.write('[ In Den Warenkorb ]');
    newWin.document.write('</title>');
    newWin.document.write('</head>');
    newWin.document.write('<style type="text/css">');
      newWin.document.write('.link');
      newWin.document.write('{');
      	newWin.document.write('font-family: Verdana,sans-serif, Arial, Helvetica;');
      	newWin.document.write('font-weight: normal;');
      	newWin.document.write('font-size: 12px;');
      	newWin.document.write('color: #000000;');
      	newWin.document.write('text-decoration: underline;');
      newWin.document.write('}');
      newWin.document.write('.link:hover');
      newWin.document.write('{');
      	newWin.document.write('font-family: Verdana,sans-serif, Arial, Helvetica;');
      	newWin.document.write('font-weight: normal;');
      	newWin.document.write('font-size: 12px;');
      	newWin.document.write('color: #000000;');
      	newWin.document.write('text-decoration: none;');
      newWin.document.write('}');
    newWin.document.write('</style>');
    newWin.document.write('<body style="margin:0px;">');
    newWin.document.write('<table style="width:391px;" border="0" cellpadding="0" cellspacing="0">');
      newWin.document.write('<tr>');
        newWin.document.write('<td style="padding-top:6px;padding-bottom:6px;text-align:center;background-color:#638CB8;color:#FFFFFF;font-family:sans-serif,Arial,Verdana; font-size:15px;font-weight:bold">Hinweis</td>');
      newWin.document.write('</tr>');
      newWin.document.write('<tr>');
        newWin.document.write('<td valign="top" bgcolor="#CAE4FF" style="padding-top:17px;padding-bottom:17px;">');
          newWin.document.write('<table>');
            newWin.document.write('<tr>');
              newWin.document.write('<td style="width:150px;text-align:center"><img alt="" src="images/basketpopup/cart_logo.jpg" /></td>');
              newWin.document.write('<td style="padding-left:10px;font-family:sans-serif,arial,Verdana;font-size:14px;color:#638CB8;font-weight:bold">Der Artikel wurde in<br />Ihren Warenkorb gelegt</td>');
            newWin.document.write('</tr>');
          newWin.document.write('</table>');
        newWin.document.write('<td>');
      newWin.document.write('</tr>');
      newWin.document.write('<tr>');
        newWin.document.write('<td valign="top">');
          newWin.document.write('<table>');
            newWin.document.write('<tr>');
              newWin.document.write('<td style="width:195px;text-align:center;">');
                newWin.document.write('<table align="center">');
                  newWin.document.write('<tr>');
							      newWin.document.write('<td onmouseover="document.getElementById(\'to_home\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_home\').style.textDecoration=\'underline\';" style="cursor:pointer;padding-left:5px;padding-top:2px;"><img onclick="window.close();" src="images/basketpopup/to_shop.jpg" alt="" /></td>');
							      newWin.document.write('<td><a onmouseover="document.getElementById(\'to_home\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_home\').style.textDecoration=\'underline\';" id="to_home" class="link" href="javascript: window.close();"><strong>weitershoppen</strong></a></td>');
							    newWin.document.write('</tr>');
                newWin.document.write('</table>');
              newWin.document.write('</td>');
              newWin.document.write('<td style="width:195px;text-align:center;">');
                 newWin.document.write('<table align="center">');
                  newWin.document.write('<tr>');
							      newWin.document.write('<td onmouseover="document.getElementById(\'to_login\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_login\').style.textDecoration=\'underline\';" style="cursor:pointer;padding-left:5px;padding-top:2px;"><img onclick="window.opener.location.href = \'?menu=basket\'; self.close();" src="images/basketpopup/to_cart.jpg" alt="" /></td>');
							      newWin.document.write('<td><a onmouseover="document.getElementById(\'to_login\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_login\').style.textDecoration=\'underline\';" id="to_login" class="link" href="javascript:window.opener.location.href = \'?menu=basket\'; self.close();"><strong>zum Warenkorb</strong></a></td>');
							    newWin.document.write('</tr>');
                newWin.document.write('</table>');
              newWin.document.write('</td>');
            newWin.document.write('</tr>');
          newWin.document.write('</table>');
        newWin.document.write('</td>');
      newWin.document.write('</tr>');
    newWin.document.write('</table>');
    newWin.document.write('</body>');
    newWin.document.write('</html>');
    newWin.document.close();
    
    document.forms.gutschein.submit();
  }
}

function AddGutscheineToBasket(form) {
  
  var chkValue0 = "";
  var chkValue1 = "";

  if(document.getElementById('gutscheineOption0').checked == true)
  {
    chkValue0 = document.getElementById('gutscheineOption0').value;
  }
  if(document.getElementById('gutscheineOption1').checked == true)
  {
    chkValue1 = document.getElementById('gutscheineOption1').value; 
  }
  
  if(document.getElementById('receiverName').value == "")
  {
     ok = false;
     alert("Bitte geben Sie den Namen des Empfängers ein .");
  }
  else
  {
    if(checkString(document.getElementById('receiverName').value) == 0)
    {
      ok = false;
      alert("Bitte geben Sie nur Buchstaben im Feld \"Name des Empfängers\" ein.");
    }
    else
    {
      var stringReceiverName = document.getElementById('receiverName').value;
      if(stringReceiverName.length > 20)
      {
        ok = false;
        alert("Der Name des Empfängers kann maximal 20 Zeichen lang sein.");
      }
      else
      {
        if(form.valueName.value == "")
        {
          ok = false;
    		  alert("Bitte geben Sie einen Wert in Euro ein .")
        }
        else
        {
          gutscheinValue = form.valueName.value;
          newNumber = transformNumber(gutscheinValue);
          
          if (isNaN(newNumber) || newNumber == 0) 
          {
      		  ok = false;
      		  alert("Bitte geben Sie den Gutscheinwert (in EUR) im Format 0,00 ein.");
        	}
          else
          { 
            if (newNumber < 5.00 || newNumber > 150.00) 
            {
      		    ok = false;
      		    alert("Der Gutscheinwert (in EUR) muss zwischen 5,00 und 150,00 Euro liegen.");
      	    }
      	    else
      	    {
      	      form.newValueName.value = newNumber;
              if((chkValue0 == "")&&(chkValue1 == ""))
              {
                alert(" Bitte wählen Sie, ob Sie oder der Empfänger den Gutschein per E-Mail erhalten soll.");
              }
              else
              {
                if(chkValue0 != "")
                {
                  if(checkMail(document.getElementById('recipientAddress').value) == 0)
                  {
                    ok = false;
                    alert("Die Emailadresse des Empfängers und die Kontrolleingabe stimmen nicht überein. Bitte korrigieren Sie Ihre Eingaben.");
                  } 
                  else
                  { 
                    if(checkMail(document.getElementById('recipientAddress1').value) == 0)
                    {
                      ok = false;
                      alert("Die Emailadresse des Empfängers und die Kontrolleingabe stimmen nicht überein. Bitte korrigieren Sie Ihre Eingaben.");
                    } 
                    else
                    {
                      if(checkSameMailAddress(document.getElementById('recipientAddress').value,document.getElementById('recipientAddress1').value) == 0)
                      {
                        ok = false;
                        alert('Die Emailadresse des Empfängers und die Kontrolleingabe stimmen nicht überein. Bitte korrigieren Sie Ihre Eingaben.');
                      }
                      else 
                      {
                		    return true;
                	    }
                	  }
                  }
        	      }
        	      else
                {
                  return true;
                }
        	    }
        	  }
          }
        }
      }
    }
  }
    
	form.valueName.focus();
  return false;
}

/* -----------==================== START REGION OCTOBER ACTION ===========------------ */
function GoToBasketOctober(quantityName,formName)
{
  
  var form = document.forms.formName;
  
  if (AddOctoberToBasket(form,quantityName))
  {
    var winleft = (screen.width - 391) / 2;
    var wintop = (screen.height - 170) / 2;  
    var newWin = window.open('', 'warenkorb', 'width=391,height=170,left='+winleft+',top='+wintop+',align=center,toolbar=no, status=no, location=no, directories=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no');
    newWin.document.open();
    newWin.document.write('<html>');
    newWin.document.write('<head>');
    newWin.document.write('<title>');
    newWin.document.write('[ In Den Warenkorb ]');
    newWin.document.write('</title>');
    newWin.document.write('</head>');
    newWin.document.write('<style type="text/css">');
      newWin.document.write('.link');
      newWin.document.write('{');
      	newWin.document.write('font-family: Verdana,sans-serif, Arial, Helvetica;');
      	newWin.document.write('font-weight: normal;');
      	newWin.document.write('font-size: 12px;');
      	newWin.document.write('color: #000000;');
      	newWin.document.write('text-decoration: underline;');
      newWin.document.write('}');
      newWin.document.write('.link:hover');
      newWin.document.write('{');
      	newWin.document.write('font-family: Verdana,sans-serif, Arial, Helvetica;');
      	newWin.document.write('font-weight: normal;');
      	newWin.document.write('font-size: 12px;');
      	newWin.document.write('color: #000000;');
      	newWin.document.write('text-decoration: none;');
      newWin.document.write('}');
    newWin.document.write('</style>');
    newWin.document.write('<body style="margin:0px;">');
    newWin.document.write('<table style="width:391px;" border="0" cellpadding="0" cellspacing="0">');
      newWin.document.write('<tr>');
        newWin.document.write('<td style="padding-top:6px;padding-bottom:6px;text-align:center;background-color:#638CB8;color:#FFFFFF;font-family:sans-serif,Arial,Verdana; font-size:15px;font-weight:bold">Hinweis</td>');
      newWin.document.write('</tr>');
      newWin.document.write('<tr>');
        newWin.document.write('<td valign="top" bgcolor="#CAE4FF" style="padding-top:17px;padding-bottom:17px;">');
          newWin.document.write('<table>');
            newWin.document.write('<tr>');
              newWin.document.write('<td style="width:150px;text-align:center"><img alt="" src="images/basketpopup/cart_logo.jpg" /></td>');
              newWin.document.write('<td style="padding-left:10px;font-family:sans-serif,arial,Verdana;font-size:14px;color:#638CB8;font-weight:bold">Der Artikel wurde in<br />Ihren Warenkorb gelegt</td>');
            newWin.document.write('</tr>');
          newWin.document.write('</table>');
        newWin.document.write('<td>');
      newWin.document.write('</tr>');
      newWin.document.write('<tr>');
        newWin.document.write('<td valign="top">');
          newWin.document.write('<table>');
            newWin.document.write('<tr>');
              newWin.document.write('<td style="width:195px;text-align:center;">');
                newWin.document.write('<table align="center">');
                  newWin.document.write('<tr>');
							      newWin.document.write('<td onmouseover="document.getElementById(\'to_home\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_home\').style.textDecoration=\'underline\';" style="cursor:pointer;padding-left:5px;padding-top:2px;"><img onclick="window.close();" src="images/basketpopup/to_shop.jpg" alt="" /></td>');
							      newWin.document.write('<td><a onmouseover="document.getElementById(\'to_home\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_home\').style.textDecoration=\'underline\';" id="to_home" class="link" href="javascript: window.close();"><strong>weitershoppen</strong></a></td>');
							    newWin.document.write('</tr>');
                newWin.document.write('</table>');
              newWin.document.write('</td>');
              newWin.document.write('<td style="width:195px;text-align:center;">');
                 newWin.document.write('<table align="center">');
                  newWin.document.write('<tr>');
							      newWin.document.write('<td onmouseover="document.getElementById(\'to_login\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_login\').style.textDecoration=\'underline\';" style="cursor:pointer;padding-left:5px;padding-top:2px;"><img onclick="window.opener.location.href = \'?menu=basket\'; self.close();" src="images/basketpopup/to_cart.jpg" alt="" /></td>');
							      newWin.document.write('<td><a onmouseover="document.getElementById(\'to_login\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_login\').style.textDecoration=\'underline\';" id="to_login" class="link" href="javascript:window.opener.location.href = \'?menu=basket\'; self.close();"><strong>zum Warenkorb</strong></a></td>');
							    newWin.document.write('</tr>');
                newWin.document.write('</table>');
              newWin.document.write('</td>');
            newWin.document.write('</tr>');
          newWin.document.write('</table>');
        newWin.document.write('</td>');
      newWin.document.write('</tr>');
    newWin.document.write('</table>');
    newWin.document.write('</body>');
    newWin.document.write('</html>');
    newWin.document.close();    
    
    document.forms[formName].submit(); 
  }else{
    alert("Your value is incorrect !");
  }
}

function AddOctoberToBasket(form,quantityName) {
  if (isNaN(document.getElementById(quantityName).value) || document.getElementById(quantityName).value.length == 0) {
		ok = false;
	} else if (document.getElementById(quantityName).value < 1 || document.getElementById(quantityName).value > 99999) {
		ok = false;
	} else {
		return true;
	}
	document.getElementById(quantityName).focus();
	return false;	
}
/* ----------===================== END REGION OCTOBER ACTION ===========-------------- */

/* -----------==================== START REGION OCTOBER ACTION ===========------------ */
function GoToBasketSimpleTablett(quantityName,formName)
{
  
  var form = document.forms.formName;
  
  if (AddSimpleTablettToBasket(form,quantityName))
  {
    var winleft = (screen.width - 391) / 2;
    var wintop = (screen.height - 170) / 2;  
    var newWin = window.open('', 'warenkorb', 'width=391,height=170,left='+winleft+',top='+wintop+',align=center,toolbar=no, status=no, location=no, directories=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no');
    newWin.document.open();
    newWin.document.write('<html>');
    newWin.document.write('<head>');
    newWin.document.write('<title>');
    newWin.document.write('[ In Den Warenkorb ]');
    newWin.document.write('</title>');
    newWin.document.write('</head>');
    newWin.document.write('<style type="text/css">');
      newWin.document.write('.link');
      newWin.document.write('{');
      	newWin.document.write('font-family: Verdana,sans-serif, Arial, Helvetica;');
      	newWin.document.write('font-weight: normal;');
      	newWin.document.write('font-size: 12px;');
      	newWin.document.write('color: #000000;');
      	newWin.document.write('text-decoration: underline;');
      newWin.document.write('}');
      newWin.document.write('.link:hover');
      newWin.document.write('{');
      	newWin.document.write('font-family: Verdana,sans-serif, Arial, Helvetica;');
      	newWin.document.write('font-weight: normal;');
      	newWin.document.write('font-size: 12px;');
      	newWin.document.write('color: #000000;');
      	newWin.document.write('text-decoration: none;');
      newWin.document.write('}');
    newWin.document.write('</style>');
    newWin.document.write('<body style="margin:0px;">');
    newWin.document.write('<table style="width:391px;" border="0" cellpadding="0" cellspacing="0">');
      newWin.document.write('<tr>');
        newWin.document.write('<td style="padding-top:6px;padding-bottom:6px;text-align:center;background-color:#638CB8;color:#FFFFFF;font-family:sans-serif,Arial,Verdana; font-size:15px;font-weight:bold">Hinweis</td>');
      newWin.document.write('</tr>');
      newWin.document.write('<tr>');
        newWin.document.write('<td valign="top" bgcolor="#CAE4FF" style="padding-top:17px;padding-bottom:17px;">');
          newWin.document.write('<table>');
            newWin.document.write('<tr>');
              newWin.document.write('<td style="width:150px;text-align:center"><img alt="" src="images/basketpopup/cart_logo.jpg" /></td>');
              newWin.document.write('<td style="padding-left:10px;font-family:sans-serif,arial,Verdana;font-size:14px;color:#638CB8;font-weight:bold">Der Artikel wurde in<br />Ihren Warenkorb gelegt</td>');
            newWin.document.write('</tr>');
          newWin.document.write('</table>');
        newWin.document.write('<td>');
      newWin.document.write('</tr>');
      newWin.document.write('<tr>');
        newWin.document.write('<td valign="top">');
          newWin.document.write('<table>');
            newWin.document.write('<tr>');
              newWin.document.write('<td style="width:195px;text-align:center;">');
                newWin.document.write('<table align="center">');
                  newWin.document.write('<tr>');
							      newWin.document.write('<td onmouseover="document.getElementById(\'to_home\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_home\').style.textDecoration=\'underline\';" style="cursor:pointer;padding-left:5px;padding-top:2px;"><img onclick="window.close();" src="images/basketpopup/to_shop.jpg" alt="" /></td>');
							      newWin.document.write('<td><a onmouseover="document.getElementById(\'to_home\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_home\').style.textDecoration=\'underline\';" id="to_home" class="link" href="javascript: window.close();"><strong>weitershoppen</strong></a></td>');
							    newWin.document.write('</tr>');
                newWin.document.write('</table>');
              newWin.document.write('</td>');
              newWin.document.write('<td style="width:195px;text-align:center;">');
                 newWin.document.write('<table align="center">');
                  newWin.document.write('<tr>');
							      newWin.document.write('<td onmouseover="document.getElementById(\'to_login\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_login\').style.textDecoration=\'underline\';" style="cursor:pointer;padding-left:5px;padding-top:2px;"><img onclick="window.opener.location.href = \'?menu=basket\'; self.close();" src="images/basketpopup/to_cart.jpg" alt="" /></td>');
							      newWin.document.write('<td><a onmouseover="document.getElementById(\'to_login\').style.textDecoration=\'none\';" onmouseout="document.getElementById(\'to_login\').style.textDecoration=\'underline\';" id="to_login" class="link" href="javascript:window.opener.location.href = \'?menu=basket\'; self.close();"><strong>zum Warenkorb</strong></a></td>');
							    newWin.document.write('</tr>');
                newWin.document.write('</table>');
              newWin.document.write('</td>');
            newWin.document.write('</tr>');
          newWin.document.write('</table>');
        newWin.document.write('</td>');
      newWin.document.write('</tr>');
    newWin.document.write('</table>');
    newWin.document.write('</body>');
    newWin.document.write('</html>');
    newWin.document.close();    
    
    document.forms[formName].submit(); 
  }else{
    alert("Your value is incorrect !");
  }
}

function AddSimpleTablettToBasket(form,quantityName) {
  if (isNaN(document.getElementById(quantityName).value) || document.getElementById(quantityName).value.length == 0) {
		ok = false;
	} else if (document.getElementById(quantityName).value < 1 || document.getElementById(quantityName).value > 99999) {
		ok = false;
	} else {
		return true;
	}
	document.getElementById(quantityName).focus();
	return false;	
}
/* ----------===================== END REGION OCTOBER ACTION ===========-------------- */

function setBasketFields(quantity,cross,motive,action,id,mid,gallery,price,plate_name,picture,articleNo,artColor,designNo)
{
  //var val = document.getElementById(''+quantity+'').value;
  document.forms['basket'].quantity.value = quantity;
  
  document.forms['basket'].cross.value = cross;
  document.forms['basket'].motive.value = motive;
  document.forms['basket'].action.value = action;
  document.forms['basket'].id.value = id;
  document.forms['basket'].mid.value = mid;
  document.forms['basket'].gallery.value = gallery;
  document.forms['basket'].price.value = price;
  document.forms['basket'].plate_name.value = plate_name;
  document.forms['basket'].req_pic.value = picture;
  document.forms['basket'].article_no.value = articleNo;
  document.forms['basket'].art_color.value = artColor;
  document.forms['basket'].design.value = designNo;
  
  GoToBasket();

}

function checkMail(email)
{
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  if (filter.test(email))
    return 1;
  else{
    return 0;
  }
}



function checkString(name)
{
  var ok = 0;
	var nameArray = name.split(" ");
  var filter = /^[A-Za-z-\xE4\xF6\xFC\xDF\xC4\xD6\xDC\xE9]{1,200}$/i;
  
  if(nameArray.length > 1)
  {
    for(var i=0;i<nameArray.length;i++)
    {
      if(filter.test(nameArray[i]))
    	 ok = 1;
    	else
    	 ok = 0;
    }
  }else{
    if(filter.test(nameArray[0]))
  	 ok = 1;
  	else
  	 ok = 0;
  }
  
  return ok;	 
}


//Add by Ovidiu -> populate in Last Minute Gutscheine With Images
//for preview the category selected

function populateWithImages()
{
  var selectedValue = document.getElementById('designSelect').value;
  if(selectedValue == 'Weihnachtszeit')
  {
    tempArray = location.href.split("/");
    var urlString = "";
    for(var i=0;i<tempArray.length-1;i++)
    {
      urlString += tempArray[i]+"/";
    }
    value = "Weihnachten";
    urlString += "AjaxResponse/gutscheine_response.php?value="+value;
    //alert(urlString);
    
    http.open('GET', urlString);
    http.onreadystatechange = updateGutscheinePreview;
    http.send(null);
  }
}

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();


function updateGutscheinePreview(){
  if(http.readyState == 4)
  {
    if(http.status == 200)
    {
      ok = http.responseText;
      tempArray = ok.split("|");
      for(var i=0;i<tempArray.length-1;i++)
      {
        alert(tempArray[i]);
      }
    }
  }
}

function enable_disable_Email()
{
  if(document.getElementById('gutscheineOption0').checked == true)
  {
    document.getElementById('recipientAddress').disabled = false;
    document.getElementById('recipientAddress1').disabled = false;
    document.getElementById('recipientAddress').style.backgroundColor = "#FFFFFF";
    document.getElementById('recipientAddress1').style.backgroundColor = "#FFFFFF";
  }else{
    document.getElementById('recipientAddress').disabled = true;
    document.getElementById('recipientAddress1').disabled = true;
    document.getElementById('recipientAddress').style.backgroundColor = "#E5E4E4";
    document.getElementById('recipientAddress1').style.backgroundColor = "#E5E4E4";
  }
}

function checkSameMailAddress(recipientAddress0,recipientAddress1)
{
  if(recipientAddress0 == recipientAddress1)
  {
    return 1;
  }
  else
  {
    return 0;
  }
}

function isInt(myNum) {
 // get the modulus: if it's 0, then it's an integer
 var myMod = myNum % 1;

 if (myMod == 0) {
         return true;
 } else {
         return false;
 }
}

function transformNumber(gutscheinValue)
{
  
  var returnNumber = 0;
  tempArray1 = gutscheinValue.split(".");
  
  if(tempArray1.length>1)
  {
    //alert("Bitte geben Sie den Gutscheinwert (in EUR) im Format 0,00 ein.");
  }
  else
  {
    tempArray = gutscheinValue.split(",");
    if(tempArray.length > 2)
    {
      //alert("Bitte geben Sie den Gutscheinwert (in EUR) im Format 0,00 ein.");
    }else{
      if(tempArray.length == 1)
      {
        returnNumber = tempArray[0];
      }
      else
      {
        if(tempArray[1].length > 2)
        {
          //alert("Bitte geben Sie den Gutscheinwert (in EUR) im Format 0,00 ein.");
        }
        else
        {
          if(tempArray[1].length == 0)
          {
            //alert("Bitte geben Sie den Gutscheinwert (in EUR) im Format 0,00 ein.");
          }
          else
          {
            var firstNumber = String(tempArray[0])+"";
            
            for(i=0;i<firstNumber.length;i++)
            {
              var numberCalculate = firstNumber.charAt(i)*Math.pow(10,(firstNumber.length - 1 - i));
              returnNumber += numberCalculate;
            }
            
            var secondNumber = tempArray[1];
            if(secondNumber.length > 0)
            {
              for(j=0;j<secondNumber.length;j++)
              {
                var numberCalculate = secondNumber.charAt(j)*Math.pow(10,-(j+1));
                returnNumber += numberCalculate;
              }
            }
            
          }
        }
      }
    }
  }
  
  return returnNumber;
}
