window.onload = StandardOnLoad;



function StandardOnLoad()

{

	if (document.getElementById)

	{

		// Validate Contact Details Form

		var aContactDetailsForm = document.getElementById('contactdetailsform');

		if (aContactDetailsForm != null)

		{

			//aContactDetailsForm.onsubmit = alert('test');

			//aContactDetailsForm.onsubmit = Validate();

		}

	}	

}



function MyFormCommands() {

alert('Some Text');

}



function Show(aBoxID)

{

	aTextToShow = document.getElementById(aBoxID);

	

	if (aTextToShow != null)

	{

		aTextToShow.style.display = 'block';

	}	

	

}



function Hide(aBoxID)

{

	aTextToHide = document.getElementById(aBoxID);

	

	if (aTextToHide != null)

	{

		aTextToHide.style.display = 'none';

	}	

	

}



function CheckRetailPrice(aTotalPricePerBook)

{

	RetailPrice = document.getElementById('RetailPrice');

	//alert(RetailPrice.value);

	

	RetailPrice.value=RetailPrice.value.replace(",",".");

	

		//alert(RetailPrice.value);

	if (RetailPrice != null)

	{

		aShowWarning = document.getElementById('RetailPriceWarning');



		

		

		if (RetailPrice.value < aTotalPricePerBook)

		{

			aShowWarning.style.display = 'block';



			RetailPrice.focus();

		}

		else

		{

			aShowWarning.style.display = 'none';

			

			RetailPrice.focus();

		}

	}

}







function CheckRetailPrice22(aTotalPricePerBook)

{

	RetailPrice = document.getElementById('RetailPrice');

	//alert(RetailPrice.value);

	

	RetailPrice.value=RetailPrice.value.replace(",",".");

	

		//alert(RetailPrice.value);

	if (RetailPrice != null)

	{

		aShowWarning = document.getElementById('RetailPriceWarning');

		var ei, t;

		ei = document.getElementById('earn_info');

		t=(RetailPrice.value-aTotalPricePerBook)/2;

		t=t.toFixed(2);

		if(t>0)

			ei.innerHTML=t+'€';

		else

			ei.innerHTML='0.00€';

		

		

		

		if (RetailPrice.value < aTotalPricePerBook)

		{

			aShowWarning.style.display = 'block';



			RetailPrice.focus();

		}

		else

		{

			aShowWarning.style.display = 'none';

			

			RetailPrice.focus();

		}

	}

}



// Validate the form function

function Validate()

{

	aContactDetails = document.getElementById('contactdetailsform');

	

	// if statements check whether values are present in the relevant form fields

	if (aContactDetails.RetailPrice.value.length == "") {

	var aRetailPrice = aContactDetails.RetailPrice;

	alert("Retail Price/Ladenpreis?");

	aRetailPrice.focus();

	return false;

	}

	

	

	var aEmailAddress = aContactDetails.Email;

	

	if (ValidateEmail(aEmailAddress.value) == false)

	{

		aEmailAddress.value = "";

		aEmailAddress.focus();

		return false;

	}	

    

  return true;

}



// Validate Email Address

function ValidateEmail(str)

{

	var at="@"

	var dot="."

	var lat=str.indexOf(at)

	var lstr=str.length

	var ldot=str.indexOf(dot)

	

	if (str.indexOf(at)==-1)

	{

	   alert("eMail?");

	   return false;

	}



	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)

	{

	   alert("eMail?");

	   return false;

	}



	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)

	{

		alert("eMail?");

		return false;

	}



	 if (str.indexOf(at,(lat+1))!=-1)

	 {

		alert("eMail?");

		return false;

	 }



	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)

	 {

		alert("eMail?");

		return false;

	 }



	 if (str.indexOf(dot,(lat+2))==-1)

	 {

		alert("eMail?");

		return false;

	 }

	

	 if (str.indexOf(" ")!=-1)

	 {

		alert("eMail?");

		return false;

	 }



	 return true;					

}





function calc_lek_no()

{

	e_lekno = document.getElementById('lek_no');

	e_lekno.value=e_lekno.value.replace(",",".");



	if (e_lekno != null)

	{

		/*if (e_lekno.value > 0)

		{*/

			

			var e_display, cval, eh_lek_no_val, echk_is_calc;

			echk_is_calc = document.getElementById('is_calc_lek_no');

			e_display = document.getElementById('lek_info');

			eh_lek_no_val = document.getElementById('lek_no_val');



            echk_is_calc.checked = e_lekno.value > 0;

			

			cval = e_lekno.value / 1650 * 8;

			eh_lek_no_val.value = cval.toFixed(2);

			e_display.innerHTML= cval.toFixed(2)+ ' €';

			e_lekno.focus();

		//}



	}

}
