	function start () {
		if (!document.getElementById || !document.createElement || !document.appendChild) return false;		
		$("#output_main").load("./main.html");
		
	}
	
	function hideSimilarMenus( obj, ptg, is_ie ) {		
		var li = obj.getElementsByTagName('li');		
		for (i=0; i<li.length; i++) if (li[i].className == 'active') return;
		if (ptg == 'DIV') $('.active').removeClass();
		
		var subs = obj.parentNode.getElementsByTagName('ul');
		if (is_ie) for (i=0; i<subs.length; i++) subs[i].style.display = "none";
		else for (i=0; i<subs.length; i++) $(subs[i]).slideUp();
		
		var images = obj.parentNode.getElementsByTagName('img');
		for (i=0; i<images.length; i++) images[i].src = "http://127.0.0.1/eshop/images/plus.gif";		
		
	}
	
// Cart Functions
	
	function loadcart ( div_id, req ) {
		document.getElementById(div_id).innerHTML = '<div>Kraunasi... <img src="http://127.0.0.1/eshop/images/cart_load.gif" /></div>';
		$("#"+div_id).load("http://127.0.0.1/eshop/index.php?"+req, function(response, status, xhr) {
			if (status == "error") { var msg = "Sorry but there was an error: "; $("#"+div_id).html(msg + xhr.status + " " + xhr.statusText); }
		} );
	}
	
	function updateproduct( prod_id ) {
		var new_amount = document.getElementById("prod-" + prod_id + "-amount").value;
		var subm = new Array();		
		subm[0] = new Array("cartfunc", 'updateprod');
		subm[1] = new Array("prodid", prod_id);
		subm[2] = new Array("amount", new_amount);		
		submitPost ( window.location, subm );	
	}
	
	function deleteproduct( prod_id ) {
		var subm = new Array();		
		subm[0] = new Array("cartfunc", 'deleteprod');
		subm[1] = new Array("prodid", prod_id);	
		submitPost ( window.location, subm );
	}
	
	function addToCart( add_prod_id ) { loadcart( "cart", "cartfunc=addtocart&prodid=" + add_prod_id); }
	
	function emptycart () { loadcart("cart", "cartfunc=emptycart"); }
	
// Additional Functions

	function urlparamselect ( req_name ) {
		var result = window.location.search.match( new RegExp(req_name + "=((\\d+)(,(\\d+))*)", "i") );
		if (result != null) result = RegExp.$1.split(',');
		return result;
	}
	
	function urllastparamselect () {
		var result = window.location.href.match( new RegExp("((\\d+)(,(\\d+))*)" + ".html", "i") );
		if (result != null) return RegExp.$1.split(',');
		else return 0;
	}

	function getCookie (Name) { 
		var ret = new RegExp(Name+"=[^;]+", "i");
		if (document.cookie.match(ret)) return document.cookie.match(ret)[0].split("=")[1];
		return null;
	}
	
	function setCookie(name, value) { document.cookie = name + "=" + value + "; path=/"; }
	
	function createElement(type, father_obj, id, class_name) {		
		var newel = document.createElement( type );
		newel.setAttribute('id', id);
		newel.setAttribute('class', class_name);
		father_obj.appendChild(newel);
		return newel;
	}
	
	function getObjAbsolutePosition( obj, do_alert ) {
		var topValue=0, leftValue=0;
		while (obj) {
			leftValue += obj.offsetLeft;
			topValue += obj.offsetTop;
			obj = obj.offsetParent;
		}
		if (do_alert) alert("Left: " + leftValue + ", Top:" + topValue);
		else {
			var ret = new Array();
			ret['left'] = leftValue; ret['top'] = topValue;
			return ret;
		}
	}
	
	function submitPost( action, subm ) {		
		var myForm = document.createElement("form"); myForm.method = "post"; myForm.action = action;		
		for (i=0; i<subm.length; i++) {
			var myInput = document.createElement("input") ;
			myInput.setAttribute("name", subm[i][0]) ;
			myInput.setAttribute("value", subm[i][1]);
			myForm.appendChild(myInput);
		}
		document.body.appendChild(myForm); myForm.submit(); document.body.removeChild(myForm);		
	}
