﻿//Interstitial Content Box v1.1- http://www.dynamicdrive.com/dynamicindex17/interstitial.htm
//Last modified: Nov 26th, 06' (New: disable webpage scrollbar, auto hide after x seconds options, 

var interstitialBox = {
    //1) list of files on server to randomly pick from and display
    displayfiles: ['index_salah.htm'],

    //2) display freqency: ["frequency_type", "frequency_value"]
    displayfrequency: ["chance", "1"],

    //3) HTML for the header bar portion of the interstitial box
    defineheader: '<div class="headerbar"><a href="#" onClick="javascript:interstitialBox.`(); return false"><img src="closeit.gif" style="border: 0" title="Close Box"/></a></div>',

    //4) cookie setting: ["cookie_name", "cookie_path"]
    cookiesetting: ["stitialcookie", "path=/"],

    //5) bust caching of pages fetched via Ajax?
    ajaxbustcache: true,

    //6) Disable browser scrollbars while interstitial is shown (Only applicable in IE7/Firefox/Opera8+. IE6 will just auto scroll page to top)?
    disablescrollbars: true,

    //7) Auto hide Interstitial Box after x seconds (0 for no)?
    autohidetimer: 0,

    ////No need to edit beyond here//////////////////////////////////

    ie7: window.XMLHttpRequest && document.all && !window.opera,
    ie7offline: this.ie7 && window.location.href.indexOf("http") == -1, //check for IE7 and offline
    launch: false,
    scrollbarwidth: 16,

    ajaxconnect: function (url, thediv) {
        var page_request = false
        var bustcacheparameter = ""
        if (window.XMLHttpRequest && !this.ie7offline) // if Mozilla, IE7 online, Safari etc
            page_request = new XMLHttpRequest()
        else if (window.ActiveXObject) { // if IE6 or below, or IE7 offline (for testing purposes)
            try {
                page_request = new ActiveXObject("Msxml2.XMLHTTP")
            }
            catch (e) {
                try {
                    page_request = new ActiveXObject("Microsoft.XMLHTTP")
                }
                catch (e) { }
            }
        }
        else
            return false
        page_request.onreadystatechange = function () {
            interstitialBox.loadpage(page_request, thediv)
        }
        if (this.ajaxbustcache) //if bust caching of external page
            bustcacheparameter = (url.indexOf("?") != -1) ? "&" + new Date().getTime() : "?" + new Date().getTime()
        page_request.open('GET', url + bustcacheparameter, true)
        page_request.send(null)
    },

    loadpage: function (page_request, thediv) {
        if (page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http") == -1)) {
            document.getElementById("interContent").innerHTML = page_request.responseText
        }
    },

    createcontainer: function () {
        //write out entire HTML for Interstitial Box:
        document.write('<div id="interContainer">' + this.defineheader + '<div id="interContent"></div></div><div id="interVeil"></div>')
        this.interContainer = document.getElementById("interContainer") //reference interstitial container
        this.interVeil = document.getElementById("interVeil") //reference veil
        this.standardbody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body //create reference to common "body" across doctypes
    },


    showcontainer: function () {
        if (this.interContainer.style.display == "none") return //if interstitial box has already closed, just exit (window.onresize event triggers function)
        var ie = document.all && !window.opera
        var dom = document.getElementById
        var scroll_top = (ie) ? this.standardbody.scrollTop : window.pageYOffset
        var scroll_left = (ie) ? this.standardbody.scrollLeft : window.pageXOffset
        var docwidth = (ie) ? this.standardbody.clientWidth : window.innerWidth - this.scrollbarwidth
        var docheight = (ie) ? this.standardbody.clientHeight : window.innerHeight
        var docheightcomplete = (this.standardbody.offsetHeight > this.standardbody.scrollHeight) ? this.standardbody.offsetHeight : this.standardbody.scrollHeight
        var objwidth = this.interContainer.offsetWidth
        var objheight = this.interContainer.offsetHeight
        this.interVeil.style.width = docwidth + "px" //set up veil over page
        this.interVeil.style.height = docheightcomplete + "px" //set up veil over page
        this.interVeil.style.left = 0 //Position veil over page
        this.interVeil.style.top = 0 //Position veil over page
        this.interVeil.style.visibility = "visible" //Show veil over page
        this.interContainer.style.left = docwidth / 2 - objwidth / 2 + "px" //Position interstitial box
        var topposition = (docheight > objheight) ? scroll_top + docheight / 2 - objheight / 2 + "px" : scroll_top + 5 + "px" //Position interstitial box
        this.interContainer.style.top = Math.floor(parseInt(topposition)) + "px"
        this.interContainer.style.visibility = "visible" //Show interstitial box
        if (this.autohidetimer && parseInt(this.autohidetimer) > 0 && typeof this.timervar == "undefined")
            this.timervar = setTimeout("interstitialBox.closeit()", this.autohidetimer * 1000)
    },


    closeit: function () {
        this.interVeil.style.display = "none"
        this.interContainer.style.display = "none"
        if (this.disablescrollbars && window.XMLHttpRequest) //if disablescrollbars enabled and modern browsers- IE7, Firefox, Safari, Opera 8+ etc
            this.standardbody.style.overflow = "auto"
        if (typeof this.timervar != "undefined") clearTimeout(this.timervar)
    },

    getscrollbarwidth: function () {
        var scrollbarwidth = window.innerWidth - (this.interVeil.offsetLeft + this.interVeil.offsetWidth) //http://www.howtocreate.co.uk/emails/BrynDyment.html
        this.scrollbarwidth = (typeof scrollbarwidth == "number") ? scrollbarwidth : this.scrollbarwidth
    },

    hidescrollbar: function () {
        if (this.disablescrollbars) { //if disablescrollbars enabled
            if (window.XMLHttpRequest) //if modern browsers- IE7, Firefox, Safari, Opera 8+ etc
                this.standardbody.style.overflow = "hidden"
            else //if IE6 and below, just scroll to top of page to ensure interstitial is in focus
                window.scrollTo(0, 0)
        }
    },

    dotask: function (target, functionref, tasktype) { //assign a function to execute to an event handler (ie: onunload)
        var tasktype = (window.addEventListener) ? tasktype : "on" + tasktype
        if (target.addEventListener)
            target.addEventListener(tasktype, functionref, false)
        else if (target.attachEvent)
            target.attachEvent(tasktype, functionref)
    },

    initialize: function () {
        this.createcontainer() //write out interstitial container
        this.ajaxconnect(this.displayfiles[Math.floor(Math.random() * this.displayfiles.length)], this.interContainer) //load page into content via ajax
        this.dotask(window, function () { interstitialBox.hidescrollbar(); interstitialBox.getscrollbarwidth(); setTimeout("interstitialBox.showcontainer()", 100) }, "load")
        this.dotask(window, function () { interstitialBox.showcontainer() }, "resize")
    }
}

