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();
}

var partners = new Array
(
	"http://www.7pd.ru",
	"http://www.enkatsu.ru",
	"http://www.ju-jutsu.ru",
	"http://www.mobiledart.ru",
	"http://www.kenkorussia.ru",
	"http://www.easycopy.ru",
	"http://www.greenquark.ru",
	"http://www.sandisk.ru",
	"http://www.sigmalens.ru",
	"http://www.slikrussia.ru",
	"http://www.tamracrussia.ru",
	"http://www.dvestnik.ru"
);

var clubs = new Array
(
	"http://club.foto.ru/info/articles/",
	"http://club.foto.ru/info/articles/",
	"http://club.foto.ru/school/",
	"http://club.foto.ru/guide/",
	"http://club.foto.ru/forum/",
	"http://club.foto.ru/camera/",
	"http://club.foto.ru/lab/",
	"http://club.foto.ru/studios/",
	"http://club.foto.ru/secondhand/"
);

var forums = new Array
(
	"http://club.foto.ru/forum/view_forum.php?f_id=11",
	"http://club.foto.ru/forum/view_forum.php?f_id=6",
	"http://club.foto.ru/forum/view_forum.php?f_id=5",
	"http://club.foto.ru/forum/view_forum.php?f_id=4",
	"http://club.foto.ru/forum/view_forum.php?f_id=3",
	"http://club.foto.ru/forum/view_forum.php?f_id=9",
	"http://club.foto.ru/forum/view_forum.php?f_id=10",
	"http://club.foto.ru/forum/view_forum.php?f_id=2"
)

function go_partner( id ) { window.location = partners[id]; }
function go_club( id ) { window.location = clubs[id]; }
function go_forum( id )	{ window.location = forums[id]; }
function go_mforum() { window.location = "http://club.foto.ru/forum/"; }

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;
}

//home page stuff
if( document.images ) { version = "n3"; } else { version = "x"; }

if( version == "n3" ) {
	p1on = new Image(92,92);
	p1on.src = "/images/cat_red.gif";
	p1off = new Image(92,92);
	p1off.src = "/images/cat_blue.gif";
}

function img_act(obj) {
	if( version == "n3" ) {
		obj.style.backgroundImage = eval("'url("+p1on.src+")'");
		obj.style.cursor = 'hand';
		obj.style.backgroundRepeat = "no-repeat"; 
	}
}

function img_inact(obj) {
	if( version == "n3" ) {
		obj.style.backgroundImage = eval("'url("+p1off.src+")'");
		obj.style.backgroundRepeat = "no-repeat"; 
	}
}


//Ї®Є § ў Їа ў®© Є®«®­ЄҐ бЇЁбЄ  в®зҐЄ, Ј¤Ґ в®ў а Ґбвм
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 checkTender() {
	var error = '';
	var obj = document.tenderform;
	if ( obj.ufirm.value == '' ) error += __warning_empty( 'Наименование фирмы(сайта)' );
	if ( obj.ucost.value == '' ) error += __warning_empty( 'Цена' );
	if ( obj.uname.value == '' ) error += __warning_empty( 'Ваше имя' );
	if ( obj.ucontact.value == '' ) error += __warning_empty( 'Контактная информация' );
	return __check( error, obj );
}

function checkCall() {
	var error = '';
	var obj = document.callform;
	if ( obj.uname.value == '' ) error += __warning_empty( 'Ваше имя' );
	if ( obj.ucontact.value == '' ) error += __warning_empty( 'Телефон' );
	return __check( error, obj );
}

function checkDmoroz()
{
	var error = '';
	var obj = document.dmorozform;
	if ( obj.uname.value == '' ) error += __warning_empty( 'Ваше имя' );
	if ( obj.utel.value == '' ) error += __warning_empty( 'Телефон' );
	if ( obj.uemail.value == '' ) error += __warning_empty( 'Email' );
	return __check( error, obj );
}

function check_email(str) {
	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}

	if (!supported) 
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		
	//var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r1 = new RegExp("(@.*@)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
} 

function __warning_empty( name ) {
	return ' - Поле \'' + name + '\' не может быть пустым!\n';
}

function __warning_len( name, len ) {
	return ' - В поле \'' + name + '\' не может быть больше ' + len + ' символов!\n';
} 

function __check( error, object ) {
	if ( error != '' ) { alert( 'Внимание!\n\n' + error ); return false; } 
	else { return true; }
}
