function obj(id) {
	object = null;
	if (document.getElementById) {
	    object = document.getElementById(id);
	}else if (document.all) {
		object = document.all[id];
	}
	return object;
}


function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}



function sover(name, what){
	
	if(what=='bottom'){
		obj("font_"+name).className = 'font_orange';
		obj("img_"+name).src = './_tpl/images/dot_circle_light_selected.gif';
	}else{
		if(obj(name)){
			obj(name).className = 'bg_menu_light_sel';
	    }
	}
	
}



function sout(name, what){

	if(what=='bottom'){
		obj("font_"+name).className = 'font_menu_main';
		obj("img_"+name).src = './_tpl/images/dot_circle_light.gif';
	}else{
		if(obj(name)){
			obj(name).className = 'bg_menu_light';
	    }
	}
	
}


function button_over(name){
	if(obj(name)){
		obj(name).className = 'button_over';
	}
}



function button_out(name){
	if(obj(name)){
		obj(name).className = 'button';
	}
}

function kosik(name, way){
	if(obj(name) && way=='over'){
		obj(name).src = './_tpl/images/kosik_over.jpg';
		obj(name+'_td').className = 'font_darkgray';
	}else if(obj(name) && way=='out'){
		obj(name).src = './_tpl/images/kosik.jpg';
		obj(name+'_td').className = 'font_orange';
	}
}



function pic_change(name, pic){
	
	if(obj(name))
		obj(name).src = './_tpl/images/'+pic;
	
}

function sub(name){
	//$name='_'+name;

	if(obj('_'+name)){
		
		if(obj('_'+name).style.display == ''){
			obj('_'+name).style.display = 'none';
		}else{
			obj('_'+name).style.display = '';
		}
	}
}


//function prod_info(name, way){
//	
//	if(obj("1_"+name)){
//		myclass=obj("1_"+name).className;
//	}
//	
//	if(obj("2_"+name)){
//		myclass=obj("2_"+name).className;
//	}
//	
//	for(i=2; i<3; i++){
//		if(obj(i+"_"+name) && way=='in'){
//			if(myclass=='row_first')
//				obj(i+"_"+name).className = 'prod_orange_fr';
//			else if(myclass=='row_odd')
//				obj(i+"_"+name).className = 'prod_orange_odd';
//			else if(myclass=='row_even')
//				obj(i+"_"+name).className = 'prod_orange_even';
//				
//		}else if(obj(i+"_"+name) && way=='out'){
//			if(myclass=='prod_orange_fr')
//				obj(i+"_"+name).className = 'row_first';
//			else if(myclass=='prod_orange_odd')
//				obj(i+"_"+name).className = 'row_odd';
//			else if(myclass=='prod_orange_even')
//				obj(i+"_"+name).className = 'row_even';
//		}
//	}
//}
//
function show_div(dname){
	
	//alert(menu_id);
	name=dname;
		
	if(obj(name).style.display == "none"){
		obj(name).style.display = "";
		
	}else
		obj(name).style.display="none";
		
		
}

function getHTTPObject() 
  {
  	var xmlhttp;
  	/*@cc_on
  	@if (@_jscript_version >= 5)
  		try {
  		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  		} catch (e) {
  		try {
  			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  		} catch (E) {
  			xmlhttp = false;
  		}
  		}
  	@else
  	xmlhttp = false;
  	@end @*/
  	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  		try {
  		xmlhttp = new XMLHttpRequest();
  		} catch (e) {
  		xmlhttp = false;
  		}
  	}
  	return xmlhttp;
  }

//SEARCH CARTRIGE
  var http;
  
  function httpChange_search()
 	{
 	  //alert(http.responseText);
    if (http.readyState==4)
    {
      
      if (http.status==200)
      {
        window.document.getElementById("search_cartrige").innerHTML = http.responseText;
      }
      else
      {
        window.status = "Problem with http search";
      }
    }
  }
  
  function search_cartrige(id)
  {
    http=getHTTPObject(); 
	http.onreadystatechange=httpChange_search;
	
	
	http.open("GET", 'search_cartrige.php?id='+id, true);
    
  	
  	
    try
    {
  	 http.send(null);	
  	}
  	catch(e)
  	{
  	 window.status = e;
    }
  }

//CART
  function httpChange_cart()
 	{
 	  //alert(http.status);
    if (http.readyState==4)
    {
      
      if (http.status==200)
      {
        window.document.getElementById("cart_count").innerHTML = http.responseText;
        colorFade('cart_header','background','999999','ffffff',40);
      }
      else
      {
        window.status = "Problem with http search";
      }
    }
  }
  
  function put_to_cart(url)
  {
    http=getHTTPObject(); 
	http.onreadystatechange=httpChange_cart;
	
	http.open("GET", 'cart.php?'+url, true);
    
  	
  	
    try
    {
  	 http.send(null);	
  	}
  	catch(e)
  	{
  	 window.status = e;
    }
  }
  
//ORDER
  var id_row;
  function httpChange_order()
 	{
    if (http.readyState==4)
    {
      
      if (http.status==200)
      {
        //alert(http.responseText);
        html=http.responseText.split("#@#");
        if (html[0]!='ship') window.document.getElementById(id_row).innerHTML = html[0];
        //Sumarna cast
        sum=html[1].split("::");
        for(i=0; i<sum.length; i++){
          value=sum[i].split("%");
          window.document.getElementById(value[0]).innerHTML = value[1]; 
        }
      }
      else
      {
        window.status = "Problem with http search";
      }
    }
  }
  
  function update_order(url,id)
  {
    id_row=id;
    http=getHTTPObject();
     
	http.onreadystatechange=httpChange_order;
	
	http.open("GET", 'cart.php?'+url, true);
    
  	
  	
    try
    {
  	 http.send(null);	
  	}
  	catch(e)
  	{
  	 window.status = e;
    }
  }
  
  function httpChange_del_order_item()
 	{
    if (http.readyState==4)
    {
      
      if (http.status==200)
      {
        //alert(http.responseText);
        html=http.responseText.split("#@#");
        if (html[0]=='0') 
        {
          window.document.getElementById('order_header').innerHTML = html[1];
          window.document.getElementById("cart_count").innerHTML = html[0];
          colorFade('cart_header','background','999999','ffffff',40);
        }
        else 
        {
          window.document.getElementById(id_row).style.display='none';
          window.document.getElementById(id_row).outerHTML='';
          window.document.getElementById("cart_count").innerHTML = html[0];
          
          //Sumarna cast
          sum=html[1].split("::");
          for(i=0; i<sum.length; i++){
            value=sum[i].split("%");
            window.document.getElementById(value[0]).innerHTML = value[1]; 
          }
        
          colorFade('cart_header','background','999999','ffffff',40);
        }
      }
      else
      {
        window.status = "Problem with http search";
      }
    }
  }
  
  function del_order(url,id)
  {
    id_row=id;
    http=getHTTPObject();
     
	http.onreadystatechange=httpChange_del_order_item;
	
	http.open("GET", 'cart.php?'+url, true);
    
  	
  	
    try
    {
  	 http.send(null);	
  	}
  	catch(e)
  	{
  	 window.status = e;
    }
  }

function show_price_r(id,object)
{
  object.style.display='none';
  document.getElementById(id).style.display='inline';
}

