// <summary>
//     Product:         Enewspaper
//     Classname:       Java Script
//     Version:         02.02 
//     Programmer:      Elham Esmaieli[elhamesmaieli@gmail.com] 
//     Purpose: 
//         All required JS to make HTML page dynamic.
// 
//     Copyright 2009 by Digital Secure Co. All Rights Reserved. 
// </summary>
// <IsMultiEdition>False</IsMultiEdition>
// <classVersion>004</classVersion>
// <EditingHistory>
//     Name:           Elham Esmaieli
//     Date:           06 May 2009
//     Reason of change :
//         Add function to confirm news direct link.
// </EditingHistory>
// <EditingHistory>
//     Name:           Soren
//     Date:           29 Apr 2009
//     Reason of change :
//         add SetCurrentNewsID(divId) to showContentForArea(divId) function in order to
//         hold current active news id for NewsCut mechanism.        
// </EditingHistory>
// <EditingHistory>
//     Name:       Elham
//     Date:       20 Jun, 2009
//     Reason of change :
//         - Editing "createImageMap()" & "createImageMap4ImageNews()" function to show border in correct position
// </EditingHistory>

var panState = '';//Keeps div id of opened sub title pan
var LastNewsContent = '0'; //A global variable to always keeps last news content id
var fontSizeSTS = true;
var showMode = 'div';

/* -------Global Functions------------  */
//This function returns an object by id
function $(id){
    return document.getElementById(id);
}

//This function changes the background image of next and previous buttons
function buttonBgOverOut(imgId, imgSrc){
    $(imgId).src='url(' + imgSrc + ')';
}

//This function make highlight btn during mouse over
function buttonImgOverOut(imgId, imgSrc){
    $(imgId).src = imgSrc;
}

//This function change class name
function changeClass(objId, objClass){
    $(objId).className = objClass;
}

//This function write data in an object
function writeObjData(objId, objData){
    $(objId).innerHTML = objData;
}

//This function make object display none
function hideObj(objId){
    $(objId).style.display = 'none';
}

//This function make object display block
function showObj(objId){
    $(objId).style.display = 'block';
}

//This function get the object data and copy in clipboard
function geting(objId){
    var v = $(objId).value;
    $(objId).select();
    clipboardData.setData('Text',v);    
}

window.fCopyToClipboard = 
function(rSource){
  rSource.select();
  if(window.clipboardData){ 
    var r=clipboardData.setData('Text',rSource.value); return 1; }
  else return 0
}

/* -------Common Functions------------  */
//This function check show mode in page load
function checkShowMode(){  
    if(showMode == 'div'){
        showDivMode();        
        //document.location.href = document.location.href;
        //alert('DIV');
        return;
        }
    else if(showMode == 'inside'){
        showInsideMode(); 
        //document.location.href = document.location.href;
        //alert('INSIDE');
        return;       
        }        
}

//This function change news show mode 
function showDivMode(){  
    var leftGap = $('pdfIcn').offsetWidth;
    leftGap = leftGap - 9;
    tbW = $('mapDivHolder').offsetLeft;
    $('titleBarHolder').style.width = '100%';
    $('contentBarHolder').style.display = 'none';
    $('prev').style.display = 'block';
    $('next').style.display = 'block'; 
    $('contentInsidePagging').style.display = 'none';
    $('topMainGap').style.display = 'block';
    $('paperItemHolder').style.display = 'block'; 
    $('insideContentHolder').style.display = 'none'; 
    $('newsTitleHolder').style.display = 'block';
    $('newsHeadlinesInside').style.display = 'none';
    $('insideGBar').style.display = 'none';
    showMode = 'div';
}

function showInsideMode(){
    hideNewsContentDiv();  
    var leftGap = $('pdfIcn').offsetWidth;
    leftGap = leftGap - 9;
    tbW = $('mapDivHolder').offsetLeft;
    $('titleBarHolder').style.width = '503px';
    $('contentBarHolder').style.display = 'block';
    $('prev').style.display = 'none';
    $('next').style.display = 'none';  
    $('contentInsidePagging').style.display = 'block';    
    $('topMainGap').style.display = 'none';  
    $('paperItemHolder').style.display = 'none'; 
    $('insideContentHolder').style.display = 'block'; 
    $('newsTitleHolder').style.display = 'none';
    $('newsContentInside').style.display = 'none';
    $('newsHeadlinesInside').style.display = 'block';
    $('insideGBar').style.display = 'block';    
    var newsHeadlines =  new String();
    newsHeadlines = $('newsHeadLineList').innerHTML;
    if (newsHeadlines != '')
        $('headlinesInsideTxt').innerHTML = newsHeadlines;                
    else
        $('headlinesInsideTxt').innerHTML = '';             
    showMode = 'inside';
}

