var GalleryId = 0;
$(document).ready(function(){
	$('ul.accordion_menu ul').hide();
	$('ul.accordion_menu li a').click(function() {
		if ($(this).next().is(':visible')) {
			$(this).next().slideUp('normal');
			$(this).addClass('active').parent().siblings('li').find('ul:visible').slideUp('normal');
		} else {
			$(this).next().slideDown('normal');
			$(this).removeClass('active').parent().siblings('li').find('ul:visible').slideUp('normal');
		}
	});
	/* Afto ine gia to pngFix se IE 5.5 & 6 */
  	$(document).pngFix();
	correctPNG();
	//Moutsatsos PNG Fix mpike sto footer tis selidas
	
  	/** Create of tabls **/
  	//$('#container').tabs();
  	//get the cookie and change the background if any cookie exists!
  	//var col = $.cookie('mad_bg_color');
	//if (col){
		//document.bgColor = col;
//		chdoc(col);
  	//}
	
	// slider
	$('ul#madslidepromo').innerfade({
									speed: 1000,
									timeout: 3000,
									type: 'sequence',
									containerheight: '216px'
	});
$("#UserControl").load("/libs/User.php");
 });
 
function GetImages(){
	$.ajax({type: "POST",dataType: "xml",url: "/libs/photogallery/gallery.php",data: "id="+GalleryId,success: function(xml){
			
				var html = '<div style=" float:left; margin: 0 0 20px 0; padding:0 0 0 20px;">';
				$(xml).find('image').each(function(){
					var imgID = $(this).attr('id');
					var galID = $(this).attr('gallery');
					var imgSrc = $(this).find('path').text();
					var width = $(this).find('width').text();
					var height = $(this).find('height').text();
					html +='<div class="photo_gallery_thumb_box">&nbsp;<a href="/gallery/?alb='+galID+'&id='+imgID+'&KeepThis=true&TB_iframe=true&height=588&width=719&cap=false" class="thickbox">';
					if (height>80){
						html +='<img src="'+imgSrc+'" border="0" height="80"/>';
					}else if (width>80){
						html +='<img src="'+imgSrc+'" border="0" width="80"/>';
					}else{
						html +='<img src="'+imgSrc+'" border="0"/>';
					}
					html +='</a>&nbsp;</div>';
					
				});
				html +='</div>';
				$("#gallery_thumbs").html(html);
				tb_init("a.thickbox");
			
		}
	});
}
 
function LoadGallery(id){
	document.write('<div id="gallery_thumbs"><img src="/skin/mad/ajax/loading.gif" border="0" /></div>');
	if(id){
		GalleryId = id;
	}
	return true;
}
 
function GetLiveTV(){
	$("#LiveTV").html(" ");
	$.get(
		"/nc/LoadTV.php", {}, function(data)
		{
			$("#LiveTV").append(data);
			//$("#LiveTV").append(data).find("ul").newsTicker();
		}
	)
	//setTimeout("GetLiveTV()",10000);
}

function GetLiveRadio(){
	$("#LiveRadio").html(" ");
	$.get(
		"/nc/LoadRadio.php", {}, function(data)
		{
			$("#LiveRadio").append(data);
			//$("#LiveRadio").append(data).find("ul").newsTicker();
		}
	)
	//setTimeout("GetLiveRadio()",10000);
}
  
function chdoc(color){
 	var COOKIE_NAME = 'mad_bg_color';
    // set cookie by number of days
    $.cookie(COOKIE_NAME, color , { path: '/', expires: 1 });
    var pic = $("body").css("background-image");
    $("body").css("background",color+" "+pic);
}
function print(id,catid,width,height){
	 var w = screen.width;
	 var h = screen.height;
	 w = (w-width)/2
	 h = (h-height)/2
	 win = window.open ("/print.php?id="+id+"&c="+catid,"Print","status=0,toolbar=0,location =0,menubar=0,directories=0,resizable=1,scrollbars =1,height="+height+",width="+width+",left="+w+",top="+h);
}
function getUrlVars(){
	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	for(var i = 0; i < hashes.length; i++){
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
	}
	return vars;
}

function SubmitComment(){
	var msg = "Θα πρέπει να συμπληρώσετε  \n";
	var e = false;
	if (!document.frmComment.firstname.value){
		msg += " το όνομά σας\n";
		e = true;
	}
	if (!document.frmComment.email.value){
		msg += " το E-mail σας\n";
		e = true;
	}
	if (!document.frmComment.message.value){
		msg += " το Μήνυμα σας\n";
		e = true;
	}
	if (e){
		alert(msg+" …και μετά να πατήσετε το: Οκ τα είπα!");
	}else{
		document.frmComment.submit();
	}
}

function CheckMail()
{
	apos=document.frmComment.email.value.indexOf("@");
	dotpos=document.frmComment.email.value.lastIndexOf(".");
	if (document.frmComment.email.value == "" || apos<1 || dotpos-apos<2){
		document.frmComment.email.focus();
		return false
	}
	return true
}



