//AJAX FRAMEWORK

window.addEvent('domready', function() {
    var clips = $$('a.player_flv_class');
    //add the events to the list of ancohrs
    for(var j=0; j<clips.length; j++)
	{
		clips[j].onclick = function() 
		{    	    
			var url_changed = this.getAttribute("name",2);
			var url_changed_arr = url_changed.split('__:__');
				url_changed = url_changed_arr.join('/'); 
			
			// play the clip specified in href- attribute with Flowplayer        
			$f().play(url_changed); 
			// by returning false normal link behaviour is skipped 
			//add the effect for scaling the player if it is a radio
			if(this.getAttribute("name",2).indexOf(".mp3") > 0)
			{//if it's a sound rescale de videoplayer
				var otherEl = $('player_container');
				otherEl.tween('height', 75);
					
			}
			else
			{//if its a video restore the correct size of player
				var otherEl = $('player_container');
				otherEl.tween('height', 250);
			}
			//****************************************************
			//*****  ADD THE TITLE AND CONTENT DOWN THE PLAYER
			//get the id of the element
			var id_content = $get( 'itemContent', this.getAttribute('href') );
			//perform the ajax request
			var ajax_el = $( 'item_content_player' );
			var req = new Request({
             method: 'get',
             url: 'get_content_item.php',
             data: { 'idContent' : id_content },
             onRequest: function() { 
             	ajax_el.set('html', '&nbsp;');
             	ajax_el.setStyle('background-image', 'url(images/ajax-loader.gif)');
             },
             onComplete: function(response) { 
             	ajax_el.setStyle('background-image', 'none');
             	ajax_el.set('html', response);
             	
             }
         }).send();
			//****************************************************
			return false; 
		} 
	
						
						
	}
	
    /*
    var ajax_el = $('ajax');
    var req = new Request({
             method: 'get',
             url: 'http://www.4one.es/webs/saludaldia/testAjax.php',
             data: { 'do' : '1' },
             onRequest: function() { alert('The request has been made, please wait until it has finished.'); },
             onComplete: function(response) { 
             	alert('The response is the following : '+ajax_el); 
             	ajax_el.set('html', response);
             	
             }
         }).send();
	*/
	
});



//ROUND CORNERS
NiftyLoad=function()
				{
					Nifty("div#mainMenu","big transparent top");
					//Nifty("li.menu_7", "big bottom transparent");
					//Nifty("div#infoHome", "top");
					Nifty("div.box", "bottom transparent");
					Nifty("div.roundBottom", "bottom transparent")
					
					
					//Nifty("div.schedulingItem,div.itemContent","big transparent tl");
					//get all clips divs
					
					
					/*
					var clips = document.getElementsByTagName("a");
					
					for(var j=0; j<clips.length; j++)
					{
						if(clips[j].getAttribute("href")=='#player_flv')
						{//in the case that the a anchor is linked to #visore
						 	
							clips[j].onclick = function() 
							{    	    
								// play the clip specified in href- attribute with Flowplayer        
								$f().play(this.getAttribute("name",2)); 
								// by returning false normal link behaviour is skipped 
								//add the effect for scaling the player if it is a radio
								if(this.getAttribute("name",2).indexOf(".mp3") > 0)
								{//if it's a sound rescale de videoplayer
									var otherEl = $('player_container');
									otherEl.tween('height', 75);
									
								}
								else
								{//if its a video restore the correct size of player
									var otherEl = $('player_container');
									otherEl.tween('height', 240);
								}
								return false; 
							} 
						}
						
						
					}
					*/
					
					
					
					
					
				}
				
function $get(key,url){
	if(arguments.length < 2) url =location.href;
	if(arguments.length > 0 && key != ""){
		if(key == "#"){
			var regex = new RegExp("[#]([^$]*)");
		} else if(key == "?"){
			var regex = new RegExp("[?]([^#$]*)");
		} else {
			var regex = new RegExp("[?&]"+key+"=([^&#]*)");
		}
		var results = regex.exec(url);
		return (results == null )? "" : results[1];
	} else {
		url = url.split("?");
		var results = {};
			if(url.length > 1){
				url = url[1].split("#");
				if(url.length > 1) results["hash"] = url[1];
				url[0].split("&").each(function(item,index){
					item = item.split("=");
					results[item[0]] = item[1];
				});
			}
		return results;
	}
}