/////////////End of interstitialBox object declaration here ////////////////////////////////

function getCookie(Name) {
    var re = new RegExp(Name + "=[^;]+", "i"); //construct RE to search for target name/value pair
    if (document.cookie.match(re)) //if cookie found
        return document.cookie.match(re)[0].split("=")[1] //return its value
    return null
}

function setCookie(name, value, days) {
    var expireDate = new Date()
    //set "expstring" to either an explicit date (past or future)
    if (typeof days != "undefined") { //if set persistent cookie
        var expstring = expireDate.setDate(expireDate.getDate() + parseInt(days))
        document.cookie = name + "=" + value + "; expires=" + expireDate.toGMTString() + "; " + interstitialBox.cookiesetting[1]
    }
    else //else if this is a session only cookie setting
        document.cookie = name + "=" + value + "; " + interstitialBox.cookiesetting[1]
}


var stitialvars = new Object() //temporary object to reference/ shorthand certain interstitialBox properties
stitialvars.freqtype = interstitialBox.displayfrequency[0] //"chance" or "cookie"
stitialvars.cookieduration = interstitialBox.displayfrequency[1] //"session" or int (integer specifying number of days)
stitialvars.cookiename = interstitialBox.cookiesetting[0] //name of cookie to use


if (stitialvars.freqtype == "chance") { //IF CHANCE MODE
    if (Math.floor(Math.random() * interstitialBox.displayfrequency[1]) == 0)
        interstitialBox.launch = true
}
else if (stitialvars.freqtype == "cookie" && stitialvars.cookieduration == "session") { //IF "SESSION COOKIE" MODE
    if (getCookie(stitialvars.cookiename + "_s") == null) { //if session cookie is empty
        setCookie(stitialvars.cookiename + "_s", "loaded")
        interstitialBox.launch = true
    }
}
else if (stitialvars.freqtype == "cookie" && typeof parseInt(stitialvars.cookieduration) == "number") { //IF "PERSISTENT COOKIE" MODE
    if (getCookie(stitialvars.cookiename) == null || parseInt(getCookie(stitialvars.cookiename)) != parseInt(stitialvars.cookieduration)) { //if persistent cookie is empty or admin has changed number of days to persist from that of the stored value (meaning, reset it)
        setCookie(stitialvars.cookiename, stitialvars.cookieduration, stitialvars.cookieduration)
        interstitialBox.launch = true
    }
}

//if (interstitialBox.launch)
//interstitialBox.initialize()
var interContainer = '';
var standardbody = '';
var scrollbarwidth = 16;
var interVeil = '';

