//For HighSlide With Gallery
hs.graphicsDir = 'css/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.fadeInOut = true;
hs.dimmingOpacity = 0.8;
hs.outlineType = 'rounded-white';
hs.captionEval = 'this.thumb.alt';
hs.marginBottom = 105 // make room for the thumbstrip and the controls
hs.numberPosition = 'caption';
hs.showCredits = false;

// Add the slideshow providing the controlbar and the thumbstrip
hs.addSlideshow({
        //slideshowGroup: 'group1',
        interval: 5000,
        repeat: false,
        useControls: true,
        overlayOptions: {
                className: 'text-controls',
                position: 'bottom center',
                relativeTo: 'viewport',
                offsetY: -60
        },
        thumbstrip: {
                position: 'bottom center',
                mode: 'horizontal',
                relativeTo: 'viewport'
        }
});


//Initially After Document Ready
jQuery(document).ready(function(){
    //#######################################################################################
    //Start & Display The Clock
    //#######################################################################################
    startclock();
    //#######################################################################################
    //Right Menu
    //#######################################################################################


    //===>For All The li's search for first ul then display it go to it's father(li) get it's first div child & change it's class to expand

    //Onclick Hide or Display Selected Child & Hide All Other Childrens
    jQuery('#right_menu li div:not("#right_menu li .right_menu_nosub")').bind('click',function(){
        try{
                //===>on Click of The div we put it in a div since if we put it in the li click even ifwe click in the
                //===>sub menu items it will make this event since the submenu ul is contained in the li

                //===>Now get the parent of the div (li), see if his child ul is displayed or not
                if(jQuery(this).parent().children('ul').css('display') == 'none')
                    jQuery(this).attr('class','right_menu_expand');
                else
                    jQuery(this).attr('class','right_menu_collapse');
                jQuery(this).parent().children('ul').slideToggle();

                //Hide All Others Children
                jQuery('#right_menu li div:not("#right_menu li .right_menu_nosub")').not(this).parent().each(function(){
                        //===>for every div in the li which not 'right_menu_nosub' & not the (div) i clicked on, get the parent of div (li)
                        jQuery(this).children('ul').hide().parent().children('div').attr('class','right_menu_collapse')
                        //===>get the (ul) child of the li & hide it & for it's parent (li) get the div & change it's class
                    });
        }
        catch(err){}
    });
    //#######################################################################################
    //For Pray Time
    //#######################################################################################
    var latitude=33.5631;
    var longitude=35.3689;
    var pray_time;
    
    var Now_Date = new Date();
    //var time_zone=-(Now_Date.getTimezoneOffset()/60);
    var time_zone= 2;
    var adjust = GetDateTimeLightSaving();
    time_zone= time_zone + adjust;

    prayTime.setCalcMethod(prayTime.Egypt);
    /*
        Jafari      Shia Ithna Ashari (Ja'fari)
        Karachi     University of Islamic Sciences, Karachi
        ISNA        Islamic Society of North America (ISNA)
        MWL         Muslim World League (MWL)
        Makkah      Umm al-Qura, Makkah
        Egypt       Egyptian General Authority of Survey
     */
    prayTime.setTimeFormat(prayTime.Time12);
    /*
        Time24      24-hour clock format
        Time12 	12-hour clock format (with am and pm suffixes)
        Time12NS 	12-hour clock format with no suffix
        Float 	Floating point number
     */
    //return an array of size 7 containing the times <Fajr, Sunrise, Dhuhr, Asr, Sunset, Maghrib, Isha>
    pray_time = prayTime.getPrayerTimes(new Date(), latitude, longitude, time_zone);    //getPrayerTimes (date, latitude, longitude, timeZone)
    //Daylight saving is included in timeZone. Therefore, you must add +1 to the base time offset if daylight saving is observed in the given date
    //getDatePrayerTimes (year, month, day, latitude, longitude, timeZone)

    function compare_times(start_time,end_time,now_time)
    {
        var start_date = new Date("1/1/2009 " + start_time);
        var end_date = new Date("1/1/2009 " + end_time);
        var now_date = new Date("1/1/2009 " + now_time);
        //we change them to dates so we can compare them

        if (now_date >= start_date && now_date < end_date)  //now time between start & end
            return true;
        return false;
    }
    var selected_color = "style='color:red;'";
    var now_date = new Date();
    var now_time = now_date.getHours()+":"+now_date.getMinutes();
    var is_fajir = compare_times(pray_time[6],pray_time[0],now_time);  //Is Now Time Between Isha & Fajir?
    if(is_fajir)is_fajir=selected_color;
    var is_duhur = compare_times(pray_time[0],pray_time[2],now_time);  //Is Now Time Between Fajir & Duhur?
    if(is_duhur)is_duhur=selected_color;
    var is_asr = compare_times(pray_time[2],pray_time[3],now_time);  //Is Now Time Between Duhur & Asr?
    if(is_asr)is_asr=selected_color;
    var is_mugrib = compare_times(pray_time[3],pray_time[5],now_time);  //Is Now Time Between Asr & Mugrib?
    if(is_mugrib)is_mugrib=selected_color;
    var is_isha = compare_times(pray_time[5],pray_time[6],now_time);  //Is Now Time Between Mugrib & Isha?
    if(is_isha)is_isha=selected_color;

    jQuery('#prayer_div_container').html(
        '<table border="1" cellspacing="1" cellpadding="3" align="center" style="width:180px;border-collapse:collapse;">'+
            '<tr><td class="pray_head_td">الفجر</td><td class="pray_body_td" '+is_fajir+'>'+pray_time[0]+'</td></tr>'+
            '<tr><td class="pray_head_td">الشروق</td><td class="pray_body_td">'+pray_time[1]+'</td></tr>'+
            '<tr><td class="pray_head_td">الظهر</td><td class="pray_body_td" '+is_duhur+'>'+pray_time[2]+'</td></tr>'+
            '<tr><td class="pray_head_td">العصر</td><td class="pray_body_td" '+is_asr+'>'+pray_time[3]+'</td></tr>'+
            /*'<tr><td class="pray_head_td">الغروب</td><td class="pray_body_td">'+pray_time[4]+'</td></tr>'+*/
            '<tr><td class="pray_head_td">المغرب</td><td class="pray_body_td" '+is_mugrib+'>'+pray_time[5]+'</td></tr>'+
            '<tr><td class="pray_head_td">العشاء</td><td class="pray_body_td" '+is_isha+'>'+pray_time[6]+'</td></tr>'+
        '</table>');
    //#######################################################################################
    //Audio Slide Show
    //#######################################################################################
    jQuery('.audio_slide_show').cycle({
        fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        timeout:3000
    });
    //#######################################################################################
});

//For Google Map
jQuery(window).load(function(){
    try{
        google_map_initialize();
    }
    catch(err){};
})
jQuery(window).unload(function(){
    try{
        GUnload();
    }catch(err){};
});