	var popWin = null;

	function openPop(popUp)
	{

	     if (popWin && !popWin.closed) {

		popWin.close();

	     }

	     popWin = window.open(popUp, "popWin", "scrollbars=0,toolbars=0,resizable=0")

	     popWin.focus()

	}

	function validateOnSubmit()
	{

		var elem = document.forms.checkout.shipChoice;

		return (radio_button_checker(elem));

	}

	function radio_button_checker(elem)
	{
		// set var radio_choice to false
		var radio_choice = false;

		// Loop from zero to the one minus the number of radio button selections
		for (counter = 0; counter < elem.length; counter++)
		{
			// If a radio button has been selected it will return true
			// (If not it will return false)
			if (elem[counter].checked)
			radio_choice = true;
		}

		if (!radio_choice)
		{
			// If there were no selections made display an alert box
			alert("Моля изберете начин на плащане и доставка.")
			return (false);
		}

		return (true);
	}

	function validateOnSubmit() {

		var elem;
		var errs=0;

		if (invoice==1) {
			if (!validatePresent(document.forms.register.oInvMOL,  'inf_oInvMOL'))        errs += 1;
			if (!validatePresent(document.forms.register.oInvAddress,  'inf_oInvAddress'))        errs += 1;
			if (!validatePresent(document.forms.register.oInvCity,  'inf_oInvCity'))        errs += 1;
			if (!validatePresent(document.forms.register.oInvName,  'inf_oInvName'))        errs += 1;
		}

		if (!validatePresent(document.forms.register.clientPass,  'inf_clientPass'))        errs += 1;
		if (!validatePresent(document.forms.register.clientLogin,  'inf_clientLogin'))        errs += 1;
		if (!validateTelnr  (document.forms.register.clientTel1, 'inf_clientTel1', true)) errs += 1;
		if (!validatePresent(document.forms.register.clientZIP,  'inf_clientZIP'))        errs += 1;
		if (!validatePresent(document.forms.register.clientCity,  'inf_clientCity'))        errs += 1;
		if (!validatePresent(document.forms.register.clientAddress,  'inf_clientAddress'))        errs += 1;
		if (!validateEGN  (document.forms.register.clientEGN, 'inf_clientEGN', true)) errs += 1;
		if (!validateEmail  (document.forms.register.clientEmail, 'inf_clientEmail', true)) errs += 1;
		if (!validatePresent(document.forms.register.clientLast,  'inf_clientLast'))        errs += 1;
		if (!validatePresent(document.forms.register.clientFirst,  'inf_clientFirst'))        errs += 1;



		if (errs>=1)  alert('Моля корегирайте или попълнете липсващата информация.');

		return (errs==0);
	};

	var invoice = 0;

	function toggleInvoice(inv,id)
	{
		if (document.getElementById)
		{
			var e = document.getElementById(id);

			if (e)
			{
				if (inv==1)
				{
					e.style.display = "block";
					invoice=1;
				}
				else
				{
					e.style.display = "none";
					invoice =0;
				}

			}
		}

	}

	function place_attributes(){
		var left_td = document.getElementById('left_spacer_td').offsetWidth;
		document.getElementById('logo').style.left=parseInt(left_td+20)+'px';

		var right_td = document.getElementById('right_spacer_td').offsetLeft;
		document.getElementById('login_conteiner').style.left=parseInt(right_td-150)+'px';
	}

	function show_login(){

		var log_div = document.getElementById('login_div');
		if(log_div.offsetTop!=0){
			log_div.style.top=parseInt(log_div.offsetTop*(0.85))+'px';
			lefttime=setTimeout('show_login()',25);
		}
	}

	function menu_bg(event){

		var bg = document.getElementById('menu_conteiner');

		bg_top = bg.offsetTop;
		bg_bottom = parseInt(bg.offsetHeight+bg_top);

		bg_left = document.getElementById('left_spacer_td').offsetWidth;
		bg_right = parseInt(bg.offsetWidth+bg_left);

		if((event.clientX>bg_left)&&(event.clientX<bg_right)&&(event.clientY>bg_top)&&(event.clientY<bg_bottom)){

			bg.style.backgroundPosition = (event.clientX-bg_left-83)+'px center';
		}
	}

	function page_location(url){
		document.location = url;
	}

	function Calculator(a1, a2, b1, b2, c1, c2)
	{
	var Rezultat1, Rezultat2, ostatyk, Razlika, Razlika2, znak, Procent, S1, Cl1, Vs1, S2, Cl2, Vs2;
	S1=a1.value; S2=a2.value; Cl1=b1.value; Cl2=b2.value; Vs1=c1.value; Vs2=c2.value;
	 Rezultat1=Cl1*25.4+2*(Vs1*(S1/100));
	 Rezultat2=Cl2*25.4+2*(Vs2*(S2/100));

		ostatyk = (Rezultat2-Rezultat1);
		if(Rezultat1==null&&Rezultat1==null) {
			Razlika=0+"mm";
			Razlika2=0+"km";
		}
		else {
			if (ostatyk>0) {
				znak="+";
				}
			else  {
				znak="";
				}
			Razlika=ostatyk;
			Procent = (ostatyk*100)/Rezultat1;
			Razlika2=(100-Procent);
			}
	document.Calc.textfield1.value=znak + String(Math.round(Razlika));
	document.Calc.textfield2.value=Math.round(Razlika2);
	document.Calc.textfield3.value=Math.round(Rezultat1);
	document.Calc.textfield4.value=Math.round(Rezultat2);
	}

	function init() {

		if (TransMenu.isSupported()) {
			TransMenu.initialize();

		}
	}
	function div_positions(){

		var left_td = document.getElementById('left_spacer_td').offsetWidth;
		document.getElementById('logo').style.left=parseInt(left_td+20)+'px';

		var right_td = document.getElementById('right_spacer_td').offsetLeft;
		document.getElementById('login_conteiner').style.left=parseInt(right_td-150)+'px';
	}