function createcontainer() {
    standardbody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body //create reference to common "body" across doctypes
    //write out entire HTML for Interstitial Box:
    defineheader = '<div class="headerbar"><a href="javascript:void(0)" onClick="closeit(); return false"><img src="closeit.gif" style="border: 0" title="Close Box"/></a></div>',
document.write('<div id="interContainer">' + defineheader + '<div id="interContent"></div></div><div id="interVeil"></div>')
    interContainer = document.getElementById("interContainer") //reference interstitial container
    //this.interVeil=document.getElementById("interVeil") //reference veil
    //this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
}

function showcontainer() {
    standardbody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body //create reference to common "body" across doctypes
    interVeil = document.getElementById("interVeil")
    //var interContainer= document.getElementById("interContainer");
    if (interContainer.style.display == "none") {
        interVeil.style.display = "block"
        interContainer.style.display = "block"
        //return //if interstitial box has already closed, just exit (window.onresize event triggers function)
    }
    var ie = document.all && !window.opera
    var dom = document.getElementById
    var scroll_top = (ie) ? standardbody.scrollTop : window.pageYOffset
    var scroll_left = (ie) ? standardbody.scrollLeft : window.pageXOffset
    var docwidth = (ie) ? standardbody.clientWidth : window.innerWidth - scrollbarwidth
    var docheight = (ie) ? standardbody.clientHeight : window.innerHeight
    var docheightcomplete = (standardbody.offsetHeight > standardbody.scrollHeight) ? standardbody.offsetHeight : standardbody.scrollHeight

    var objwidth = interContainer.offsetWidth
    var objheight = interContainer.offsetHeight

    interVeil.style.width = docwidth + "px" //set up veil over page
    interVeil.style.height = docheightcomplete + "px" //set up veil over page
    interVeil.style.left = 0 //Position veil over page
    interVeil.style.top = 0 //Position veil over page
    interVeil.style.visibility = "visible" //Show veil over page
    interContainer.style.left = docwidth / 2 - objwidth / 2 + "px" //Position interstitial box
    //var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+5+"px" //Position interstitial box
    var topposition = scroll_top + 25 + "px"  //Position interstitial box

    //alert(topposition);
    interContainer.style.top = Math.floor(parseInt(topposition)) + "px"
    interContainer.style.visibility = "visible" //Show interstitial box


}


function closeit() {
    
    disablescrollbars = true
    interVeil.style.display = "none"
    interContainer.style.display = "none"
    if (disablescrollbars && window.XMLHttpRequest) //if disablescrollbars enabled and modern browsers- IE7, Firefox, Safari, Opera 8+ etc
        standardbody.style.overflow = "auto"

    showFlash();
}

function showFlash() {

    try {
        document.getElementById("RezoraDiv").style.display = "block";
        document.getElementById("div300_300").style.display = "block";
    }
    catch (ex) {
        //document.getElementById("LeftAdv_divOuter").style.display = "block";
        //document.getElementById("LeftAdv_divInner").style.display = "block";

    }

    flash = document.getElementsByTagName('embed')
    for (var i = 0; i < flash.length; i++) {
        flash[i].style.visibility = 'visible';
    }
    document.getElementById("TOpAdv").style.display = "block";
    //document.getElementById("LeftAdvMainDiv").style.display = "block";

}


function loadXMLDoc(url) {
    //document.getElementById('MostReadDiv').innerHTML='<img src="images/circle_animation.gif" alt="" >';

    jx.load(url, function (data) {
        //alert(data); // Do what you want with the 'data' variable.
        document.getElementById('MostReadDiv').innerHTML = data
    });

}





function ajaxconnect(url, thediv) {
    ie7 = window.XMLHttpRequest && document.all && !window.opera,
ie7offline = this.ie7 && window.location.href.indexOf("http") == -1, //check for IE7 and offline
ajaxbustcache = true
    var page_request = false
    var bustcacheparameter = ""
    if (window.XMLHttpRequest && !ie7offline) // if Mozilla, IE7 online, Safari etc
        page_request = new XMLHttpRequest()
    else if (window.ActiveXObject) { // if IE6 or below, or IE7 offline (for testing purposes)
        try {
            page_request = new ActiveXObject("Msxml2.XMLHTTP")
        }
        catch (e) {
            try {
                page_request = new ActiveXObject("Microsoft.XMLHTTP")
            }
            catch (e) { }
        }
    }
    else
        return false
    page_request.onreadystatechange = function () {
        loadpage(page_request, thediv)
    }
    if (ajaxbustcache) //if bust caching of external page
        bustcacheparameter = (url.indexOf("?") != -1) ? "&" + new Date().getTime() : "?" + new Date().getTime()
    page_request.open('GET', url + bustcacheparameter, true)
    page_request.send(null)
}

