// JavaScript Document

// INPUT ONCLICK SCRIPT-->
function clearText(field){
	if (field.defaultValue == field.value) {
		field.value = '';
		field.className='click';
	} else if (field.value == '') {
		field.value = field.defaultValue;
		field.className='blur';
}
}

// scrollable paging
$(function() {
	// paging slider
	if ($('#pageslider').length) {
	  $("#pageslider").scrollable();
	}
});


// select dropdown
$(function(){
	
	$('select#rating').selectmenu({
		style:'dropdown',
		maxHeight: 150
	});
	$('select.slcttype1').selectmenu({
		style:'dropdown',
		maxHeight: 155
	});
	$('select.slcttype2').selectmenu({
		style:'dropdown',
		maxHeight: 128
	});
	
});


$(document).ready(function () {

    // JCAROUSELLITE
    if ($('.soonthumbs').length) {
        $(".soonthumbs .jCarouselLite").jCarouselLite({
            btnNext: ".soonthumbs .next",
            btnPrev: ".soonthumbs .prev",
            vertical: true,
            visible: 6,
            circular: true,
            scroll: 2
        });
    }


    // LIQUID CAROUSEL ACTIONS
    if ($('#dvdthumbs').length) {
        $('#dvdthumbs').liquidcarousel({ height: 220, duration: 300, hidearrows: true });
    }
    if ($('#braythumbs').length) {
        $('#braythumbs').liquidcarousel({ height: 220, duration: 300, hidearrows: true });
    }
    if ($('#gamethumbs').length) {
        $('#gamethumbs').liquidcarousel({ height: 204, duration: 300, hidearrows: true });
    }
    if ($('#bookthumbs').length) {
        $('#bookthumbs').liquidcarousel({ height: 220, duration: 300, hidearrows: true });
    }
    if ($('#musicthumbs').length) {
        $('#musicthumbs').liquidcarousel({ height: 194, duration: 300, hidearrows: true });
    }
    if ($('#giftthumbs').length) {
        $('#giftthumbs').liquidcarousel({ height: 220, duration: 300, hidearrows: true });
    }
    if ($('#similarthumbs').length) {
        $('#similarthumbs').liquidcarousel({ height: 109, duration: 300, hidearrows: true });
    }
    if ($('#recentthumbs').length) {
        $('#recentthumbs').liquidcarousel({ height: 109, duration: 300, hidearrows: true });
    }


    // BTN4 CLICK ACTIONS
    $(".cols3right .up").mousedown(function () {
        $(this).addClass('click');
    });

    $(".cols3right .up").mouseup(function () {
        $(this).removeClass('click');
    });

    $(".cols3right .down").mousedown(function () {
        $(this).addClass('click');
    });

    $(".cols3right .down").mouseup(function () {
        $(this).removeClass('click');
    });

    // EMAILBTN CLICK ACTION
    $("#logged.emailbtn").click(function () {
        $(this).addClass('selected');
    });


    // APPLY LARGEST HEIGHT IN EVERY LIST5 LI
    $(".list5 > .row").each(function () {
        var maxheight = 0;
        $("> li", this).each(function () {
            if (maxheight < $(this).height()) {
                maxheight = $(this).height();
            }
        });

        $("> li", this).height(maxheight);
    });

    // APPLY LARGEST HEIGHT IN EVERY LIST9.NODESCR LI
    $(".list9.nodescr > ul").each(function () {
        var maxheight = 0;
        $("> li", this).each(function () {
            if (maxheight < $(this).height()) {
                maxheight = $(this).height();
            }
        });

        $("> li", this).height(maxheight);
    });




    // FANCYBOX
    if ($('.zoom1').length) {
        $(".zoom1").fancybox({
            titlePosition: 'inside',
            'transitionIn': 'fade',
            'transitionOut': 'fade',
            'hideOnContentClick': true,
            centerOnScroll: true
        });
    }
    if ($('.magn').length) {
        $('.magn').click(function (event) {
            $('#FirstImageID').click();
        });
    }
    if ($(".zoom2").length) {
        $('.zoom2').fancybox({
            'transitionIn': 'fade',
            'transitionOut': 'fade',
            centerOnScroll: true,
            overlayShow: true
        });
    }
    if ($(".page").length) {
        $('.page').fancybox({
            'width': '75%',
            'height': '75%',
            'autoScale': false,
            'transitionIn': 'none',
            'transitionOut': 'none',
            'type': 'iframe'
        });
    }
    if ($(".popupmap").length) {
        $('.popupmap').fancybox({
            'width': '75%',
            'height': '75%',
            'autoScale': false,
            'transitionIn': 'none',
            'transitionOut': 'none',
            'type': 'iframe',
            frameWidth: 580,
            frameHeight: 530
        });
    }

    // MULTISELECT, 'Select All' text changed
    if ($('select.multi').length) {
        $("select.multi").multiSelect({
            selectAll: false,
            selectAllText: 'Επιλογή Όλων',
            noneSelected: 'Επιλογές',
            oneOrMoreSelected: '% επιλεγμένα',
            listHeight: 155
        });
    }

    if ($('.formtype1 input.chkbx').length) {
        $('.formtype1 input.chkbx').prettyCheckboxes();
    }

    if ($('.formtype2 input.radbtn').length) {
        $('.formtype2 input.radbtn').prettyCheckboxes();
    }

    // FAQ ANIMATED FAQ SCROLL
    $('.topbtn a').click(function () {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
        return false;
    });

    // PRETTY CHECKBOXES
    if ($('#radios1').length) {
        $('#radios1 input[type=radio]').prettyCheckboxes();
        //$('#checkboxDemo input[type=checkbox],#radioDemo input[type=radio]').prettyCheckboxes();
        //$('.inlineRadios input[type=radio]').prettyCheckboxes({'display':'inline'});
    }

    // RENTALS LIST STATE BUTTON
    $(".list3.compact .state").click(function () {
        $(this).parent('li').toggleClass('open');
    });

    // ADD .chkbx TO INPUT
    // call prettyCheckboxes() for every CheckBox ID generated
    /*if ($('#ctl00_MainContentPlaceHolder_CheckBoxID').length) {
    $('#ctl00_MainContentPlaceHolder_CheckBoxID').prettyCheckboxes();
    }
    if ($('#ctl00_MainContentPlaceHolder_AlertCheckBoxID').length) {
    $('#ctl00_MainContentPlaceHolder_AlertCheckBoxID').prettyCheckboxes();
    }*/

    // make pretty checkboxes based on parent class
    if ($('.makechckbx').length) {
        $(".makechckbx input").prettyCheckboxes();
    }


    // resize thumb frame in detail page
    var prodframe = $("#main .cols3left .photos img").width();
    $("#main .cols3left .photos").css("width", prodframe);


    //Handles Enter clicks when in Search TextBox. Url parameters depend on cinema/ eshop search
    $("#textfield").keypress(function (e) {
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
            var searchKey = $("#textfield").val();
            var redirectUrl = 'search.aspx?key=' + searchKey;
            //cinema searches
            var str = String(window.location);
            if (str.indexOf("cinema") != -1) {
                if ($('#selecttypeid').val() == 'cinema')
                    redirectUrl += "&type=cinema";
            }
            // category eshop searches
            else {
                if (($('#selecttypeid').val() == 'Τίτλοι') || ($('#selecttypeid').val() == 'Titles'))
                    redirectUrl += "&title=" + searchKey;
                else if (($('#selecttypeid').val() == 'Ηθοποιοί') || ($('#selecttypeid').val() == 'Actors'))
                    redirectUrl += "&actor=" + searchKey;
                else if (($('#selecttypeid').val() == 'Σκηνοθέτες') || ($('#selecttypeid').val() == 'Directors'))
                    redirectUrl += "&director=" + searchKey;

                // format eshop searches
                if ($('#selecttypeid').val() == 'DVD')
                    redirectUrl += "&formatID=1";
                else if ($('#selecttypeid').val() == 'BLURAY')
                    redirectUrl += "&formatID=12";
                else if ($('#selecttypeid').val() == 'GAMES')
                    redirectUrl += "&formatID=-1";
                else if ($('#selecttypeid').val() == 'BOOKS')
                    redirectUrl += "&formatID=11";
                else if ($('#selecttypeid').val() == 'MUSIC')
                    redirectUrl += "&formatID=13";
                else if ($('#selecttypeid').val() == 'GIFTS')
                    redirectUrl += "&formatID=14";
                else if ($('#selecttypeid').val() == 'ΑΝΑΛΩΣΙΜΑ')
                    redirectUrl += "&formatID=8";
            }

            window.location.replace(redirectUrl);
        }
    });

    //Handles Search Button Clicks
    $(".search a").click(function () {
        var searchKey = $("#textfield").val();
        var redirectUrl = 'search.aspx?key=' + searchKey;
        //cinema searches
        var str = String(window.location);
        if (str.indexOf("cinema") != -1) {
            if ($('#selecttypeid').val() == 'cinema')
                redirectUrl += "&type=cinema";
        }
        // specific eshop searches
        else {
            if (($('#selecttypeid').val() == 'Τίτλοι') || ($('#selecttypeid').val() == 'Titles'))
                redirectUrl += "&title=" + searchKey;
            else if (($('#selecttypeid').val() == 'Ηθοποιοί') || ($('#selecttypeid').val() == 'Actors'))
                redirectUrl += "&actor=" + searchKey;
            else if (($('#selecttypeid').val() == 'Σκηνοθέτες') || ($('#selecttypeid').val() == 'Directors'))
                redirectUrl += "&director=" + searchKey;

            // format eshop searches
            if ($('#selecttypeid').val() == 'DVD')
                redirectUrl += "&formatID=1";
            else if ($('#selecttypeid').val() == 'BLURAY')
                redirectUrl += "&formatID=12";
            else if ($('#selecttypeid').val() == 'GAMES')
                redirectUrl += "&formatID=-1";
            else if ($('#selecttypeid').val() == 'BOOKS')
                redirectUrl += "&formatID=11";
            else if ($('#selecttypeid').val() == 'MUSIC')
                redirectUrl += "&formatID=13";
            else if ($('#selecttypeid').val() == 'GIFTS')
                redirectUrl += "&formatID=14";
            else if ($('#selecttypeid').val() == 'ΑΝΑΛΩΣΙΜΑ')
                redirectUrl += "&formatID=8";
        }

        window.location.replace(redirectUrl)
    });



    function alertMsg() {
        alert("Hello");
    }



});


$(window).bind("load", function() {
	// GALLERY1
	if ($('div#gallery1').length) {
	  $("div#gallery1").slideViewerPro({
		  leftButtonInner: "<img src='images/arrow2-le.gif' />",
		  rightButtonInner: "<img src='images/arrow2-ri.gif' />"
	  });
	}
	
	// GALLERY2
	if ($('div#gallery2').length) {
	  $("div#gallery2").slideViewerPro({
		  galBorderWidth: 0,
		  thumbsBorderColor: "#1e1e1e",
		  thumbsActiveBorderColor: "#fff",
		  thumbsRightMargin: 13,
		  buttonsWidth: 13,
		  leftButtonInner: "<img src='images/arrow4-le.gif' />",
		  rightButtonInner: "<img src='images/arrow4-ri.gif' />"
	  });
	}
	
	// GALLERY3
	if ($('div#gallery3').length) {
	  $("div#gallery3").slideViewerPro({
		  galBorderWidth: 0,
		  thumbsVis: false
	  });
	}
});








