/**
 * @author anastis sourgoutsidis
 */
$(document).ready(function(){

	$(".mainMenu li").css("z-index","10");
	$(".middle_column").css("z-index","5");
	$(".slideshow_container").css("z-index","10");

	$(".mainMenu li").hover(
	  function () {
	    $(this).children("ul").show();
	  },
	  function () {
	    $(this).children("ul").hide();
	  }
	);
	

	$('.box h2').hover(function(){
		$(this).siblings('ul').slideToggle();
	});
    //$('.left_column .box ul:gt(0)').hide();
    $('.left_column .box ul').hide();

	$('.category span').hover(function(){
		var submenu = $(this).next('ul');
		$(this).parent('li').toggleClass('open');
		submenu.slideToggle("50");
		return false;
	});
    // Hide all lists except the outermost.
    $('.left_column ul ul').hide();
	

    $('a[href*="admin/file_delete"]').click(function() {
        var answer = confirm("Σίγουρα θέλετε να διαγράψετε το αρχείο;")
        if (answer){
            return true;
        }
        else{
            return false;
        };
    });
	
    $('a[href*="admin/article_delete"]').click(function() {
        var answer = confirm("Σίγουρα θέλετε να διαγράψετε το επιλεγμένο άρθρο;")
        if (answer){
            return true;
        }
        else{
            return false;
        };
    });

    $('a[href*="admin/category_delete"]').click(function() {
        var answer = confirm("Σίγουρα θέλετε να διαγράψετε την επιλεγμένη κατηγορία;")
        if (answer){
            return true;
        }
        else{
            return false;
        };
    });
	
    $('input[type="submit"][value="Διαγραφή"]').click(function() {
        var answer = confirm("Σίγουρα θέλετε να διαγράψετε τον επιλεγμένο χρήστη;")
        if (answer){
            return true;
        }
        else{
            return false;
        };
    });
	

	//var currentPath = location.pathname;
	//$('a[href $= "' + currentPath + '"]').parent().addClass('current');

	var currentPath = location.href;
	
	$('a[href = "' + currentPath + '"]').parent().addClass('current');

	$('.box li.current').parents('ul').each(function(){
		$(this).show();
		$(this).parent('li').toggleClass('open');
	});
	
	$(".mainMenu").lavaLamp({ fx: "backout", speed: 700 });

	$(".jcarousellite").jCarouselLite({  
		vertical: true,  
		visible: 4,  
		auto:30,  
		speed:3000
		//easing: "backout"
	}); 


	//Search Box
	var search_value = $(".search_container .search_label").text();
	$(".search_container .search_label").remove();
	$(".search_box").attr("value",search_value);
    $(".search_box").focus(function () {
         if ($(this).attr("value") == search_value) 
		 {
		 	$(this).attr("value", "");
		 }
    });
    $(".search_box").blur(function () {
         if($(this).attr("value")=="")
		 {
		 	$(this).attr("value",search_value);
		 }
    });

	$(document).pngFix();

	//var slideNum = $(".main_slideshow > a").size();
	//var randomIndex = Math.floor(Math.random()*slideNum); 
	$('.main_slideshow').slideshow({
        width:888,      // width in px
        height:240,     // height in px
        //index:randomIndex, 	// start from frame number N
        index:0, 	// start from frame number N
		time:7000,      // time out beetwen slides
        title:false,     // show title
        panel:false,     // show controls panel
        playframe:false,       // show frame "Play Now!"
        imgresize:true      // resize image to slideshow window
		}).playSlide();


	$('.small_slideshow').slideshow({
        width:180,      // width in px
        height:180,     // height in px
        //index:0,        // start from frame number N
        //time:3000,      // time out beetwen slides
		//history:false,  // change/check location hash 
        title:false,     // show title
        //titleshow:false,// always show title
        //callback:null,  // callback function - call when slide changed - receive index and label
        panel:false,     // show controls panel
        //play:true,     // play slideshow
        //loop:true,      // looping
        //effect:'fade',  // aviable fade, scrollUp/Down/Left/Right, zoom, zoomFade, growX, growY
        //effecttime:1000,// aviable fast,slow,normal and any valid fx speed value
        //filter:true,    // remove <br/>, empty <div>, <p> and other stuff
        //nextclick:false,      // bind content click next slide
        //playclick:false,      // bind content click play/stop
        //playhover:false,      // bind content hover play/stop
        //playhoverr:false,     // bind content hover stop/play (reverse of playhover)
        playframe:false,       // show frame "Play Now!"
        //loadframe:true,       // show frame with "loading"
        //fullscreen:false,     // in full window size
		
        imgresize:true,      // resize image to slideshow window
        imgzoom:true,         // zoom image to slideshow window (for smaller side)
        imgcenter:true,       // set image to center
        imgajax:true         // load images from links
        //imglink:true,         // go to external link by click
		
        //linkajax:false,       // load html from links
        //help:'Plugin homepage: <a href="http://slideshow.hohli.com">(a)Slideshow</a><br/>'+
        //     'Author homepage: <a href="http://anton.shevchuk.name">Anton Shevchuk</a>',

        /*controls: { // show/hide controls elements
			'hide': true, // show controls bar on mouse hover
			'first': true, // goto first frame
			'prev': true, // goto previouse frame (if it first go to last)
			'play': true, // play slideshow
			'next': true, // goto next frame (if it last go to first)
			'last': true, // goto last frame
			'help': true, // show help message
			'counter': true // show slide counter
		} */
		}).playSlide();
	
});