function loadpage(page_request, thediv) {
    if (page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http") == -1)) {
        document.getElementById("interContent").innerHTML = page_request.responseText
    }
}

function DoIt(File) {
    showcontainer()
    url = File;
    jx.load(url, function (data) {
        //alert(data); // Do what you want with the 'data' variable.
        document.getElementById("interContent").innerHTML = data
    });
    //document.getElementById("interContent").innerHTML=document.getElementById("VideoPlayer").innerHTML

}

//ShowImagesKarekater("", "24", "3", "41", "/Gallery/Big_karekateer4_24_12_2009_14_19.jpg", "Nakad Prizes")
function ShowImagesKarekater(issueid, typeid, imageid, File, caption) {

    LoadingVar = "<div align='center'><img src='images/circle_animation.gif' alt='' /></div>";
    document.getElementById("interContent").innerHTML = LoadingVar
    showcontainer()
    //data = "<div align='center'><img src='Gallery/" + File + "' width='425' height='250'/><br />" + caption + "</div>";
    //alert(caption);
    
    url = "images.aspx?id=" + issueid + "&type=" + typeid + "&ImageId=" + imageid + "&ImageStatus=1";
    jx.load(url, function (data) {
        //    //alert(url); // Do what you want with the 'data' variable.
        document.getElementById("interContent").innerHTML = data
    });
    hideFlash();
}
function ShowDesiredTopic(url) {

    LoadingVar = "<div align='center'><img src='images/circle_animation.gif' alt='' /></div>";
    document.getElementById("interContent").innerHTML = LoadingVar
    showcontainer()
    //data = "<div align='center'><img src='Gallery/" + File + "' width='425' height='250'/><br />" + caption + "</div>";
    //alert(caption);


    jx.load(url, function (data) {
        //    //alert(url); // Do what you want with the 'data' variable.
        document.getElementById("interContent").innerHTML = data
    });
    hideFlash();
}
function hideFlash() {
    document.getElementById("TOpAdv").style.display = "none";
    document.getElementById("RezoraDiv").style.display = "none";

    //document.getElementById("LeftAdvMainDiv").style.display = "none";
    try {
        document.getElementById("div300_300").style.display = "none";
    }
    catch (ex) {
        //document.getElementById("LeftAdv_divOuter").style.display = "none";
        //document.getElementById("LeftAdv_divInner").style.display = "none";
    }
    flash = document.getElementsByTagName('embed');

    for (var i = 0; i < flash.length; i++) {
        flash[i].style.visibility = 'hidden';
    }
}

function MainNewsNavTo(issueid, contentid, limit, current) {
    currentdiv = "MainNewsdiv" + current;
    LoadingVar = "<div align='center'><img src='images/circle_animation.gif' alt='' /></div>";
    document.getElementById("NewsMainDiv").innerHTML = LoadingVar
    if (limit > 10) {
        limit = 5;
    }

    url = "MainIndexNews.aspx?IssueID=" + issueid + "&Limit=" + limit + "&Current=" + current;
    jx.load(url, function (data) {
        //    //alert(url); // Do what you want with the 'data' variable.
        document.getElementById("NewsMainDiv").innerHTML = data
        document.getElementById(currentdiv).style.display = 'block';
    });



}
var isFirstTime = 1;