//This function set the height of all effected element height by newspaper image height
function setAllHeightyImageSize(imgH){
    $('newsTitleHolder').style.height = imgH + 'px';
    $('newsContentInside').style.height = imgH + 'px';
    $('newsHeadlinesInside').style.height = imgH + 'px';
    $('headlinesInsideTxt').style.height = (parseInt(imgH) - 15) + 'px'; 
    $('contentInsideTxt').style.height = (parseInt(imgH) - 15) + 'px'; 
    $('mapNewsPaperHolder').style.height = imgH + 'px';
    $('mapDivHolder').style.height = imgH + 'px';
    $('paperItemHolder').style.height = imgH + 'px';
    $('mainContentPart').style.height = (parseInt(imgH) + 35) + 'px';    
    $('insideContentHolder').style.height = (parseInt(imgH) + 35) + 'px';
    $('insideGBar').style.height = (parseInt(imgH) + 24) + 'px';
    $('gBarTop').style.height = (parseInt(imgH) + 24) + 'px';  
    $('gBarDown').style.height = (parseInt(imgH) + 24) + 'px';  
    $('prev').style.height = (parseInt(imgH) + 35) + 'px';
    $('next').style.height = (parseInt(imgH) + 35) + 'px';
    $('sidebarMenu').style.height = (parseInt(imgH) + 271) + 'px';
    $('standardIcn').style.top = (parseInt(imgH) + 280) + 'px';
    $('prevB').style.top = (parseInt(imgH) - 75) + 'px';
    $('nextB').style.top = (parseInt(imgH) - 75) + 'px';
    $('newsContent').style.height = (parseInt(imgH) - 48) + 'px';
    $('myscrolledContent').style.height = (parseInt(imgH) - 115) + 'px';
}

//This function make highlight pagging number by clicking
function changePageNumber(){
    var len = $('pageNumberHolder').childNodes.length;
    for(var i=0; i<len; i++){       
        if($('pageNumberHolder').childNodes.item(i).className == 'paggNumberingHolderSelected white'){
            $('pageNumberHolder').childNodes.item(i).className = 'paggNumberingHolder black';
            break;
        }        
    }
}

// (Div Mode) This function creat next pagging button in both conditions, disabled or enabled
function putNextPagging(nextParam, src, themColor){
    if (nextPageURL == ''){
        $('next').innerHTML = '<div class="paggingTop lightGray" style="text-align:left;">' +
                                    'بعدی' +
                                    '<img id="nt" src="' + src + 'images/theme_' + themColor + '/pagging/etedal_nextDis.jpg" width="10" height="15" alt="صفحه بعدی" align="top" style="margin-top:1px; margin-right:3px;" />' +
                                '</div>' +
                                '<div id="nextB" class="paggingBottom lightGray" style="text-align:left; top:713px;">' +
                                    'بعدی' +
                                    '<img id="nb" src="' + src + 'images/theme_' + themColor + '/pagging/etedal_nextDis.jpg" width="10" height="15" alt="صفحه بعدی" align="top" style="margin-top:1px; margin-right:3px;" />' +
                                '</div>';
    }
    else{    
        $('next').innerHTML = '<div class="paggingTop pionter" style="text-align:left;" onmouseover="buttonImgOverOut(\'nt\', \'' + src + 'images/theme_' + themColor + '/pagging/etedal_paggingNextOver.jpg\')" onmouseout="buttonImgOverOut(\'nt\', \'' + src + 'images/theme_' + themColor + '/pagging/etedal_paggingNext.jpg\')" onclick="goUrl(\'' + nextParam + '\');">' +
                                    'بعدی' +
                                    '<img id="nt" src="' + src + 'images/theme_' + themColor + '/pagging/etedal_paggingNext.jpg" width="10" height="15" alt="صفحه بعدی" align="top" style="margin-top:1px; margin-right:3px;" />' +
                                '</div>' +
                                '<div id="nextB" class="paggingBottom pionter" style="text-align:left; top:713px;" onmouseover="buttonImgOverOut(\'nb\', \'' + src + 'images/theme_' + themColor + '/pagging/etedal_paggingNextOver.jpg\')" onmouseout="buttonImgOverOut(\'nb\', \'' + src + 'images/theme_' + themColor + '/pagging/etedal_paggingNext.jpg\')" onclick="goUrl(\'' + nextParam + '\');">' +
                                    'بعدی' +
                                    '<img id="nb" src="' + src + 'images/theme_' + themColor + '/pagging/etedal_paggingNext.jpg" width="10" height="15" alt="صفحه بعدی" align="top" style="margin-top:1px; margin-right:3px;" />' +
                                '</div>';
    }      
}

