var $j = jQuery.noConflict();

var GalleryId = 0;
var Micro = 0;
$j(document).ready(function(){	
	/* Afto ine gia to newsticker */
//	GetLiveTV();
	//GetLiveRadio();
	/* Afto ine gia to pngFix se IE 5.5 & 6 */
  	$j(document).pngFix();
	correctPNG();
	//Moutsatsos PNG Fix mpike sto footer tis selidas
	
  	/** Create of tabls **/
  	//$j('#container').tabs();
  	//get the cookie and change the background if any cookie exists!
  	//var col = $j.cookie('mad_bg_color');
	//if (col){
		//document.bgColor = col;
//		chdoc(col);
  	//}
	
	// slider
	var o = testForObject("madslidepromo");
	if (o) {
		$j('ul#madslidepromo').innerfade({
										speed: 1000,
										timeout: 3000,
										type: 'sequence',
										containerheight: '216px'
		});
	}
	
if (GalleryId){
	GetImages();
}

$j("#btn_show").click(function () {
	//if ($j("#slide_up").is(":hidden")){
	//	$j("#slide_up").show();
	//}
	$j("#slide_up").slideDown("slow");
});
$j("#toggle_down").click(function () {
	$j("#slide_up").slideUp("slow");
});
$j("#slide_up").click(function () {
	$j("#slide_up").slideUp("slow");
});


$j("#UserControl").load("/libs/User.php");



});
 
function fixbanner(){
	//$j("#Advertisement").attr("wmode","transparent");
}

function GetImages(){

	$j.ajax({type: "POST",dataType: "xml",url: "/libs/photogallery/gallery.php",data: "id="+GalleryId+"&m="+Micro,success: function(xml){
				var html = '<div style=" float:left; margin: 0 0 20px 0; padding:0 0 0 20px;">';
				$j(xml).find('image').each(function(){
					var imgID = $j(this).attr('id');
					var galID = $j(this).attr('gallery');
					var imgSrc = $j(this).find('path').text();
					var width = $j(this).find('width').text();
					var height = $j(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=1" 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>';
				$j("#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(){
	$j("#LiveTV").html(" ");
	$j.get(
		"/nc/LoadTV.php", {}, function(data)
		{
			$j("#LiveTV").append(data);
			//$j("#LiveTV").append(data).find("ul").newsTicker();
		}
	)
	//setTimeout("GetLiveTV()",10000);
}

function GetLiveRadio(){
	$j("#LiveRadio").html(" ");
	$j.get(
		"/nc/LoadRadio.php", {}, function(data)
		{
			$j("#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
    $j.cookie(COOKIE_NAME, color , { path: '/', expires: 1 });
    var pic = $j("body").css("background-image");
    $j("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
}

function testForObject(Id, Tag)
{
  var o = document.getElementById(Id);
  if (o)
  {
    if (Tag)
    {
      if (o.tagName.toLowerCase() == Tag.toLowerCase())
      {
        return o;
      }
    }
    else
    {
      return o;
    }
  }
  return null;
}


//window.addEvent('domready',function(){
	//alert("edE");
//	var px = new mooSlide2({ slideSpeed: 1500, fadeSpeed: 1500,  toggler:'toggle_up', content:'slide_up', height:250, removeOnClick: true, opacity:'1', effects:Fx.Transitions.Bounce.easeOut, from:'top', loadExternal:'http://www.google.com/' });
//	var p = new mooSlide2({ slideSpeed: 1500, fadeSpeed: 1500,  toggler:'toggle_down', content:'slide_down', height:250, removeOnClick: true, opacity:'1', effects:Fx.Transitions.Bounce.easeOut , from:'bottom'});
	//p.run();
//})