function NewMainNewsNavTo(current, navto) {
    ArrayLenghts = (MainNewsIds.length) - 1;
    NewLocation = current + navto;

    start = NewLocation;

    if (NewLocation > ArrayLenghts) {
        NewLocation = ArrayLenghts;
    }

    if (NewLocation <= 0) {
        NewLocation = 1;
    }

    ANMainNewsImgDiv = document.getElementById("ANMainNewsImg");
    ANMainNewsTitleDiv = document.getElementById("ANMainNewsTitle");
    ANMainNewsAbstractDiv = document.getElementById("ANMainNewsAbstract");
    anMainNewsnavtable = document.getElementById("MainNewsnavtable");

    ANMainNewsImgDiv.innerHTML = "<img src='" + MainNewsImages[NewLocation] + "' alt='' />";
    ANMainNewsTitleDiv.innerHTML = "<a href='" + MainNewsLinks[NewLocation] + "'><span style='font-size: 16pt'>" + MainNewsTitles[NewLocation] + "</span></a>";
    ANMainNewsAbstractDiv.innerHTML = MainNewsAbstract[NewLocation];
    if (MainNewsCommentsNumber[NewLocation] != "0") {
        ANMainNewsAbstractDiv.innerHTML += "<div dir='rtl'><a href='" + MainNewsLinks[NewLocation] + "'>[تعليقات - " + MainNewsCommentsNumber[NewLocation] + "]</a></div>";
    }


    NextNavLink = "";
    if (NewLocation < ArrayLenghts) {
        NextNavLink = "'NewMainNewsNavTo(" + NewLocation + ",1)'";
    }
    PrevNavLink = "";
    if (NewLocation > 1) {
        PrevNavLink = "'NewMainNewsNavTo(" + NewLocation + ",-1)'";
    }
    var status = 0;
    OneOfText = NewLocation + " من " + ArrayLenghts;
    if (isFirstTime == 1) {
        NavImages = "";
        NavImages += "<a id='prvLink' href='javascript:void(0)' onclick=" + PrevNavLink + "><img src='images/next_Nmain.jpg' title='السابق' alt='السابق' width='19' height='19' vspace='5' /></a> ";
        NavImages += "<span id='MainNewsPause'><a id='ppLink' href='javascript:void(0)' onclick='PausingAndPlaying(NewsSlideShowID," + status + ")'><img src='images/pause_Nmain.jpg' alt='توقف' title='توقف' width='18' height='19' vspace='5' /><a></span> ";
        NavImages += "<a id='nxtLink' href='javascript:void(0)' onclick=" + NextNavLink + "><img src='images/back_Nmain.jpg' title='التالي' alt='التالي' width='19' height='19' vspace='5' /><a>  ";
        isFirstTime = 0;
        HTmlNav = "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td width='75'>" + NavImages + "</td><td id='countText' dir='rtl' align='left' class='MainNewsNavText'> " + OneOfText + "</td></tr></table>"
        anMainNewsnavtable.innerHTML = HTmlNav;

    }
    else {
        document.getElementById('prvLink').onclick = function () { NewMainNewsNavTo(NewLocation, -1) };
        document.getElementById('nxtLink').onclick = function () { NewMainNewsNavTo(NewLocation, 1) };
        document.getElementById('countText').innerHTML = OneOfText;
    }
}

function PausingAndPlaying(id, status) {
    MainNewsPauseDiv = document.getElementById("MainNewsPause");
    //alert(status)
    if (status == 1) {
        // 1 -> play & 0 -> pause
        NewsSlideShowID = setInterval("MainNewsSlideShow()", 7000)
        MainNewsPauseDiv.innerHTML = "<a href='javascript:void(0)' onclick='PausingAndPlaying(NewsSlideShowID,0)'><img src='images/pause_Nmain.jpg' alt='توقف' title='توقف' width='18' height='19' vspace='5' /><a>";
    }
    else {
        clearInterval(id);
        MainNewsPauseDiv.innerHTML = "<a href='javascript:void(0)' onclick='PausingAndPlaying(NewsSlideShowID,1)'><img src='images/play_Nmain.jpg' alt='تشغيل' title='تشغيل' width='18' height='19' vspace='5' /><a>";
    }
    return true;
}

function MainNewsSlideShow() {
    ArrayLenghts = (MainNewsIds.length) - 1;
    TheCurrent = 0;
    if (start < 1) {
        start = 1;
    }

    if (start < ArrayLenghts) {
        TheCurrent = start;
    } else {
        TheCurrent = 0;
        start = 0;
    }
    //alert(ArrayLenghts)
    NewMainNewsNavTo(TheCurrent, 1);


}

function ShowWafiatBigImage(ImageName) {
    LoadingVar = "<div align='center'><img src='images/circle_animation.gif' alt='' /></div>";
    document.getElementById("interContent").innerHTML = LoadingVar
    showcontainer()
    data = "<div align='center'><img src='" + ImageName + "' /><br /></div>";
    document.getElementById("interContent").innerHTML = data

}



function ChangeImg(ImgName) {
    document.getElementById("MainImg").src = "images/" + ImgName
    //ImageContainer
}
createcontainer();


//get images by id
function ChangeContent(id) {
    //id=0;
    Nextid = id + 1;
    var NextStr = "";
    Previd = id - 1;
    var PrevStr = "";

    img_array = new Array();
    img_array[0] = "images/image0001.jpg";
    img_array[1] = "images/image0002.jpg";
    img_array[2] = "images/Copy of image0001.jpg";
    img_array[3] = "images/Copy of image0002.jpg";
    img_array[4] = "images/Copy (2) of image0001.jpg";
    img_array[5] = "images/Copy (2) of image0001.jpg";

    if (id > img_array.length) {
        //document.getElementById("next").visibility = false;
    }
    else {
        NextStr = '<a href="javascript:void(null)" onclick="ChangeContent(' + Nextid + ')">' + "<IMG SRC='images/Next.png' />" + "</a>";
    }

    if (id > 1) {
        PrevStr = '<a href="javascript:void(null)" onclick="ChangeContent(' + Nextid + ')"><IMG SRC="images/Back.png" /></a>';
    }

    var output = ''

    output += '<table border="0" width="100%" cellspacing="0" cellpadding="0">';
    output += '<tr>';
    output += '<td align="center" id="prev">' + PrevStr + '</td>';
    output += '<td width="320" id="img">';

    output += '<p align="center">';
    output += '<img border="0" src="' + img_array[id] + '" alt="' + img_array[id] + '" id="MainImg" width="305" height="319"></td>';
    output += '</p>';

    output += '<td width="130" id="next">' + NextStr + '</td>';
    output += '</tr>';
    output += '</table>';
    //alert(output)
    document.getElementById("ImageContainer").innerHTML = output


    //    var x = document.images;
    //    var image[];
    //    for (var i=0;i<x.length;i++)
    //    {
    //        image[i] = x[i];
    //    }

}

