function popup_window( id, width, height ) {
	if (!width) width = 900;
	if (!height) height = 800;
	wnd = window.open( "/prod_popup.php?id=" + id, "_blank", "width="+width+",height="+height+",status=1,toolbar=0,resizable=1,scrollbars=1,menubar=1");
	wnd.focus();
}

function open_poll( one )
{
	act = document.pollform.act.value;
	poll_id = document.pollform.poll_id.value;
	
	if( one == "1" ) { // radio
		q = "&q=" + get_radio_value( document.pollform.q );
	}
	
	if( one == "0" ) { // checkbox
		q = get_checkbox_values( document.pollform ); 
	}
	
	wnd = window.open( "/poll_action.php?act="+act+"&poll_id=" + poll_id + q, "_blank", "width=300,height=150,status=0,toolbar=0,resizable=0,scrollbars=0,menubar=0");
	wnd.focus();
}

function open_claim(){
	name = document.claimform.name.value;
	email = document.claimform.email.value;
	phone = document.claimform.phone.value;
	comment = document.claimform.comment.value;
		
	wnd = window.open( "/claim_action.php?name="+name+"&email=" +email+"&phone=" +phone+"&comment=" +comment, "_blank", "width=300,height=150,status=0,toolbar=0,resizable=0,scrollbars=0,menubar=0");
	wnd.focus();
}

function get_radio_value( obj ) {
	var i=0; var q=0;
    while((i<obj.length)&&(obj[i].checked!=1)) {i++;}
   	if (i!=obj.length) q =obj[i].value;
	return q;
}

function get_checkbox_values( obj )
{
 	var ret="";

	for( i = 0; i < obj.elements.length; i++ )
	{
		var item=obj.elements[i];
		if( item.checked==true && item.value > 0 ) ret = ret + "&q[]=" + item.value;
	}
	return ret;
}

function open_compare(product_id) {
	wnd = window.open( '/compare.php?action=add&id=' + product_id,  '_compare' ); 
	wnd.focus();
}

var imgname = "";
var description = "";

function start_window(img, desc, width, height){

	nw = window.open("./popup_map.html", "_blank", "width="+width+",height="+height+",status=no,toolbar=no,menubar=no");
    imgname=img;
    description=desc;
}

//показ в правой колонке списка точек, где товар есть
function show_exist(city_id)
{
	s = document.getElementById('exist'+city_id).style;
	d = document.getElementById('n_exist'+city_id).style;

	if (s.display == 'none')
	{
		s.display = 'block';
		d.display = 'none';
	}
	else 
	{
		s.display = 'none';
		d.display = 'block';
	}
}

function close_all()
{
	s = document.getElementById('tenderf').style;
	s.display = 'none';
	s2 = document.getElementById('errorf').style;
	s2.display = 'none';
}

function show_div( id )
{
	close_all();

	s = document.getElementById(id).style;

	if (s.display == 'block')
	{
		s.display = 'none';
	}
	else 
	{
		s.display = 'block';
		document.location.replace( "#"+id );
		//scrollTo(id);
	}
}

function show_div2( id )
{
	s = document.getElementById(id).style;
	s.display = 'block';
}

function hide_div2( id )
{
	s = document.getElementById(id).style;
	s.display = 'none';
}

//было в html_page.inc
var src_st;
function header_over(c)
{
	src_st = c.style["backgroundColor"];
	c.style["backgroundColor"] = "#FF9900";
	c.style['cursor'] = 'pointer';
}

function header_out(c)
{
	c.style['cursor'] = 'inherit';
    if (src_st != null) c.style["backgroundColor"] = src_st;
}

function absPosition(obj) {
      var x = y = 0;
      do {
            x += obj.offsetLeft;
            y += obj.offsetTop;
			//alert(obj.offsetTop);
            obj = obj.offsetParent;
      } while(obj);
	  
      return {x:x, y:y};
} 

function setWindowPosition(d, x, y)
{
	d.left = (x - 170) + 'px';
	d.top = (y + 0) + 'px';
	
	d.visibility = "visible";
	//d.display = "block";
}

function setWindowPosition2(d, x, y)
{
	d.left = (x) + 'px';
	d.top = (y) + 'px';
}

function close_barand()
{
	var d = document.getElementById('BrandInfoDiv').style;
	d.visibility = "hidden";
}

function show_brand_info()
{
	var d = document.getElementById('BrandInfoDiv').style;
	var c = document.getElementById('brandname');
	var pos = absPosition(c);
		
	setWindowPosition( d, pos.x, pos.y );
}

function print_obj( o )
{
	for (i in o)
	{
		var s = '';
		s += i;
		s += '<br />';
		document.write(s);
	}
}