function loadcal(month, year)
{
	$('#cal').empty();
	$.get('index.php?id=771&month=' + month + '&year=' + year, function(data) {
		$('#cal').html(data);
	});
}

function openwin(url,name , width, height, scrollbars) 
{

    var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=0,scrollbars=' + scrollbars +',menubar=0,status=0' );
}

function openbranch( id )
{	
		newId = "folder" + id + "data";
		imgId = "folder" + id + "picon";
		foldId = "folder" + id + "ficon";

		showIt = document.getElementById(newId);

		if (showIt.style.display == "none")
		{
			showIt.style.display = "";
			document.getElementById(imgId).src = "/images/admin/minus.gif";
			document.getElementById(foldId).src = "/images/admin/publisher/fopen.gif";

		} else {
			showIt.style.display = "none" ;
			document.getElementById(imgId).src = "/images/admin/plus.gif";
			document.getElementById(foldId).src = "/images/admin/publisher/fclose.gif";

		}

}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function loadcats_cb(status, data, args) {

	if( status == "+" )
	{
		document.getElementById( "year_div" ).innerHTML = data;
	

	}else{
			alert("Îøèáêà");

	}
}
function loadcats( )
{
	point = document.getElementById( "year_id" ).value;

	if( point != "" && point != 0 )
	{
		myajax_do_call("loadcats", loadcats.arguments, "GET", "/index.php?module=cat&action=getcats&id=" + point );
	}
}

function makesearch_cb(status, data, args) {

	if( status == "+" )
	{
		document.getElementById( "results_div" ).innerHTML = data;
	

	}else{
			alert("Îøèáêà");

	}
}
function makesearch( )
{
	if( document.getElementById( "year_id" ) )
		year_id = document.getElementById( "year_id" ).value;

	if( document.getElementById( "model_id" ) )
		model_id = document.getElementById( "model_id" ).value;

	if( document.getElementById( "cat_id" ) )
		cat_id = document.getElementById( "cat_id" ).value;

	if( point != "" && point != 0 )
	{
		myajax_do_call("makesearch", makesearch.arguments, "GET", "/index.php?module=cat&action=searchspare&year=" + year_id + "&model=" + model_id + "&cat=" + cat_id  );
	}
}

function putbasket_cb(status, data, args) {
	if( status == "+" )
	{
		if( opener )
		{			
			opener.document.getElementById( 'all_cost' ).innerHTML= data + " ðóá.";	
		}else{
			document.getElementById( 'all_cost' ).innerHTML= data + " ðóá.";	
		}
			

	}else{
			alert("Îøèáêà");

	}
}
function putbasket( art, parentart )
{

	if( art != "" )
	{
		num = document.getElementById( "order" + art + "_ammount" ).value;
		if( num == "" ) num = 0;
		
		if( num != 0 )
		{				
			document.getElementById( 'addlink' + art ).className= "trail_on";
			document.getElementById( "order" + art + "_ammount" ).value = "";
		}else{
			document.getElementById( 'addlink' + art ).className= "trail_off";
		}

			myajax_do_call("putbasket", putbasket.arguments, "GET", "/shop/index.php?module=basket&action=add&art=" + art + "&num=" + num + "&parentart=" + parentart );

	}	
}

function makeprate_cb(status, data, args) {

	if( status == "+" )
	{
		makestars( data, c_art );
	}else{
			alert("Îøèáêà");

	}
}
function makeprate( art, rate )
{
if( art != "" && rate != "" )
{
	c_art = art;
	myajax_do_call("makeprate", makeprate.arguments, "GET", "/shop/index.php?module=register&action=makeprate&art=" + art + "&rate=" + rate );

}	
}

function makestars( rate, art )
{

	i = 1;
	
while( i <= 5 )
	{
		if( i <= rate )
		{
			document.getElementById( 'star' + i + "_" + art ).className="";
		}else{
			document.getElementById( 'star' + i + "_" + art ).className="gray";
		}
	i++;
	}

}

function show_adv( )
{	
	if (document.getElementById('selects_div').style.display != 'none')
	{
		document.getElementById('selects_div').style.display = 'none';
		document.getElementById('actions_div').style.display = 'block';
		
	}
	else
	{ 	
		document.getElementById('selects_div').style.display = 'block';
		document.getElementById('actions_div').style.display = 'none';
	}
}