// (Content Inside Mode) This function creat next pagging button in both conditions, disabled or enabled
function createNextPagging(nextParam, src, themColor){
    if (nextPageURL == ''){
        $('nextInsideMode').innerHTML = '<div class="contentPaggingTop lightGray" style="text-align:left;">' +
                                            'بعدی' +
                                            '<img id="cnt" src="' + src + 'images/theme_' + themColor + '/pagging/etedal_nextDis.jpg" width="10" height="15" alt="صفحه بعدی" align="top" style="margin-top:1px; margin-right:3px;" />' +
                                        '</div>';
    }
    else{    
        $('nextInsideMode').innerHTML = '<div class="contentPaggingTop pionter" style="text-align:left;" onmouseover="buttonImgOverOut(\'nt\', \'' + src + 'images/theme_' + themColor + '/pagging/etedal_paggingNextOver.jpg\')" onmouseout="buttonImgOverOut(\'cnt\', \'' + src + 'images/theme_' + themColor + '/pagging/etedal_paggingNext.jpg\')" onclick="goUrl(\'' + nextParam + '\');">' +
                                            'بعدی' +
                                            '<img id="cnt" src="' + src + 'images/theme_' + themColor + '/pagging/etedal_paggingNext.jpg" width="10" height="15" alt="صفحه بعدی" align="top" style="margin-top:1px; margin-right:3px;" />' +
                                        '</div>';
    }      
}

// (Div Mode) This function creat previous pagging button in both conditions, disabled or enabled
function putPrevPagging(prevParam, resource, themColor){
    if (prevParam == ''){
        $('prev').innerHTML = '<div class="paggingTop lightGray" style="text-align:right;">' +
                                    '<img id="pt" src="' + resource + 'images/theme_' + themColor + '/pagging/etedal_prevDis.jpg" width="10" height="15" alt="صفحه قبل" align="top" style="margin-top:1px; margin-left:3px;" />' +
                                    'قبلی' +
                                '</div>' +
                                '<div id="prevB" class="paggingBottom lightGray" style="text-align:right; top:713px;">' +
                                    '<img id="pb" src="' + resource + 'images/theme_' + themColor + '/pagging/etedal_prevDis.jpg" width="10" height="15" alt="صفحه قبل" align="top" style="margin-top:1px; margin-left:3px;" />' +
                                    'قبلی' +
                                '</div>';
    }
    else{ 
        $('prev').innerHTML = '<div class="paggingTop pionter" style="text-align:right;" onmouseover="buttonImgOverOut(\'pt\', \'' + resource + 'images/theme_' + themColor + '/pagging/etedal_paggingPrevOver.jpg\')" onmouseout="buttonImgOverOut(\'pt\', \'' + resource + 'images/theme_' + themColor + '/pagging/etedal_paggingPrev.jpg\')" onclick="goUrl(\'' + prevParam + '\');">' +                        
                                    '<img id="pt" src="' + resource + 'images/theme_' + themColor + '/pagging/etedal_paggingPrev.jpg" width="10" height="15" alt="صفحه قبل" align="top" style="margin-top:1px; margin-left:3px;" />' +
                                    'قبلی' +
                                '</div>' +
                                '<div id="prevB" class="paggingBottom pionter" style="text-align:right; top:713px;" onmouseover="buttonImgOverOut(\'pb\', \'' + resource + 'images/theme_' + themColor + '/pagging/etedal_paggingPrevOver.jpg\')" onmouseout="buttonImgOverOut(\'pb\', \'' + resource + 'images/theme_' + themColor + '/pagging/etedal_paggingPrev.jpg\')" onclick="goUrl(\'' + prevParam + '\');">' +
                                    '<img id="pb" src="' + resource + 'images/theme_' + themColor + '/pagging/etedal_paggingPrev.jpg" width="10" height="15" alt="صفحه قبل" align="top" style="margin-top:1px; margin-left:3px;" />' +
                                    'قبلی' +
                                '</div>';
    }       
}

