	var ajaxObjects = new Array();
	
	function showAjax(teamid,pageid)
	{	ajaxLoader('js/loader_news2.html','latestNews');	
		var ajaxIndex = ajaxObjects.length;
		var ajax;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = 'js/test.php?id='+teamid+'&pid='+pageid;
		ajaxObjects[ajaxIndex].onCompletion = function(){ showData(ajaxIndex,teamid,pageid); }; //function(){ showRSSData(ajaxIndex,numericId); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
	}
	
	function showData(ajaxIndex,teamid,pageid){
		var content=ajaxObjects[ajaxIndex].response;
		if(content==null) showAjax(teamid,pageid);
		document.getElementById('latestNews').innerHTML=content;
		//clearTimeout(timer);
		//setTimeout('showAjax('+teamid+','+pageid+')',5000);
	}		
	function showAjax2()
	{
		ajaxLoader('js/loader_news2.html','gossip');
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = 'js/test.php?id=2';
		ajaxObjects[ajaxIndex].onCompletion = function(){ showData_Gossip(ajaxIndex); }; //function(){ showRSSData(ajaxIndex,numericId); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
	}
	function showData_Gossip(ajaxIndex){
		var content=ajaxObjects[ajaxIndex].response;
		if(content==null) showAjax2();
		document.getElementById('gossip').innerHTML=content;
		//setTimeout('showAjax()',50000);
	}
	
	function showForum() {
		ajaxLoader('js/loader_forum.html','forum_inside');	
		var ajaxIndex = ajaxObjects.length;
		var ajax;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = 'forum/forum.php';
		ajaxObjects[ajaxIndex].onCompletion = function(){ showDataForum(ajaxIndex); }; 
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
	}
	
	function showDataForum(ajaxIndex){
		var content=ajaxObjects[ajaxIndex].response;
		if(content==null) showForum();
		content=parseScript(content);
		if(content.indexOf('shoutbox')>0) {
			$("#forum_inside").css("background","#E4E3E2 url(forum_images/forum_top_2.jpg) no-repeat scroll center top");
		}
		document.getElementById('forum_inside').innerHTML=content;
		//ajaxLoader('','forum_inside');	
		if(content.indexOf('shoutbox')>0) {
			autoscroll();
			setTimeout('showForumUpdate()',12000);
		}
	}
	
	function showForumUpdate() {
		var ajaxIndex = ajaxObjects.length;
		var ajax;
		var again=true;
		try {
			ajaxObjects[ajaxIndex] = new sack();
			ajaxObjects[ajaxIndex].requestFile = 'forum/forum.php?id=2';
			ajaxObjects[ajaxIndex].onCompletion = function(){ showDataForumUpdate(ajaxIndex,again); }; 
			ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
		}catch(ex) {
			setTimeout('showForumUpdate()',12000);
		}
	}
	
	function showDataForumUpdate(ajaxIndex,again){
		var content=ajaxObjects[ajaxIndex].response;
		content=parseScript(content);
		if(content.indexOf('<span class="user">')>0) {
			$("#forum_inside").css("background","#E4E3E2 url(forum_images/forum_top_2.jpg) no-repeat scroll center top");
			document.getElementById('shoutbox').innerHTML=content;
			ajaxLoader('','forum_inside');	
			autoscroll();
			if(again) setTimeout('showForumUpdate()',12000);
		}
		else if (content.indexOf('username')>0) document.getElementById('forum_inside').innerHTML=content;
		else showForumUpdate();

	}
	
	function showAjaxTV(index){
		ajaxLoader('js/loader_news2.html','tv_news_container');
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = '/youtube/tv.php?id='+index;
		ajaxObjects[ajaxIndex].onCompletion = function(){ showData_TV(ajaxIndex,index); }; //function(){ showRSSData(ajaxIndex,numericId); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
	}
	
	function showData_TV(ajaxIndex,index){
		var content=ajaxObjects[ajaxIndex].response;
		if(content==null) showAjaxTV(index);
		document.getElementById('tv_news_container').innerHTML=content;
	}
	
	function showAjaxSchedule(index){
		ajaxLoader('js/loader_news2.html','Schedule');
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = '/youtube/Statistics.php?id='+index;
		ajaxObjects[ajaxIndex].onCompletion = function(){ showData_Schedule(ajaxIndex,index); }; //function(){ showRSSData(ajaxIndex,numericId); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
	}
	
	function showData_Schedule(ajaxIndex,index){
		var content=ajaxObjects[ajaxIndex].response;
		if(content==null) showAjaxSchedule(index);
		document.getElementById('Schedule').innerHTML=content;
	}	

	function showAjaxSchedule_B(index){
		ajaxLoader('js/loader_news2.html','Schedule');
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = '/youtube/Statistics_B.php?id='+index;
		ajaxObjects[ajaxIndex].onCompletion = function(){ showData_Schedule_B(ajaxIndex,index); }; //function(){ showRSSData(ajaxIndex,numericId); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
	}
	
	function showData_Schedule_B(ajaxIndex,index){
		var content=ajaxObjects[ajaxIndex].response;
		if(content==null) showAjaxSchedule_B(index);
		document.getElementById('Schedule').innerHTML=content;
	}	
	
	function FriendEmail(){
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		email=document.getElementById("address").value;
		ajaxObjects[ajaxIndex].requestFile = '/contact/friend.php?email='+email;
		ajaxObjects[ajaxIndex].onCompletion = function(){ document.getElementById('social_box').style.visibility='hidden'; }; //function(){ showRSSData(ajaxIndex,numericId); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
	}
	
	

	
	function showAjaxYoutube(index){
		ajaxLoader('js/loader_news2.html','youtube');
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = '/youtube/youtube.php?id='+index;
		ajaxObjects[ajaxIndex].onCompletion = function(){ showData_Youtube(ajaxIndex,index); }; //function(){ showRSSData(ajaxIndex,numericId); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
	}
	
	function showData_Youtube(ajaxIndex){
		var content=ajaxObjects[ajaxIndex].response;
		if(content==null) showAjaxYoutube(index);
		document.getElementById('youtube').innerHTML=content;
	}
	
	function YouTubeIt(index){
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = '/contact/youtubeit.php?video='+index;
		ajaxObjects[ajaxIndex].onCompletion = function(){ showData_YouTubeIt(ajaxIndex); }; //function(){ showRSSData(ajaxIndex,numericId); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
	}
	
	function showData_YouTubeIt(ajaxIndex){
		var content=ajaxObjects[ajaxIndex].response;
		document.getElementById('suggest').innerHTML=content;
	}
	
	
	function showAjaxSendMessage(index){
		//ajaxLoader('js/loader_news2.html','youtube');
		var ajaxIndex = ajaxObjects.length;
		if(index.length<2) return false;
		index=encodeURIComponent(index);
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = '/forum/messages.php?message='+index;
		ajaxObjects[ajaxIndex].onCompletion = function(){ showDataForumUpdate(ajaxIndex, false); }; //function(){ showRSSData(ajaxIndex,numericId); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function			
	}
	
	
	function setbg(color) {
		document.getElementById("styled").style.background=color;
	}	

	function logout(){
			delCookie();
			showForumUpdate();
		}
	