//DoIt()




function swapisses(Index) {
    myImgs = new Array(["shabab.png", "massai.png", "ektsady.png", "elbet.png"], ["hebdo.png", "derasat.png", "seyasa.png", "demokratia.png"], ["weekly.png", "ait.png", "arab.png"]);
    //alert(myImgs[0][0])
    MyLink = new Array(["http://shabab.ahram.org.eg/", "http://massai.ahram.org.eg/", "http://ik.ahram.org.eg/index.htm", "http://elbeit.ahram.org.eg/"], ["http://hebdo.ahram.org.eg/", " http://acpss.ahram.org.eg/", "http://www.siyassa.org.eg/asiyassa/index.asp", "http://democracy.ahram.org.eg/"], ["http://weekly.ahram.org.eg/index.htm", "http://ait.ahram.org.eg/", "http://arabi.ahram.org.eg/"]);
    mytitle = new Array(["الشباب", "الأهرام المسائي", "الأهرام الإقتصادى", "مجلة البيت"], ["الأهرام إبدو", "مركز الدراسات", "السياسة الدولية", "الديموقراطية"], ["الأهرام ويكلى", "لغة العصر", "الأهرام العربى"]);
    //myalt = new Array(["الشباب", "الأهرام الرياضى", "الأهرام الإقتصادى", "مجلة البيت"], ["الأهرام إبدو", "مركز الدراسات", "السياسة الدولية", "الديموقراطية"], ["الأهرام ويكلى", "الأهرام المسائى", "الأهرام العربى"]);
    imgstr = new Array();

    for (x = 0; x < 4; x++) {
        if (myImgs[Index][x] != undefined) {
            //alert(myImgs[Index][x])
            myImgs[Index][x] = '<a  href="' + MyLink[Index][x] + '" target="_blank" runat="server" ><img src="images/' + myImgs[Index][x] + '" alt="' + mytitle[Index][x] + '" title="' + mytitle[Index][x] + '" ></a>';
        } else {
            //alert(myImgs[Index][x]);
            myImgs[Index][x] = "";
        }
    }

    myhtml = '<table border="0" width="100%" cellpadding="5" cellspacing="2"> ';
    myhtml += '<tbody>';
    myhtml += '<tr>';
    myhtml += '<td align="center">' + myImgs[Index][0] + '</td>';
    myhtml += '<td  align="center">' + myImgs[Index][1] + '</td>';
    myhtml += '</tr><tr>';
    myhtml += '<td  align="center">' + myImgs[Index][2] + '</td>';
    myhtml += '<td  align="center">' + myImgs[Index][3] + '</td>';
    myhtml += '</tr>';
    myhtml += '</tbody>';
    myhtml += '</table>';

    //alert(Index +"|"+ myImgs.length)

    if (Index < myImgs.length - 1) {
        NextImgSrc = "final-_10.png";
        NextNumber = Index + 1;
    } else {
        NextImgSrc = "final-_10A.png";
        NextNumber = Index;
    }
    //alert(Index)
    if (Index >= 1) {
        PrevImgSrc = "final-_08.png";
        PrevNumber = Index - 1;
    } else {
        PrevImgSrc = "final-_08A.png";
        PrevNumber = 0;
    }



    nextVar = '<a href="javascript:void(null)" onclick="swapisses(' + NextNumber + ')"><img src="images/' + NextImgSrc + '" width="58" height="40" alt="التالي" title="التالي" /></a>';
    PrevVar = '<a href="javascript:void(null)" onclick="swapisses(' + PrevNumber + ')"><img src="images/' + PrevImgSrc + '" width="58" height="40" alt="السابق" title="السابق" /></a>';

    document.getElementById("issuesdiv").innerHTML = myhtml;
    document.getElementById("next").innerHTML = nextVar;
    document.getElementById("prev").innerHTML = PrevVar;

}
function ChkBox() {

    try {
        if (document.getElementById("sitesearch").style.display != 'none') {
            value = document.getElementById("txtSearch").value
            if (value.length < 3) {
                alert("برجاء ادخال كلمة بحث لا تقل عن 3 حروف");
                return false;
            }
        }
        return true;
    } catch (ex) {
        return true;
    }
}