// (Content Inside Mode) This function creat previous pagging button in both conditions, disabled or enabled
function createPrevPagging(prevParam, resource, themColor){
    if (prevParam == ''){
        $('prevInsideMode').innerHTML = '<div class="contentPaggingTop lightGray" style="text-align:right;">' +
                                            '<img id="cpt" src="' + resource + 'images/theme_' + themColor + '/pagging/etedal_prevDis.jpg" width="10" height="15" alt="صفحه قبل" align="top" style="margin-top:1px; margin-left:3px;" />' +
                                            'قبلی' +
                                        '</div>';
    }
    else{ 
        $('prevInsideMode').innerHTML = '<div class="contentPaggingTop pionter" style="text-align:right;" onmouseover="buttonImgOverOut(\'pt\', \'' + resource + 'images/theme_' + themColor + '/pagging/etedal_paggingPrevOver.jpg\')" onmouseout="buttonImgOverOut(\'cpt\', \'' + resource + 'images/theme_' + themColor + '/pagging/etedal_paggingPrev.jpg\')" onclick="goUrl(\'' + prevParam + '\');">' +                        
                                            '<img id="cpt" src="' + resource + 'images/theme_' + themColor + '/pagging/etedal_paggingPrev.jpg" width="10" height="15" alt="صفحه قبل" align="top" style="margin-top:1px; margin-left:3px;" />' +
                                            'قبلی' +
                                        '</div>';
    }       
}


/* -------Show and hide right pan tree------------  */
// -------Main title------This function expand and collaps the main papaer title side pan menu
function showHideNewsTitle(divId, HTMLResourcePath, themColor){
    stsN = $(divId).style.display;
    if(stsN == 'none'){
        $(divId).style.display = 'block';
        $('spn_'+divId).className = 'panLink_activeG';        
        $('tree_'+divId).src = HTMLResourcePath + 'images/theme_' + themColor + '/sideBar/etedal_active.jpg';
        $('sel_' + divId).className = 'panSestionSelected bgWhite gray';
        return;
        }
    else if(stsN == 'block'){
        $(divId).style.display = 'none';
        $('spn_'+divId).className = 'panLink gray';
        $('tree_'+divId).src = HTMLResourcePath + 'images/theme_' + themColor + '/sideBar/etedal_disactiveG.jpg';
        $('sel_' + divId).className = 'panSestion gray';
        return;
        }        
}

//-------Sub title------This function expand and colaps sub title of side pan
function showHidePageIndex(divId, HTMLResourcePath, themColor){
    //panState holds the open pan div id but it shouldn't be equal to current div id to close it 
    if ((panState != '') && (panState != divId)){
        $(panState).style.display = 'none';
        $('spn_'+panState).className = 'panLink gray';
        $('tree_'+panState).src = HTMLResourcePath + 'images/theme_' + themColor + '/sideBar/etedal_disactiveG.jpg';
    } 
    //sts holds the status of div pan display 
    sts = $(divId).style.display;
    //show and hide status of div pan 
    if(sts == 'none'){
        $(divId).style.display = 'block';
        $('spn_'+divId).className = 'panLink_active';
        $('tree_'+divId).src = HTMLResourcePath + 'images/theme_' + themColor + '/sideBar/etedal_activeG.jpg';
        panState = divId;
        return;
        }
    else if(sts == 'block'){
        $(divId).style.display = 'none';
        $('spn_'+divId).className = 'panLink gray';        
        $('tree_'+divId).src = HTMLResourcePath + 'images/theme_' + themColor + '/sideBar/etedal_disactiveG.jpg';
        return;
        }        
}


/* -------News Content Related Functions----  */
//This function visible the Content Div
function showNewsContentDiv(){    
    newsTitleSts = $('newsContentHolder').style.display;
    hideLastHighlight();
    $('newsContentHolder').style.display = 'block';
}

function hideNewsContentDiv(){    
    hideLastHighlight();
    $('newsContentHolder').style.display = 'none';        
    LastNewsContent = '0';// set lastNewsContent to zero(empty)
}