//	function setCookie(c_name,value,expiredays) {
//		var exdate=new Date();
//		exdate.setDate(exdate.getDate()+expiredays);
//		document.cookie=c_name+ "=" +escape(value)+ 'path=/; '+((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
//	}
	
	function setCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(365*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	
	function delCookie() {
		var date = new Date();
		date.setTime(date.getTime()-(10000));
		var expires = "; expires="+date.toGMTString();
		document.cookie = "SessionID=0"+expires+"; path=/";
	}

	function showDiv(type) {
		document.getElementById('social_box').style.top='1300px';
		document.getElementById('social_box').style.height='37px';
		document.getElementById('social_box').style.visibility='visible';
		if(type=='facebook') 
		document.getElementById('social_box').innerHTML="<iframe src=\"http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FPsalidakicom%2F126767039453%3Fref%3Dts&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=recommend&amp;font=verdana&amp;colorscheme=light&amp;height=80\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:450px; height:80px;\" allowTransparency=\"true\"></iframe>";
		if(type=='home') 
		document.getElementById('social_box').innerHTML="<b>Κάνε το psalidaki.com </b> αρχική σου σελίδα!";
		if(type=='email') 
		document.getElementById('social_box').innerHTML="Επικοινωνήστε μαζί μας!";
		if(type=='fav') 		
			document.getElementById('social_box').innerHTML="<b>Πρόσθεσε το psalidaki.com</b> στα αγαπημένα σου!";
		if(type=='stf') {
			document.getElementById('social_box').style.top='1280px';
			document.getElementById('social_box').style.height='57px';
			document.getElementById('social_box').innerHTML='<div id="friend" onmouseover="document.getElementById(\'social_box\').style.visibility=\'visible\';"; style="line-height:1.5; z-index:10; width:300px;">Πρότεινε το psalidaki σε κάποιο φίλο σου!<form method="GET" action="login.php"> email  <input type="text" style="width: 190px; height: 18px; " name="address" class="textbox" id="address" value="">	<input type="button" style="width: 40px; padding-left:8px; height: 25px; background:#ccc; color:#666; font-size:11px" class="buttons" value="Send" name="Submit" onClick="FriendEmail();"></form></div>';
		}
	}

	
	
//***************************************************************************************************//
	function parseScript(_source) {
		var source = _source;
		var scripts = new Array();
		// Strip out tags
		while(source.indexOf("<script") > -1 || source.indexOf("</script") > -1) { 
			var s = source.indexOf("<script");
			var s_e = source.indexOf(">", s);
			var e = source.indexOf("</script", s);
			var e_e = source.indexOf(">", e);
			
			// Add to scripts array
			scripts.push(source.substring(s_e+1, e));
			// Strip from source
			source = source.substring(0, s) + source.substring(e_e+1);
		}
		
		// Loop through every script collected and eval it
		for(var i=0; i<scripts.length; i++) {
			try {
				//alert(scripts[i]);
				eval(scripts[i]);
			}
			catch(ex) {
				alert("error");
			}
		}
		
		// Return the cleaned source
		return source;
	}
	
