
function set_calendar( y , m , direction ) {
	if( direction == 0 ) {/*prev*/
		m--;
		if( m == 0 ) {
			m = 12 ;
			y--;
		}
	}
	else {
		m++;
		if( m == 13 ) {
			m = 1 ;
			y++;
		}
	}

	var loc = www_main + 'action.php?action=calendar&y=' + y + '&m=' + m ;

	get_data('calendar' , loc);

}

function top_hover( target , status , base ) {
	
	obj = document.getElementById(target);
	img = base ;
	if(status == 0) img += '_n.png';
	if(status == 1) img += '_h.png';
	//alert(img);
	obj.style.background = 'url(' + img + ')';
	obj.style.backgroundRepeat = 'repeat-x';
}

function show_hide( container , state )  {

	var divCustomerInfo = document.getElementById( container );

	if(divCustomerInfo.style.display=='block')
		divCustomerInfo.style.display='none';
	else
		divCustomerInfo.style.display='block';

	//alert(container + ':'+ divCustomerInfo.style.display);
}

function displayContainer(sContainer , sText){
	var divCustomerInfo = document.getElementById(sContainer);
	divCustomerInfo.style.visibility='visible';
	if(sText.indexOf("<RAW>")>=0)
	{
		sText = sText.substring(0 , sText.indexOf("<!DOCTYPE"));
		sText=str_replace("<RAW>" , "" , sText);
		divCustomerInfo.innerHTML = sText;
	}
	else	
	{
		if(sText.indexOf("<!DOCTYPE")>0)
			divCustomerInfo.innerHTML = sText.substring(0,sText.indexOf("<!DOCTYPE")); //sText;
		else
		{
			//alert(sText);
			divCustomerInfo.innerHTML = sText;
		}
	}
}

function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
}	

function currentTimeStamp(){
	var d = new Date();
	s = d.getUTCDate() + "_" + d.getUTCMonth() + "_" + d.getUTCFullYear() + "_" + d.getUTCHours() + "_" + d.getUTCMinutes() + "_" + d.getUTCSeconds() + "_" + d.getUTCMilliseconds();
	return s;	
}
		
function getData(Dest , sUrl ){	
	var sLoc;
	var b;
	var oXmlHttp = zXmlHttp.createRequest();
	
	//alert(Dest + ":" + sUrl );

	if(sUrl.indexOf(".html")>=0)
		sLoc  = sUrl;
	else
	{
		if(sUrl.indexOf("?")>=0)
			sLoc  = sUrl + "&TimeStamp=" + currentTimeStamp() ;
		else
			sLoc  = sUrl + "?TimeStamp=" + currentTimeStamp() ;
	}
	displayContainer( Dest , "<img border=0 src=" + www_main + "images/loading.gif>");		
	
	
	oXmlHttp.open("get", sLoc, true);
	//alert('step2:'+sLoc);
	oXmlHttp.onreadystatechange = function () 
	{
		if (oXmlHttp.readyState == 4) 
		{
			if (oXmlHttp.status == 200) 
			{

				if(oXmlHttp.responseText.indexOf('<!--err-->') >=0)
				{
					
					//err handling

				}
				else
				{
						displayContainer( Dest , oXmlHttp.responseText);
				}
			} 
			else 
			{
				displayContainer( Dest , "An error occurred: " + oXmlHttp.statusText); 
			}
		}            
	};
	oXmlHttp.send(null);
}

function get_data(Dest , sUrl ) { getData( Dest , sUrl ) ;}

function do_rating( uid			,
					rating_type	,
					value) {
	
	var loc = www_main + 'action.php?action=rate&uid=' + uid + 
						'&rating_type=' + rating_type + 
						'&value=' + value;

	get_data( 'rating_block_' + rating_type , loc  );
}

function do_rating_select(	is_selected ,
							idx			,
							rating_type	,
							clr_current	) {
	var obj = document.getElementById('br_' + rating_type + '_' + idx );

	if( is_selected )
		obj.style.border='1px solid #000000';
	else 
		obj.style.border='1px solid #cecece';
}