function hideNewsContentInside(){    
    hideLastHighlight();
    $('newsTitleTxtR').style.display = 'block';
    $('newsTitleTxt').style.display = 'block';
    $('newsTitleTxtL').style.display = 'block';
    $('contentBarRight').style.display = 'none';
    $('newsContentFeature').style.display = 'none';
    $('newsContentInside').style.display = 'none';
    $('backToHeadlines').style.display = 'none';
    $('contentInsideTxt').innerHTML = ''; 
    $('newsContentInside').style.display = 'none';
    $('newsHeadlinesInside').style.display = 'block';
    $('insideGBar').style.display = 'block';
    LastNewsContent = '0';// set lastNewsContent to zero(empty)
}

//Highlight related map area
function lightContent(divId){
    showHighlightImageMap('map_' + divId); 
}

//Hide Highlight related map area
function hideLightContent(divId){
    hideHighlightImageMap('map_' + divId); 
}

//This function first hides last news map highlight, newspaper headlines and all newsContent except the current news content
//It works on clicking each map area highlight
function showContentForArea(divId) {
    // hold current active news id.
    SetCurrentNewsID(divId);
    hideLastHighlight();    //hide last map area highlight
    $('newsTitleHolder').style.display = 'none';  //hide news headlines div
    LastNewsContent = divId;
    hideAllContentDiv();    
    if(showMode == 'div'){
        showNewsContentDiv();
        $('content_' + divId).style.display = 'block';
    }
    else if(showMode == 'inside'){
        $('newsTitleTxtR').style.display = 'none';
        $('newsTitleTxt').style.display = 'none';
        $('newsTitleTxtL').style.display = 'none';
        $('insideGBar').style.display = 'none';
        $('contentBarRight').style.display = 'block';
        $('newsContentFeature').style.display = 'block';
        $('newsContentInside').style.display = 'block';
        $('backToHeadlines').style.display = 'block';
        $('contentInsideTxt').style.display = 'block';
        var newsContent =  new String();
        newsContent = $('content_' + divId).innerHTML;                
        if (newsContent != ''){
            $('contentInsideTxt').innerHTML = newsContent;  
            $('newsTitr').style.paddingTop = '0px';
            $('newsTitr').style.marginTop = '-15px';
            }
        else
            $('contentInsideTxt').innerHTML = '';  
        $('newsHeadlinesInside').style.display = 'none';      
        hideLastHighlight();
    }
    showHighlightImageMap('map_' + divId);
}

//This function gets object id and makes an array of all tagName which choosed
function $$(item, tagName){
    if (typeof(item) == "string"){
        if ($(item) != null)
            return $(item).getElementsByTagName(tagName);
        else
            return null;
    }
    else{
        if (item.getElementsByTagName != null){
            return item.getElementsByTagName(tagName);
        }
        else{
           return null; 
        }
    }
}

//This function hides all news content Div
function hideAllContentDiv(){
    var items = $$("allContent", "div");
    for (var i = 0; i < items.length; i++){
        $(items[i].id).style.display = 'none';
    }	    
}


//This function first hides last news map highlight, newspaper headlines and all newsContent except the current news content
//It works on clicking each map area highlight
function showImageForArea(divId,URLAddress){
    goUrlInNewWindow(URLAddress);
}


/* -------Make headline div visible------------  */
//This function first hides last news map highlight and then  shows all newspaper headlines
//It works on clicking news Headlines
function showHeadlines(){
    hideLastHighlight(); //Hides last map area highlight
    $('newsContent_' + LastNewsContent).style.display = 'none';
    $('newsHeadLines').style.display = 'block';
    LastNewsContent = '0';// set lastNewsContent to zero(empty)
}

//This function visible the headlines Div
function showNewsTitleDiv(){
    hideNewsContentDiv();
    newsTitleSts = $('newsTitleHolder').style.display;
    if( newsTitleSts == 'none')
        $('newsTitleHolder').style.display = 'block';
    else
        $('newsTitleHolder').style.display = 'none';
}


/* -------Redirect to specific URL address ------------ */
//This function gets a url and changes pages url by that
function goUrl(URLAddress) {
    if (URLAddress != "") {
      document.location.href = URLAddress;
    }
  }
  
//This function gets a url aand open it in new window
function goUrlInNewWindow(URLAddress) {
    if (URLAddress != "") {
      window.open(URLAddress);
    }
  } 
  
