
loadContentComplete = function( req, target, dim ) {
	
	new Effect.Opacity('content-'+target, {from:1, to:0, queue:'end', afterFinish: function() { 																							
		new	Effect.BlindUp('content-'+target, {from:0, to:1, queue:'end', afterFinish: function() {

		$('content-'+target).innerHTML = req.responseText;
		
		Effect.BlindDown('content-'+target, {from:0, to:1, queue:'end'} );
		Effect.Appear('content-'+target, {from:0, to:1, queue:'end'} );		
																							  
		} } );
		
	} } );
	
	new Effect.Fade('loading-'+target, {duration:1, queue:'end'});
}

content = function ( file, q, method, label, target ) {
	new Effect.Appear('loading-'+target, {duration:1, queue:'end'});
	var url = file+".php?"+q;
	var dim = $('content-'+target).getDimensions();
	var ajaxContentRequest = new Ajax.Request(url,
	{
		 method: 'get',
		 onComplete : function(req) {loadContentComplete( req, target, dim );}
	
	});
	
}

updateWeather = function (xml, target) {

	element = xml.getElementsByTagName('channel')[0];
	// childNodes[13] = location
	city = element.childNodes[13].attributes[0].nodeValue;
	country = element.childNodes[13].attributes[2].nodeValue;
	element = xml.getElementsByTagName('item')[0];
	// childNodes[11] = <yweather:condition>
	conditionName = element.childNodes[11].attributes[0].nodeValue; 
	imageCode = element.childNodes[11].attributes[1].nodeValue;
	temperature = element.childNodes[11].attributes[2].nodeValue; 
	date = element.childNodes[11].attributes[3].nodeValue; 

	var isi = '<div style="width:140px; margin-right:20px;" id="content-weather-image"><img src="images/weather/'+imageCode+'.png" alt="'+conditionName+'"></div><div><h3 style="padding:0px; margin:0px;" id="content-weather-location">'+city+", "+country+'</h3><h1 style="padding:10px 0px;" id="content-weather-temperature">'+temperature+"&deg;C"+'</h1><p style="display:inline;" id="content-weather-condition">'+conditionName+"<br />"+date+'</p><div>';
	
	new Effect.Opacity(target, {from:1, to:0, afterFinish: function() {															
		$(target).innerHTML = isi;
		new Effect.Appear($(target));
	}});

}

getWeather = function ( target ) {
	var url = "http://capung.info/class/weather.php";
	var ajaxWeatherRequest = new Ajax.Request(url,
	{
		 method: 'get',
		 onComplete : function( req ) { 
			xml = req.responseXML; 		//alert('req.responseXML');
			text = req.responseText; 	//alert(req.responseText);
			updateWeather(xml, target);
		 } 
	});
}


loadTagboard = function (h) {
	var file = "pages/tagboard";
	var target = 'tagboard';
	var label = 'Tagboard Data';	
	var method = 'get';	

	if(h <= maxpage && h >= 1) {
		offset = (h-1)*2; //alert('off:'+offset+'|p:'+p);
		q = "offset="+offset+"&row=2";
		content( file, q, method, label, target );
		return h;
	} else
		return p;	

}


kirimTag = function() {
	//alert($F('nama').blank());

	if($F('nama').blank() || $F('pesan').blank() || $F('url').blank() ) {
		alert('All fields MUST NOT be BLANK!');
	} else {
		var param = $('tagboardform').serialize();
		$('tagboardform').disable();
		var url = 'wp-content/plugins/axp.works-tag/tag.ajax.php';
		var ajaxContentRequest = new Ajax.Request(url,
		{
			 method: 'post', 
			 parameters: param,
			 onComplete : function(req) 
			 {
				if(req.responseText != '1') {
					alert(req.responseText);
				} else {
					loadTagboard(1);
				}
				$('tagboardform').enable();
			 }
		
		});			
	}

	return false;
}

