// Code to Update Grid After
var http = createRequestObject();
var objectId = "small_basket";

function run_js()
{
  var the_div = document.getElementById(objectId);
  if(null!=the_div)
  {
    with(the_div)
    {
      var arr_scripts = the_div.getElementsByTagName("script");
      for(i in arr_scripts)
      {
        var src = arr_scripts[i].src;
        if(null!=src)
        {
          var has_question = (src.indexOf('?', 1)>0 ? true : false );
          if(0==src.length)
            arr_scripts[i].setAttribute('src', '');
          else
            arr_scripts[i].setAttribute('src',
arr_scripts[i].src + (has_question==true ? '&' : '?') + '1=1');
        }
      }
    }
  }
}

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        ro = new XMLHttpRequest();
    }
    return ro;    
}

function sendReq(serverFileName, variableNames, variableValues) {
	//document.getElementById("loading").style.display = "inline";
	var paramString = '';
	
	variableNames = variableNames.split(',');
	variableValues = variableValues.split(',');
	
	for(i=0; i<variableNames.length; i++) {
		paramString += variableNames[i]+'='+variableValues[i]+'&';
	}
	paramString = paramString.substring(0, (paramString.length-1));
			
	if (paramString.length == 0) {
	   	http.open('get', serverFileName+'?i='+Math.random());
	}
	else {
		http.open('get', serverFileName+'?i='+Math.random()+'&'+paramString);
	}
	http.setRequestHeader('content-type', 'text/html');
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
	
	if(http.readyState == 4){
		responseText = http.responseText;
		document.getElementById(objectId).innerHTML = responseText;
		run_js();
		//document.getElementById("loading").style.display = "none";
    }
}








function ShowHide(menuid)
{
	objmenu = document.getElementById('menu'+menuid);
	objsubmenu = document.getElementById('submenu'+menuid);
	if (objsubmenu.style.display == 'none')
	{
		objsubmenu.style.display = 'inline';
		objmenu.className = 'menu_open';
	}
	else
	{
		objsubmenu.style.display = 'none';
		objmenu.className = 'menu_close';
	}
}
function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return 0
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function format_number(str_number, count_simbols)
{
	if (count_simbols==undefined) count_simbols=2;
	var astrnumber = (str_number+"").split(".");
	if (astrnumber.length==1) return str_number+".00";
	
	if (astrnumber[1].length==1) return astrnumber[0]+"."+astrnumber[1]+"0";
	if (astrnumber[1].length==2) return str_number;
	if (astrnumber[1].length>2) return astrnumber[0]+"."+astrnumber[1].substr(0,count_simbols);
	
}

function setCookie(cname, cval)
{
  date = new Date();
  date = new Date(date.valueOf() + 1000 * 60 * 60 * 24 * 7);
  document.cookie = cname+"="+cval+";path=/; expires=" + date.toGMTString();
}
function setDivHeight()
{
//	 width=document.documentElement?document.documentElement.clientWidth:(window.innerWidth?window.innerWidth:800)
//document.documentElement?document.documentElement.clientHeight:(window.innerHeight?window.innerHeight:600);
	height=document.body.clientHeight;
	document.getElementById("polosa").style.height=parseInt(height-698)+"px";
//	document.getElementById("basket_total_count").innerHTML = getCookie("total_count");
//	document.getElementById("basket_total_price").innerHTML = format_number(getCookie("total_price"));
}