//This function gets the global variable value to hide previous map area highlight
function hideLastHighlight(){
    if (LastNewsContent != 0){
        i = LastNewsContent;
        lni = 'map_' + i;
        $(lni).style.border='none';
    }
}

//This function gets coords of map shape and creates a div element for each one and by newsId parameters gives them a unice id
//in onmouseover event calls "showHighlightImageMap(divId)" to highlight the div
//in onmouseout event calls "hideHighlightImageMap(divId)" to hide div
//in onclick event calls "showContentForArea(newsId)" to show related news content
function createImageMap(xyStr, newsId){    
    var xy = new Array();
    for(var i=0; i<3; i++){
        f = xyStr.indexOf(',');
        xy[i] = xyStr.substring(0,f);
        xyStr = xyStr.substring(f+1); 
    }
    xy[3] = xyStr;			    
    w = parseInt(xy[2]) - parseInt(xy[0]);
    h = parseInt(xy[3]) - parseInt(xy[1]);
    xy[0] = parseInt(xy[0]) - 4;
    xy[1] = parseInt(xy[1]) - 4;
    $('mapDivHolder').innerHTML += '<div id="map_'+ newsId +'" style="position:absolute; left:' + xy[0] + 'px; top:' + xy[1] + 'px; width:' + w + 'px; height:' + h + 'px; " onmouseover="showHighlightImageMap(\'map_'+ newsId +'\');"  onmouseout="hideHighlightImageMap(\'map_'+ newsId +'\');" onclick="showContentForArea(\''+ newsId +'\');">&nbsp;</div>';    
}

//This function gets coords of map shape and creates a div element for each one and by newsId parameters gives them a unice id
//in onmouseover event calls "showHighlightImageMap(divId)" to highlight the div
//in onmouseout event calls "hideHighlightImageMap(divId)" to hide div
//in onclick event calls "showImageForArea(newsId)" to show related news content
function createImageMap4ImageNews(xyStr, newsId ,URLAddress){    
    var xy = new Array();
    for(var i=0; i<3; i++){
        f = xyStr.indexOf(',');
        xy[i] = xyStr.substring(0,f);
        xyStr = xyStr.substring(f+1); 
    }
    xy[3] = xyStr;			    
    w = parseInt(xy[2]) - parseInt(xy[0]);
    h = parseInt(xy[3]) - parseInt(xy[1]);
    xy[0] = parseInt(xy[0]) - 4;
    xy[1] = parseInt(xy[1]) - 4; 
    $('mapDivHolder').innerHTML += '<div id="map_'+ newsId +'" style="position:absolute; left:' + xy[0] + 'px; top:' + xy[1] + 'px; width:' + w + 'px; height:' + h + 'px; " onmouseover="showHighlightImageMap(\'map_'+ newsId +'\');"  onmouseout="hideHighlightImageMap(\'map_'+ newsId +'\');" onclick="showImageForArea(\''+ newsId +'\' , \''+ URLAddress+ '\')">&nbsp;</div>';    
}

//This function checks div and if it is not the current highlight div for current news content makes it hidden
function hideHighlightImageMap(divId){    
    i = LastNewsContent;    
    lni = 'map_' + i;
    if(lni != divId){
        $(divId).style.border = 'none';
        $(divId).style.cursor = 'default';
        }
}

//This function highlights div by gives it a background color 
function showHighlightImageMap(divId){
    $(divId).style.border = 'solid 4px #ffcc00'; 
    $(divId).style.cursor = 'pointer'; 
}

//This function gets "LastNewsContent" global variable value to finds the last news Id
function getNewsId(newsContentId){
    u = newsContentId.indexOf('_');
    n = newsContentId.substring(u+1);
    return n;
}

//Pass the query string parametre to this function to get the value
function querySt(str) {
    hu = window.location.search.substring(1);
    if(hu == '')
    {
        return '';
    }
    gy = hu.split("?");
    for (i=0 ; i<gy.length ;i++) 
    {
        ft = gy[i].split("=");
        if (ft[0] == str) 
        {
            return ft[1];
        }
    }
    return '';
}    

// This function get URL Base and make print version link
// note : if news ID avalable
function goPrintVersion(URLBase) {
    if (LastNewsContent != '0') 
    {
      goUrlInNewWindow(URLBase + LastNewsContent);
    }
    else
    {
        alert('لطفاً یک خبر را انتخاب کنید');
    }
  } 


