   var result_div = '';
   var error_div = '';
   var hour_div = '';
   var hour_div2 = '';
   var bdone = false;
   var nlogintype = 's';

   var tStart  = 0;
   var tStartimg  = 0;

  function ptaKepHelyHiba(ojjektum, hiba){
  	if(document.getElementById(error_div)) {
			document.getElementById(error_div).innerHTML = "Hiba. " + hiba.name + " :: " + hiba.fileName + " :: " + hiba.lineNumber + " :: " + hiba.message;
  	}
  	else {
  		alert( "Hiba. " + hiba.name + " :: " + hiba.fileName + " :: " + hiba.lineNumber + " :: " + hiba.message);
  	}
	}

	function ptaLoading(){
		if(document.getElementById(hour_div)) {
			document.getElementById(hour_div).style.display = "";
		}
	}

	function ptaComplete(){

		if(document.getElementById(hour_div)) {
			document.getElementById(hour_div).style.display = "none";
		}
		bdone = true;
	}

	function ptaCompleteZip(originalRequest) {
				//document.getElementById(result_div).value = originalRequest.responseText;
		if(document.getElementById(result_div)) {
			$(result_div).value = originalRequest.responseText;
			if(document.getElementById(hour_div)) $(hour_div).style.display = "none";
		}

		bdone = true;
	}

	function getzip($field, $fieldres) {

  	result_div = $fieldres;
 	  error_div = $fieldres;
 	  hour_div = '';

 	  if(document.getElementById(hour_div)) document.getElementById(hour_div).style.display = "";

   	var poststr = "id=" + escape(encodeURI( $($field).value ));

    var ajax = new Ajax.Request(
			"http://exi.hu/getzip.php",
				{
					method: "post",
					parameters: poststr,
					onLoading: ptaLoading,
					onComplete: ptaCompleteZip,
					onException: ptaKepHelyHiba
				}
			);
  }

  function logout() {

  	result_div = 'dvlogin';
 	  error_div = 'dvlogin';
 	  hour_div = '';
 	  bdone = false;

 	  var poststr = "show=logout";

    var ajax = new Ajax.Updater(
			result_div,
			"http://exi.hu/logon.php",
			{
				method: "post",
				parameters: poststr,
				onLoading: ptaLoading,
				onComplete: ptaComplete,
				onException: ptaKepHelyHiba
			}
		);

		timerID = setTimeout("refcart()", 1000);
  }

  function login(type) {

  	nlogintype = type;

  	result_div = 'dvlogin';
 	  error_div = 'dvlogin';
 	  hour_div = '';
 	  bdone = false;

 	  var poststr = "show=login&name=" + escape(encodeURI( $('txtusername').value )) +
 	  	"&psw=" + escape(encodeURI( $('txtpassw').value )) + "&type=" + escape(encodeURI( 'type' ));

    var ajax = new Ajax.Updater(
			result_div,
			"http://exi.hu/logon.php",
			{
				method: "post",
				parameters: poststr,
				onLoading: ptaLoading,
				onComplete: ptaComplete,
				onException: ptaKepHelyHiba
			}
		);

		timerID = setTimeout("refcart()", 1000);
	}

  function refcart() {

  	clearTimeout(timerID);
    timerID  = 0;

    if(bdone) {

	  	result_div = 'dvcart';
	 	  error_div = 'dvcart';
	 	  hour_div = '';
	 	  bdone = false;

	 	  var poststr = "show=refcart&mode=" + nlogintype;

	    var ajax = new Ajax.Updater(
				result_div,
				"http://exi.hu/cart.php",
				{
					method: "post",
					parameters: poststr,
					onLoading: ptaLoading,
					onComplete: ptaComplete,
					onException: ptaKepHelyHiba
				}
			);

			timerID = setTimeout("showrate()", 1000);
    }
    else {
    	timerID = setTimeout("refcart()", 1000);
    }
  }

  function showrate() {

  	clearTimeout(timerID);
    timerID  = 0;

    if(bdone) {

	  	result_div = 'dvrate';
	 	  error_div = 'dvrate';
	 	  hour_div = '';
	 	  bdone = false;

	 	  var poststr = "show=showrate";

	    var ajax = new Ajax.Updater(
				result_div,
				"http://exi.hu/rates.php",
				{
					method: "post",
					parameters: poststr,
					onLoading: ptaLoading,
					onComplete: ptaComplete,
					onException: ptaKepHelyHiba
				}
			);
    }
    else {
    	timerID = setTimeout("showrate()", 1000);
    }
  }

  function addrate() {

  	result_div = 'dvrates';
 	  error_div = 'dvrates';
 	  hour_div = '';

 	  var poststr = "show=addrate&comment=" + escape(encodeURI( $('txtcomment').value )) +
 	  	"&rate=" + escape(encodeURI( $('boxrate').value )) + "&id=" + escape(encodeURI( $('prodid').value ));

    var ajax = new Ajax.Updater(
			result_div,
			"http://exi.hu/rates.php",
			{
				method: "post",
				parameters: poststr,
				onLoading: ptaLoading,
				onComplete: ptaComplete,
				onException: ptaKepHelyHiba
			}
		);
  }

  function addcart(id, quan, netto, brutto, afa) {

  	result_div = 'dvcart';
 	  error_div = 'dvcart';
 	  hour_div = '';
 	  hour_div2 = '';

  	if(document.getElementById('cart')) {
  		if(tStartimg == 0) {
				document.getElementById('cart').style.background = 'url(http://exi.hu/tpls/_img/colRightCartBgHover.gif)';
				tStartimg = 1;
  		}
			else {
				document.getElementById('cart').style.background = 'url(http://exi.hu/tpls/_img/colRightCartBgHover2.gif)';
				tStartimg = 0;
			}
		}


 	  var poststr = "show=addcart&mode=s&id=" + escape(encodeURI( id )) +
 	  	"&quan=" + escape(encodeURI( $(quan).value )) +
 	  	"&netto=" + escape(encodeURI( netto )) +
 	  	"&brutto=" + escape(encodeURI( brutto )) +
 	  	"&afa=" + escape(encodeURI( afa ));

    var ajax = new Ajax.Updater(
			result_div,
			"http://exi.hu/cart.php",
			{
				method: "post",
				parameters: poststr,
				onLoading: ptaLoading,
				onComplete: ptaComplete,
				onException: ptaKepHelyHiba
			}
		);
  }

  function clearcart(mode) {

  	result_div = 'dvcart';
 	  error_div = 'dvcart';
 	  hour_div = '';
	 	bdone = false;

 	  var poststr = "show=clearcart" +
 	  	"&mode=" + escape(encodeURI( mode ));

    var ajax = new Ajax.Updater(
			result_div,
			"http://exi.hu/cart.php",
			{
				method: "post",
				parameters: poststr,
				onLoading: ptaLoading,
				onComplete: ptaComplete,
				onException: ptaKepHelyHiba
			}
		);

		if(mode == 'd') {
			timerID = setTimeout(" gomainpage()", 1000);
		}
  }

  function gomainpage() {

  	clearTimeout(timerID);
    timerID  = 0;

    if(bdone) {

	  	location.href = "index.php?show=main";

    }
    else {
    	timerID = setTimeout("gomainpage()", 1000);
    }
  }

  function delcart(mode, id) {

  	result_div = 'dvcart';
 	  error_div = 'dvcart';
 	  hour_div = '';

 	  var poststr = "show=delcart&id=" + escape(encodeURI( id )) +
 	  	"&mode=" + escape(encodeURI( mode ));

    var ajax = new Ajax.Updater(
			result_div,
			"http://exi.hu/cart.php",
			{
				method: "post",
				parameters: poststr,
				onLoading: ptaLoading,
				onComplete: ptaComplete,
				onException: ptaKepHelyHiba
			}
		);
  }

  function modcart(mode, id, ndb) {

  	result_div = 'dvcart';
 	  error_div = 'dvcart';
 	  hour_div = '';

 	  var poststr = "show=modcart&id=" + escape(encodeURI( id )) +
 	  	"&ndb=" + escape(encodeURI( ndb )) +
 	  	"&mode=" + escape(encodeURI( mode ));

    var ajax = new Ajax.Updater(
			result_div,
			"http://exi.hu/cart.php",
			{
				method: "post",
				parameters: poststr,
				onLoading: ptaLoading,
				onComplete: ptaComplete,
				onException: ptaKepHelyHiba
			}
		);
  }

  function modShipType(mode) {
  	result_div = 'divshp';
 	  error_div = 'divshp';
 	  hour_div = '';

 	  var poststr = "show=modshipment&mode=" + escape(encodeURI( $(mode).value  ));

    var ajax = new Ajax.Updater(
			result_div,
			"http://exi.hu/cart.php",
			{
				method: "post",
				parameters: poststr,
				onLoading: ptaLoading,
				onComplete: ptaComplete,
				onException: ptaKepHelyHiba
			}
		);
  }
