﻿$(document).ready(function() {
    // show message thanks to referral
    var ref = document.referrer.toLowerCase();
    var msg = findMatch(ref);
    //var msg = 'Mamali';
    if (msg) {
        // Make the message
        var div = $('#WelcomePlaceHolder');
        div.html('Thank you ' + msg + ' for linking to my page').show();
        $.nyroModalManual({
            bgColor: '#3333cc'
            , minWidth: 245
            , minHeight: 130
            , content: div
            , 'blocker': '#main_content'
        });
        ajax_timeout = setTimeout(function() {
            $.nyroModalRemove();
        }, 7000);

    }
    // Toggle the menu div click
    $('p.mainNav').click(function() {
        var div = $(this).next('div');
        var img = $(this).children('.imgmenu');
        // First hide all div but the one clicked
        $('div.navigationDiv div').not(div).hide();
        // set all image with right_arrow
        $('.imgmenu').not(img).attr({ 'src': 'Images/nav_right_arrow.gif' });
        div.toggle();
        img.attr({ 'src': (img.attr('src') == 'Images/nav_down_arrow.gif') ? 'Images/nav_right_arrow.gif' : 'Images/nav_down_arrow.gif' });
    }); // mainNave click



    //Context Menu
    $('html').contextMenu('MasterMenu', {
        bindings: {
            'TV': function(t) { document.location = 'Wait.aspx?Page=PersianTV.aspx'; }
            , 'P_Radio': function(t) { document.location = 'Wait.aspx?Page=PersianRadio.aspx'; }
            , 'F_Radio': function(t) { document.location = 'Wait.aspx?Page=FrenchRadio.aspx'; }
            , 'Music': function(t) { document.location = 'Wait.aspx?Page=PersianMusic.aspx'; }
            , 'Contact': function(t) { document.location = 'Wait.aspx?Page=Contact.aspx'; }
            , 'VDO': function(t) { document.location = 'Wait.aspx?Page=VDO.aspx'; }
            , 'Exit': function(t) { return false; }

}// bindings

        , menuStyle: {

            border: '2px solid #000'
        , width: '150px'
} // MenuStyle
        , shadow: true
        }); //Context Menu


    });                                // Ready
    var msgs = [
 { 'url': 'newsbyray', 'msg': 'Ray' }
, { 'url': 'chista', 'msg': 'Chista' }
, { 'url': 'nid-oik', 'msg': 'nid-oik.de' }
, { 'url': 'paltalk', 'msg': 'PalTalk' }
, { 'url': 'ahura', 'msg': 'Ahura Pirooz' }
, { 'url': 'parskhabar', 'msg': 'Pars Khabar' }
, { 'url': 'delicious', 'msg': 'Delicious' }
, { 'url': 'scandiran', 'msg': 'Scand Iran' }
, { 'url': 'mardom', 'msg': 'Mardom TV' }

];


    function findMatch(ref) {
        for (var i = 0; i < msgs.length; i++) {
            if (ref.indexOf(msgs[i].url) > 0)
                return msgs[i].msg;
        }
        return null;
    }


    function showHideSubNav(id) {
        var $div = $('#' + id);
        $div.show();
        $div.prev().children('.imgmenu').attr({ 'src': 'Images/nav_down_arrow.gif' });
    }
    /***********************************************
    * Bookmark site script- 

/* Modified to support Opera */
    function bookmarksite(title, url) {
        if (window.sidebar) // firefox
            window.sidebar.addPanel(title, url, "");
        else if (window.opera && window.print) { // opera
            var elem = document.createElement('a');
            elem.setAttribute('href', url);
            elem.setAttribute('title', title);
            elem.setAttribute('rel', 'sidebar');
            elem.click();
        }
        else if (document.all)// ie
            window.external.AddFavorite(url, title);
    }
    /*****************************************************************
    Don't let other frame to content the site
    *****************************************************************/
    function breakout_of_frame() {
        //alert(top.location);
        //alert(location);
        if (top.location != location) {
            top.location.href = document.location.href;
        }
    }
    /******************************************************/
