function eBookStoreShowContents(product_uid, product_pid) {
	var filename = '/index.php?id=225&eBook=' + product_uid + '&eBookCat=' + product_pid;
	eBookStoreShowFile(filename);
}

function eBookStoreSubmit() {
	document.getElementById('basket_form').submit();
}

function eBookStoreSubmitGratis() {
	document.getElementById('basket_form_gratis').submit();
}

function eBookStoreDeleteItemFromBasket(uid) {
  var confirmation = window.confirm("Soll der Artikel wirklich gelöscht werden?")
  
  if (confirmation) {
	  document.getElementById('products_qty_' + uid).value = 0;
		document.getElementById('basket_form').submit();
	}
}

function eBookStoreConfirmDeleteBasket() {
  var confirmation = window.confirm("Möchten Sie Ihren Warenkorb wirklich löschen?")

  if (confirmation) { return true; }
  else { return false; }
}

function eBookStoreLogIn() {
	document.getElementById('login_form').submit();
}

function eBookStoreLogOut() {
	eBookStoreLogIn();
}

function eBookStoreForgotPassword() {
	eBookStoreLogIn();
}

function eBookStoreCheckEmail(value)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,10})+$/.test(value))	{
		return true;
	}	else {
		return false;
	}
}

function eBookStoreCheckNewCustomerForm() {
	var result = true;

	if (document.getElementById('is_logged_in').value == 0) {
		if (document.getElementById('billing_first_name').value == '')
		{
			if (result) {
				result = false;
				alert('Bitte geben Sie Ihren Vornamen ein.');
				document.getElementById('billing_first_name').focus();
			}
		}
		if (document.getElementById('billing_last_name').value == '')
		{
			if (result) {
				result = false;
				alert('Bitte geben Sie Ihren Nachnamen ein.');
				document.getElementById('billing_last_name').focus();
			}
		}
		if (document.getElementById('billing_email').value == '' || eBookStoreCheckEmail(document.getElementById('billing_email').value) == false)
		{
			if (result) {
				result = false;
				alert('Bitte geben Sie Ihre E-Mail Adresse ein.');
				document.getElementById('billing_email').focus();
			}
		}
		if (document.getElementById('billing_email2').value == '')
		{
			if (result) {
				result = false;
				alert('Bitte bestätigen Sie Ihre E-Mail Adresse.');
				document.getElementById('billing_email2').focus();
			}
		}
		if (document.getElementById('billing_email2').value != document.getElementById('billing_email').value)
		{
			if (result) {
				result = false;
				alert('Bitte überprüfen Sie Ihre E-Mail Adresse.');
				document.getElementById('billing_email2').focus();
			}
		}
	}
	if (!document.getElementById('form_1').checked)
	{
		if (result) {
			result = false;
			alert('Bitte akzeptieren Sie unsere Allgemeinen Geschäftsbedingungen.');
			document.getElementById('form_1').focus();
		}
	}

	if (result) {	eBookStoreSubmit(); }
}

function eBookStoreShowFile(filename)
{
	var width = screen.availWidth;
	var height = screen.availHeight;

  if (width > 1280) {width = 1280;}
  if (height > 1024) {height = 1024;}

  var posx = ((width) - 600) / 2;
  var posy = (((height) - 400) / 2) - 200;

  if (posx < 1) {posx = 1;}
  if (posy < 1) {posy = 1;}

  posx = Math.floor(posx);
  posy = Math.floor(posy);

  var fenster = window.open(filename, 'popup', 'width=600,height=400,left='+posx+',top='+posy+',location=no,menubar=no,resizeable=yes,scrollbars=yes,status=no,toolbar=no,hotkeys=no,dependent=yes');
}

function eBookStoreShowVideoImageNormal(image_object) {
	image_object.src = 'fileadmin/template/images/video.jpg';
}

function eBookStoreShowVideoImageMouseOver(image_object) {
	image_object.src = 'fileadmin/template/images/video_over.jpg';
}

function eBookStoreShowVideo(filename)
{
	var width = screen.availWidth;
	var height = screen.availHeight;

  if (width > 1280) {width = 1280;}
  if (height > 1024) {height = 1024;}

  var posx = ((width) - 500) / 2;
  var posy = (((height) - 450) / 2) - 200;

  if (posx < 1) {posx = 1;}
  if (posy < 1) {posy = 1;}

  posx = Math.floor(posx);
  posy = Math.floor(posy);

  var fenster = window.open(filename, 'videopopup', 'width=500,height=450,left='+posx+',top='+posy+',location=no,menubar=no,resizeable=no,scrollbars=no,status=no,toolbar=no,hotkeys=no,dependent=yes');
}