﻿$(document).ready(function () {
    $("dd:not(:first)").hide();
    $("dd").hide();
    $("dt a").click(function () {
        //$("dd:not(:visible)").slideToggle("slow");
        //$("dd:visible").slideUp("slow");
        $(this).parent().next().slideToggle("slow");
        return false;
    });
    //news slider
    var newsoption1 = {
        firstname: "mynews",
        secondname: "showhere",
        thirdname: "news_display",
        fourthname: "news_button",
        mouseover: true,
        imagedir: "Images/",
        playingtitle: "الأخبار : ",
        nexttitle: "الخبر التالي : ",
        prevtitle: "الخبر السابق : ",
        newsspeed: '8000',
        effectis: '0'
    }
    $.init_news(newsoption1);
    var myoffset = $('#news_button').offset();
    if (myoffset) {
        var mytop = myoffset.top - 1;
        $('#news_button').css({ top: mytop });
    }
    ///// end news slider ////////
});
function clearMessage() {
    x = document.getElementById("ctl00_Slider1_lblMessage");
    if (x)
        x.innerHTML = "";
}
function clearMessage2() {
    x = document.getElementById("ctl00_Slider1_lblMessage2");
    if (x)
        x.innerHTML = "";
}
function pageLoad() {
    var manager = Sys.WebForms.PageRequestManager.getInstance();
    manager.add_beginRequest(OnBeginRequest);
    manager.add_endRequest(OnEndRequest);
}
var GlobalSubmitButtonID = "ctl00_Slider1_btnLogin";
var SubmitButtonID;
function OnBeginRequest(sender, args) {

    SubmitButtonID = args.get_postBackElement().id.toLowerCase();

    if (SubmitButtonID === GlobalSubmitButtonID.toLowerCase()) {
        //Request came from the submit button . Disable submit button during postback        
        $get(GlobalSubmitButtonID).disabled = true;
    }
}
function OnEndRequest(sender, args) {
    //Check for failure here - handle them here.
    //Re-enable submit button   
    $get(GlobalSubmitButtonID).disabled = false;
}
function SubmitVote() {
    var iOption1 = 0, iOption2 = 0, iOption3 = 0, iOption4 = 0;
    var iValue = 0;
    for (i = 0; i < document.forms[0].vote.length; i++) {
        if (document.forms[0].vote[i].checked) {
            iValue = document.forms[0].vote[i].value;
        }
    }
    if (iValue == 1) {
        iOption1 = 1;
    }
    else if (iValue == 2) {
        iOption2 = 1;
    }
    else if (iValue == 3) {
        iOption3 = 1;
    }
    else if (iValue == 4) {
        iOption4 = 1;
    }
    var QuestionID = $('.question').attr("id");
    var str = "ID=" + QuestionID + "&Op1=" + iOption1 + "&Op2=" + iOption2 + "&Op3=" + iOption3 + "&Op4=" + iOption4;
    //alert(str);
    $('#btnVote').attr("disabled", true);
    $.ajax({
        type: "GET",
        cache: false,
        url: "HandelVote.aspx",
        data: str,
        success: function (msg) {
            //alert(msg);
            if (msg.indexOf("####OK") != -1) {
                //alert(msg);
                $('.VoteResult').text("تمت إضافة التصويت بنجاح");
                $('.VoteValues').html(msg.substring(0, msg.indexOf("####")));
                $('#btnVote').attr("disabled", true);
                $('#container').css("display", "none");
                //alert("ok");
            }
            else {
                $('.VoteResult').text("يوجد خطأ في التصويت");
                $('#btnVote').attr("disabled", false);
            }
        }
    });
}
function SetBgOnFoucus(obj) {
    obj.style.backgroundColor = '#FFFFE6'
}
function SetBgOnBlur(obj) {
    obj.style.backgroundColor = ''
}