function SendVoting(QustionID) {
    var flag = false;
    var msg = "من فضلك إختر إجابة";
    for (i = 0; i < aspnetForm.rdVoting.length; i++) {
        if (aspnetForm.rdVoting[i].checked == true) {
            jx.load("VotingResult.aspx?QustionID=" + QustionID + "&OptionID=" + aspnetForm.rdVoting[i].value, function (data) { document.getElementById("VotingDiv").innerHTML = data });
            flag = true;
        }
    }

    if (!flag) {
        alert(msg);
        return false;
    }
    return true;
}

function SendVoting2(QustionID, capatchaVal) {
    var formss = document.getElementById("aspnetForm");
    if (capatchaVal == 1) {
        var flag = false;
        var flagCapatcha = false;

        var msg = "من فضلك إختر إجابة";
        var msg2 = "من فضلك إدخل كود التأكيد";
        

        for (i = 0; i < formss.rdVoting.length; i++) {
            if (formss.rdVoting[i].checked == true) {
                flag = true;
            }
        }

        if (formss.voting1_Captcha1_txtCaptcha.value.length >= 4) {
            flagCapatcha = true;
        }

        if (!flag) {
            alert(msg);
            return false;
        }
        else if (!flagCapatcha) {
            alert(msg2);
            return false;
        }
        else {
            for (i = 0; i < formss.rdVoting.length; i++) {
                if (formss.rdVoting[i].checked == true) {
                    jx.load("VotingResult.aspx?capatcha=" + formss.voting1_Captcha1_txtCaptcha.value + "&QustionID=" + QustionID + "&OptionID=" + formss.rdVoting[i].value, function (data) { document.getElementById("VotingDiv").innerHTML = data });
                }
            }


        }
    }
    else {
        var flag = false;
        var msg = "من فضلك إختر إجابة";
        for (i = 0; i < formss.rdVoting.length; i++) {
            if (formss.rdVoting[i].checked == true) {
                jx.load("VotingResult.aspx?QustionID=" + QustionID + "&OptionID=" + formss.rdVoting[i].value, function (data) { document.getElementById("VotingDiv").innerHTML = data });
                flag = true;
            }
        }

        if (!flag) {
            alert(msg);
            return false;
        }
    }


    return true;
}
function SendVoting_Results(QustionID) {
    window.open("Voting_Results.aspx?QustionID=+QustionID+", null, "width=500,height=650,top=100,left=200", "true");
}

function DisplayTabContent(flag) {
    if (flag == "1") {
        document.getElementById("ImageContentDiv").style.visibility = "visible";
        document.getElementById("VideoContentDiv").style.visibility = "hidden";
    }
    else if (flag == "2") {
        document.getElementById("VideoContentDiv").style.visibility = "visible";
        document.getElementById("ImageContentDiv").style.visibility = "hidden";
    }
}

function showSdiv(DivID) {
    var div = document.getElementById(DivID);
    div.style.display = 'block';

    //sitesearch
    if (DivID == 'GoogleSearch') {
        document.getElementById("sitesearch").style.display = 'none'
    } else {
        document.getElementById("GoogleSearch").style.display = 'none'
    }
}

function rzCC(s) {
    // thanks http://www.ruzee.com/blog/2006/07/\
    // retrieving-css-styles-via-javascript/
    for (var exp = /-([a-z])/;
               exp.test(s);
               s = s.replace(exp, RegExp.$1.toUpperCase()));
    return s;
}

function _setStyle(element, declaration) {
    if (declaration.charAt(declaration.length - 1) == ';')
        declaration = declaration.slice(0, -1);
    var k, v;
    var splitted = declaration.split(';');
    for (var i = 0, len = splitted.length; i < len; i++) {
        k = rzCC(splitted[i].split(':')[0]);
        v = splitted[i].split(':')[1];
        eval("element.style." + k + "='" + v + "'");

    }
}

/*
function showGallarydiv(DivID){
var div = document.getElementById("gall-"+DivID);  
document.getElementById("GallMainDiv").innerHTML= '<img src="images/circle_animation.gif" alt="" />'
            
if(navigator.appName == "WebTV")
{
            
}
if(navigator.appName == "Netscape")
{
IE=0
}
if(navigator.appName == "Microsoft Internet Explorer")
{
IE=1
}
  
if(IE==0){
div.setAttribute("class", "photo");
} else {
div.setAttribute( 'className', 'photo' );  
}

           
            
if(DivID == 0){ // images"salah jahin"
typeid = 2;
div2 = document.getElementById("gall-1");
}else{
typeid = 3;
div2 = document.getElementById("gall-0");
}

            
if(IE==0){
div2.setAttribute("class", "photo2");
} else {
div2.setAttribute( 'className', 'photo2' );  
}

            
GallNavTo( document.getElementById("theissueid").value , typeid, 0);
}
*/

