
//var from_logo = false;
var d = document;

var img = "/images/loading.gif";
var img_width = 32;
var img_height = 32;
var msg = "Обработка данных";
var title = "Обработка";

function hide_email( user, domain, title )
{
	if ( title == '' ) {
		title = user + "&#64;" + domain;
	}

	d.write("<a href=ma"+"il"+"to&#58;" + user + "&#64;" + domain + ">" + title + "</a>");
}

function Show( id )
{
	d.getElementById( id ).style.display='';
}

function Hide( id )
{
	d.getElementById( id ).style.display='none';
}

function Toggle( id )
{
	if ( d.getElementById( id ).style.display == 'none' ) {
		//d.getElementById( id ).style.display='block';
		d.getElementById( id ).style.display='';
		return 1;
	} else {
		d.getElementById( id ).style.display='none';
		return 0;
	}
}

function ShowLoading( id ) {
	d.getElementById( id ).innerHTML = '<img src="' + img + '" width=' + img_width + ' height=' + img_height + ' alt="' + title + '" title="' + title + '" /><div class=fs9>' + msg + '</div>';
}

function ConfirmAction( message ) {
	var result = window.confirm( message );
	return result;
}

function openNewWindow(myURL, my_width, my_height)
{
	myNewWindow=window.open(
							myURL,
							'sample',
							'toolbar=no,bar=no,location=no,status=no,menubar=no,scrollbars=yes ,resizable=no ,width='+my_width+',height='+my_height+',top=10,left=20'
						);
}

function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL, winName, features);
}

function setCurrentDate( elem_id, offset ) {
	var cur_date;
	var prev_month = false;

	if ( today.getDate() == 1 ) {
		prev_month = true;
	}

	if (today.getDate() < 10)
		cur_date = "0" + today.getDate();
	else
		cur_date = today.getDate();

	cur_date = cur_date + "-";

	if ( today.getMonth() < 9 ) {
		cur_date = cur_date + "0" + (today.getMonth()+1);
	} else {
		cur_date = cur_date + (today.getMonth()+1);
	}

	elem_id.value = cur_date + "-" + today.getFullYear();
}

function IncrementField( id ) {
	var res = d.getElementById( id ).value - 0 + 1;
	d.getElementById( id ).value = res;
}

function DecrementField( id, min ) {
	var res = d.getElementById( id ).value - 1;

	if ( res < min ) {
		d.getElementById( id ).value = min;
	} else {
		d.getElementById( id ).value = res;
	}
}

function PrintOrderForm( id, button ) {
	//xajax_FillOrderItem( id );

	var res = '<div id=order_form align=center>'
				+ '<input type=hidden id=item_id value='+ id +' />'
				+ '<div class=pt5>'
				+ d.getElementById( 'item_name_' + id ).innerHTML
				+ '	&nbsp;'
				+ '	<input type=text id=item_quantity value=1 style=\'width: 25px; text-align: center;\' />'
				+ '</div>'
				+ '<div class=pt5>'
				+ '	<input type=button class=order_btn style="width: 120px;" value=\' '+ button +' \' onclick=\'xajax_AddOrderItem( d.getElementById( "item_id" ).value, d.getElementById( "item_quantity" ).value ); $.add2cart( "cat_'+ id +'", "order_id"  )\' />'
				+ '</div>'
				+ '</div>';
	return res;
}

function AddOrderItem() {
	xajax_AddOrderItem( d.getElementById( "item_id" ).value, d.getElementById( "item_quantity" ).value );
}

var curr_cat = '';

function ZoomCat( type, id )
{
	if ( type == '+' ) {
		if ( curr_cat != '' && curr_cat != id ) {
			ZoomCat( '-', curr_cat );
		}

		curr_cat = id;
		Show( id + '_description' );
		Hide( id + '_small' );
		Show( id + '_big' );
	} else {
		Hide( id + '_description' );
		Hide( id + '_big' );
		Show( id + '_small' );
		curr_cat = '';
	}
}

function Search() {
	if ( d.getElementById( 'keyword' ).value != '' ) {
		xajax_Search( d.getElementById( 'keyword' ).value );

	} else {
		alert( 'Укажите слова для поиска!' );
	}

	return false;
}
//---