/* ------- display Archive Div ------------ */  
var archiveSts = false;
//This function visible the archive date drop down list by clicking on 'بایگانی'
function showArchiveDiv(){
    if(!archiveSts){
        $('archiveHolder').style.display = 'block';
        archiveSts = true;
        return;
    }
    else{
        $('archiveHolder').style.display = 'none';
        archiveSts = false;
        return;
    }
}

//This function visible the archive date drop down list by clicking on search button
function hideArchiveDiv(){
    $('archiveHolder').style.display = 'none';
    archiveSts = false;
}

//This function make highlight pagging number by clicking
function changeFontSize(){
    if (fontSizeSTS){
        changeClass('allContent', 'fontSizeXLarg lineHeightLarg');
        fontSizeSTS = false;
        return;
    }
    else{
        changeClass('allContent', 'fontSizeLarg lineHeightMedium');
        fontSizeSTS = true;
        return;
    }
}

//This function make move icon hidden if the browser would be Net scape
function hideMoveIcn(){
    var browserVer = navigator.appName;          
    if (browserVer == 'Netscape'){        
        $('movmentIcn').style.display = 'none';
        $('movmentTxt').style.display = 'none';
        }
    else        
        return;
}

//This function make move icon hidden if the browser would be Net scape
function hidePdfIcn(prm){    
    if (prm != '')
        $('pdfIcnHolder').style.display = 'block';
    else        
        return;
}


/* ------- Confirm News Direct Link ------------ */  
var newsLinkSts = false;
var str = new String();
//This function visible the archive date drop down list by clicking on 'بایگانی'
function showNewsLink(objId){ 
    str = window.location + '?NewsID=' + LastNewsContent;
    $(objId).value = str;
    x = window.confirm(str + '\n\n  کپی شود؟ clipboard آیا در');
    if(x)        
        geting(objId);
    else
        return;
}



/* ------- Change Site Color  ------------ */  
function showColorPanel(){
    var sts = document.getElementById('chooseColor').style.display;
    if(sts == 'none')
        document.getElementById('chooseColor').style.display = 'block';
    else
        document.getElementById('chooseColor').style.display = 'none';
}

function changeSiteColor(col){
    var x = new Array();
    x = document.images;
    var imgS = x[0].src;        
    var inx = imgS.indexOf('/theme_') + 7;
    var startSrc = imgS.substring(0, inx);
    var endSrc = new Array();
     
    for (var i=0;i<x.length;i++)
    {
        var s = x[i].src;        
        var color = s.substring(inx);
        var k = color.indexOf('/');
        k = inx + k;
        color = s.substring(inx , k);
        endSrc[i] = s.substring(k);
        x[i].src = startSrc + col + endSrc[i];
    }    
    var root = document.getElementById('ss').href;
    var m = root.indexOf('CSS/');
    root = root.substring(0,m);
    document.getElementById('ss').href = root + 'CSS/' + col + 'Styles.css';
    siteColor = col;
}

//This function help page number to be sorted correctly by numeric value. 
function sortNumber(a,b){
    return a - b;
}

//This function genareted sorted page numbering html code
var pageNumbers = new Array();
var pageLink;
var i = 0;
var selectPage;
          
function creatPaggingNumber(){
    var end = pageNumbers.length;    
    pageNumbers.sort(sortNumber);
    for(var i=0; i<end; i++){
        var tdTag = document.createElement("td");   
        tdTag.align ="center";
        if(pageNumbers[i] == selectPage){              
            tdTag.innerHTML = "<div class='paggNumberingHolderSelected white'>" + pageNumbers[i] + "</div>";   
        }
        else{            
            var c = pageLink.indexOf('Page/');
            c = parseInt(c) + 5;
            var link = pageLink.substring(0,c);                        
            link = link + pageNumbers[i] + '/index.htm';                       
            tdTag.innerHTML = "<div onclick='goUrl(\"" + link + "\");' class='paggNumberingHolder black'>" + pageNumbers[i] + "</div>";   
        }  
        
        document.getElementById('pageNumberHolder').appendChild(tdTag); 
    }
}



/* ------- User Setting Cookies  ------------ */  
function setColorByCookie(){
    var cc = YAHOO.util.Cookie.get('colorCookie');
    if(cc!='' && cc!= null){
        changeSiteColor(YAHOO.util.Cookie.get('colorCookie'));
    }
}