function showGallarydiv(DivID) {
    var div = document.getElementById("gall-" + DivID);
    document.getElementById("GallMainDiv").innerHTML = '<img src="images/circle_animation.gif" alt="" />'

    if (DivID == 0) { // 
        typeid = 3;
        div2 = document.getElementById("gall-1");
    } else {
        typeid = 2;
        div2 = document.getElementById("gall-0");
    }

    /* commented by ahmed farouk - Date : 16_9_2010

    if (DivID == 1) { //zaman
    document.getElementById("gall-1").innerHTML = " <a href='javascript:void(0)' onclick='showGallarydiv(1)'><img src='images/sjahin_on.jpg' alt='' /></a>";
    document.getElementById("gall-0").innerHTML = " <a href='javascript:void(1)' onclick='showGallarydiv(0)'><img src='images/caric_off.jpg' alt='' /></a>";
    } else { // today
    document.getElementById("gall-0").innerHTML = "<a href='javascript:void(0)' onclick='showGallarydiv(0)'><img src='images/caric_on.jpg' alt='' /> </a>";
    document.getElementById("gall-1").innerHTML = "<a href='javascript:void(0)' onclick='showGallarydiv(1)'><img src='images/sjahin_off.jpg' alt='' /> </a>";
    }

    */
    GallNavTo(document.getElementById("theissueid").value, typeid, 0);
}

function GallNavTo(issueid, typeid, imageid) {
    url = "images.aspx?id=" + issueid + "&type=" + typeid + "&ImageId=" + imageid + "&ImageStatus=0";
    document.getElementById("GallMainDiv").innerHTML = '<img src="images/circle_animation.gif" alt="" />';
    jx.load(url, function (data) {
        document.getElementById("GallMainDiv").innerHTML = data
    });

}


function FP_changeProp() {//v1.0
    var args = arguments, d = document, i, j, id = args[0], o = FP_getObjectByID(id), s, ao, v, x;
    d.$cpe = new Array(); if (o) for (i = 2; i < args.length; i += 2) {
        v = args[i + 1]; s = "o";
        ao = args[i].split("."); for (j = 0; j < ao.length; j++) {
            s += "." + ao[j]; if (null == eval(s)) {
                s = null; break;
            }
        } x = new Object; x.o = o; x.n = new Array(); x.v = new Array();
        x.n[x.n.length] = s; eval("x.v[x.v.length]=" + s); d.$cpe[d.$cpe.length] = x;
        if (s) eval(s + "=v");
    }
}

function FP_getObjectByID(id, o) {//v1.0
    var c, el, els, f, m, n; if (!o) o = document; if (o.getElementById) el = o.getElementById(id);
    else if (o.layers) c = o.layers; else if (o.all) el = o.all[id]; if (el) return el;
    if (o.id == id || o.name == id) return o; if (o.childNodes) c = o.childNodes; if (c)
        for (n = 0; n < c.length; n++) { el = FP_getObjectByID(id, c[n]); if (el) return el; }
    f = o.forms; if (f) for (n = 0; n < f.length; n++) {
        els = f[n].elements;
        for (m = 0; m < els.length; m++) { el = FP_getObjectByID(id, els[n]); if (el) return el; }
    }
    return null;
}

function FP_changePropRestore() {//v1.0
    var d = document, x; if (d.$cpe) {
        for (i = 0; i < d.$cpe.length; i++) {
            x = d.$cpe[i];
            if (x.v == "") x.v = ""; eval("x." + x.n + "=x.v");
        } d.$cpe = null;
    }
}

if (navigator.appName == "Netscape") {
    var IE = 0
}
if (navigator.appName == "Microsoft Internet Explorer") {
    var IE = 1
}

function SetMenuStyle(current, stylename) {
    //alert(current)
    var currentdiv = document.getElementById(current);
    //alert(currentdiv);


    if (IE == 0) {
        currentdiv.setAttribute("class", stylename);
    } else {
        currentdiv.setAttribute('className', stylename);
    }

}



function resizeIframe(frameid) {
    //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
    //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
    var iframeids = ["myframe"]

    //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
    var iframehide = "yes"

    var getFFVersion = navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
    var FFextraHeight = parseFloat(getFFVersion) >= 0.1 ? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers


    var currentfr = document.getElementById(frameid)

    if (currentfr && !window.opera) {
        currentfr.style.display = "block"
        if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
            currentfr.height = currentfr.contentDocument.body.offsetHeight + FFextraHeight;
        else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
        {

            currentfr.height = currentfr.Document.body.scrollHeight;
        }
    }
}





