



function make_link(url)
	{
	gigel = window.open();
	gigel.document.location.href='http://'+url.replace("|",".").replace("|",".").replace("|",".").replace("|",".").replace("|",".").replace("|",".").replace("|",".").replace("|",".");
	}
	
	
	

	
	
	
//////////////////////////////////////// AJAX FUNCTIONS ////////////////////////////////////////////


			var req;
			var req2;
			 // pentru ajax-ul de pe pagina de categorii
			
			
			
			var sitepath=root_path;
			var elem_blur = new Array;
			
			
	function loadXMLDoc(url) {

   				// Internet Explorer
   				try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
   				catch(e) {
      				try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
      				catch(oc) { req = null; }
   				}
   				// Mozailla/Safari
   				if (!req && typeof XMLHttpRequest != "undefined") { req = new XMLHttpRequest(); }

   				// Call the processChange() function when the page has loaded
   				if (req != null) {
      				req.onreadystatechange = processChange;
      				req.open("GET", url, true);
      				req.send(null);
   				}
			}

	function processChange() {
				
   				// The page has loaded and the HTTP status code is 200 OK
   				if (req.readyState == 4 && req.status == 200) {
   					//alert(req.responseText);
      				// Write the contents of this URL to the searchResult layer
      				getObject("cart_content").innerHTML = req.responseText;
				}
			}

	function getObject(name) {
   				var ns4 = (document.layers) ? true : false;
   				var w3c = (document.getElementById) ? true : false;
   				var ie4 = (document.all) ? true : false;

   				if (ns4) return eval('document.' + name);
   				if (w3c) return document.getElementById(name);
   				if (ie4) return eval('document.all.' + name);
   				return false;
			}

			
	function loadXMLDoc2(url) {

			
   				// Internet Explorer
   				try { req2 = new ActiveXObject("Msxml2.XMLHTTP"); }
   				catch(e) {
      				try { req2 = new ActiveXObject("Microsoft.XMLHTTP"); }
      				catch(oc) { req2 = null; }
   				}
   				// Mozailla/Safari
   				if (!req2 && typeof XMLHttpRequest != "undefined") { req2 = new XMLHttpRequest(); }

   				// Call the processChange() function when the page has loaded
   				if (req2 != null) {
      				req2.onreadystatechange = processChange2;
      				req2.open("GET", url, true);
      				req2.send(null);
   				}
			}

	function processChange2() {
				
   				// The page has loaded and the HTTP status code is 200 OK
   				if (req2.readyState == 4 && req2.status == 200) {
   					//alert(req2.responseText);
      				// Write the contents of this URL to the searchResult layer
      				getObject2("shopped_items").innerHTML = req2.responseText;
				}
   				}
			
			
			
	function getObject2(name) {
   				var ns4 = (document.layers) ? true : false;
   				var w3c = (document.getElementById) ? true : false;
   				var ie4 = (document.all) ? true : false;

   				if (ns4) return eval('document.' + name);
   				if (w3c) return document.getElementById(name);
   				if (ie4) return eval('document.all.' + name);
   				return false;
			}
			
			
			
			
			
			
			
			
			
			
			
			
			
			
	function add_item(id, price,tip){	
	  			//alert(id);alert(price);
				if(id=='') productId=0;
				if(price=='') productPrice=0;
				var path= sitepath+'/include/shoppingCart/shopping_cart_add.php?productId='+id+'&productPrice='+price+'&type='+tip;
				loadXMLDoc(path);
				//alert('Produsul a fost adaugat');
				
				setTimeout("window.location.href='http://www.mnitaly.ro/cos-produse/'",80);
	
				
			}
		
			
			
			
	function show_cart(){	
	  				  			
				
				var path= sitepath+'/include/shoppingCart/show.php';
				loadXMLDoc(path);
	
				
			}	
			
			
	
			
   function show_shopped_items(id,language){	
	  			//alert(id+"   "+language);
				var path= sitepath+'/include/shoppingCart/shopped_items.php?id='+id+'&lang='+language;
				loadXMLDoc2(path);
	
				
			}		
			
			
			
			
	function delete_item(id){
				var path= sitepath+'/cos_produse.php?demodificat=';
				path= path + id +'&cantitate=0';
				loadXMLDoc(path);
			}
			
			
			
			
	function doCos_av(id){	
				var path= sitepath+'/cos_produse_detaliat.php?demodificat=';
				path= path + id +'&cantitate=';
				path = path + getObject('cantitate_' + id).value;
				if (getObject('cantitate_' + id).value!='')
				loadXMLDoc(path);
			}
			
			
			
	function deleteFromCos_av(id){
				var path= sitepath+'/cos_produse_detaliat.php?demodificat=';
				path= path + id +'&cantitate=0';
				loadXMLDoc(path);
			}
			
			///////////////////////////////// END AJAX FUNCTIONS ////////////////////////////////////////////
				
			
			
	function update_pret(value,pret, i)
{

		//alert(i);
		//alert(document.getElementById('productQuantity_sent_'+i));
		var pretul=0;
		if(value==0)
		{
			value=1;
			pretul=pret;
			document.getElementById('productPrice_'+i).value=pretul.toFixed(3);
			document.getElementById('productQuantity_'+i).value=1;
		}
		else
		{
				if(value*0==0)
				{
						pretul=pret*value;
						document.getElementById('productPrice_'+i).value=pretul.toFixed(3);
						document.getElementById('productQuantity_sent_'+i).value=value;					
					}
         		else 
         		{
         		value=1;
				pretul=pret;
				document.getElementById('productPrice_'+i).value=pretul.toFixed(3);
				document.getElementById('productQuantity_'+i).value=1;
         		}		 
        
		
		}
		
		document.getElementById('productQuantity_sent_'+i).value=document.getElementById('productQuantity_'+i).value;
		
		
		
		
		
}		


