function openImage (uri, wid, hei)
{
    if (wid > 1000) { wid = 1000; };
    if (hei > 750) { hei = 750; };
    var str = "height=" + hei + ",width=" + wid + ",resizable,scrollable,scrollbars";
    window.open(uri,"",str);
};

function saveRating(pid, type, rating)
{
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
   	    req = new XMLHttpRequest();
       	if (req.overrideMimeType) {
            req.overrideMimeType('text/xml');
            // See note below about this line
   	    }
    } else if (window.ActiveXObject) { // IE
        try {
   	        req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
   	            req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
  	};
	req.onreadystatechange = function() { processRating(req); };
	req.open('POST', '/shop/rating/', true);
	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   	req.send('rating=' + rating + '&type=' + type + '&id=' + pid);
}

function processRating(req) {
        if (req.readyState == 4) {
            if (req.status == 200) {
                parseRating(req);
            } 
        } 
}

function parseRating (req)
{
	var data = eval ('('+ req.responseText +')');
	if (data.rating_name)
	{
		var obj = document.getElementById('rating_this_' + data.rating_name);
		obj.innerHTML = '<div class="v_result" style="float:left"><div id="rating_this_' + data.rating_name + '_pct" class="v_tablet" style="width:' + data.rating_pct + 'px;"></div></div><span id="rating_this_' + data.rating_name + '" style="line-height:19px;">' + data.rating_value + ' ةع 10</span><div class="clr"></div>';
	}
	for (var i=0; i < data.ratings.length; i++)
	{
		document.getElementById(data.ratings[i].name + '_pct').style.width = data.ratings[i].width + 'px';
		document.getElementById(data.ratings[i].name).innerHTML = '&nbsp;&nbsp;' + data.ratings[i].value;
	};
}

window.onresize = function() {
  showAnalog();
}

document.body.onresize = function() {
  showAnalog();
}

window.onload = function() {
  showAnalog();
}

document.body.onload = function() {
  showAnalog();
}

function showAnalog (msg)
{
	var t1=document.getElementById("test1");
   	var t2=document.getElementById("test2");
	var width = document.getElementById('test2').offsetParent.offsetLeft;
	if (!msg)
	{
		//msg = 'width_from=' + t1.offsetLeft + '&width_to=' + t2.offsetLeft + '&width='+ document.body.clientWidth +'&ref=' + document.location.href;
		msg = 'width_from=' + t1.offsetLeft + '&width_to=' + width + '&width='+ document.body.clientWidth +'&ref=' + document.location.href;
	};
	
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
   	    req = new XMLHttpRequest();
       	if (req.overrideMimeType) {
            req.overrideMimeType('text/xml');
            // See note below about this line
   	    }
    } else if (window.ActiveXObject) { // IE
        try {
   	        req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
   	            req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
  	};
	req.onreadystatechange = function() { processAnalog(req); };
	req.open('GET', '/includes/dynamic/include_analog.html?' + msg, true);
	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   	req.send(msg);
}

function processAnalog(req) {
        if (req.readyState == 4) {
            if (req.status == 200) {
                document.getElementById('include_analog').innerHTML = req.responseText;
            } 
        } 
}

function getPing()
{
	return 1;
}

function openAdvice(id)
{
    var uri = '/shop/advice/?id=' + id;
    var str = "height=540,width=704,resizable,scrollable,scrollbars";
    window.open(uri,'',str);
};