function update_quantity(i)
{
		//alert(i);
		var j=0;
		for(j=0;j<i;j++)
		{
		
		document.getElementById('productQuantity_sent_'+j).value=document.getElementById('productQuantity_'+j).value;
		
		}

}


function check_keywords()
{
	var words='';
	var l=0;
	words=document.getElementById('cuvinte').value;
	l=words.length;
	while((words.indexOf(" ")==0)&&l)
	{
		
	words=words.substr(1);
	l=words.length;
	}
	if((words=='')||(words==' ')) return 0;
	else 
	{
		
		
		return 1;
	}
	
	

}








//************************ functii ajax pentru pagina de categorie *********************/



			

	function getObject3(name) {
							

   				var ns4 = (document.layers) ? true : false;
   				var w3c = (document.getElementById) ? true : false;
   				var ie4 = (document.all) ? true : false;

   				if (ns4) return eval('document.' + name);
   				if (w3c) return document.getElementById(name);
   				if (ie4) return eval('document.all.' + name);
   				if(!(ns4||w3c||ie4)) return false;
			}
















	
//************************************** FILTRE ************************************//


function make_filter(obj){

	var url;

	//show_loading();

	if(obj)
				url = sitepath+"rezultat-filtre/?category="+$('url_categorie').value+"&subcategory="+$('url_subcategorie').value+"&filter="+obj.name+"&value="+obj.value+"&add="+obj.checked;
	else
			url = sitepath+"rezultat-filtre/?category="+$('url_categorie').value+"&subcategory="+$('url_subcategorie').value;
	//alert(url);

	new Ajax.Request(url, {
 	 	method: 'get',
  		onSuccess: function(transport) {
 
   //alert (transport.responseText);
      getObject3("product_holder").innerHTML =transport.responseText;
    
  }
});
		
		
	

}


function sterge_filtru(filter)
{

	var url;

	//show_loading();


	url = sitepath+"rezultat-filtre/?category="+$('url_categorie').value+"&subcategory="+$('url_subcategorie').value+"&filter="+filter+"&delete=true";

	var i=0;

	elements = document.getElementsByTagName('input');

	for(i=0;i<elements.length;i++){
		if(elements[i].type=="checkbox" && elements[i].parentNode.parentNode.parentNode.id == "filter_expand_"+filter){
			elements[i].checked=0;
		}
	}

	new Ajax.Request(url, {
 	 		method: 'get',
  			onSuccess: function(transport) {
			//alert (transport.responseText);
      		getObject3("product_holder").innerHTML =transport.responseText;
    
  }
});

	

}




function show_loading(){


	if($('product_holder')){
		$('products_loading').style.height=$('product_holder').offsetHeight + 'px';
		//$('products_loading').style.top=$('product_holder').offsetTop + 'px';
		//$('products_loading').style.left=$('product_holder').offsetLeft + 'px';
	}
	$('products_loading').style.display='block';
}

function hide_loading(){
	$('products_loading').style.display='none';
}










/**********************************************************************************************/