  var globalObject = new Object();
  globalObject.playlistWidgetClickID = 0;
   
  function img_reload(site_url) {
           var currentTime = new Date()
           var result = currentTime.getMinutes() + "";
           result = result + currentTime.getSeconds();
           document.myForm.img_secure.src = site_url + 'check_image.php?'+result;
  }
  
  function characters_used (s) {
          var r = s - document.getElementById('txt_area').value.length;
           document.getElementById('characters').innerHTML = r;
           if (r < 0) {
             document.getElementById('characters').style.color = '#f00';
             document.getElementById('add_txt').disabled = 'disabled';
             //document.getElementById('add_txt').className = 'submit_disabled';
             //document.getElementById('add_txt_div').className = 'submit_disabled';
           } else {
             document.getElementById('characters').style.color = '#777';
             document.getElementById('add_txt').disabled = '';
             //document.getElementById('add_txt').className = 'submit_general';
             document.getElementById('add_txt_div').className = 'stripe SSGeneral';
           }
  }

  function changeLink(id, active) {
           document.getElementById(id).className=active;
  }

  function characterUsed (s) {
          var r = s - $('mail_txt').value.length;
           $('characters_txt').innerHTML = r;
           if (r < 0) {
             $('characters_txt').style.color = '#f00';
           } else {
             $('characters_txt').style.color = '#777';
           }
  }

  function SetAllCheckBoxes() {
          var elem = document.myForm.elements;
          for (var i = 0; i < elem.length; i++) {
             if (elem[i].type == 'checkbox') {
               if (elem[i].name != 'all_chk' && elem[i].id != 'all_chk') {
                 if (document.myForm.all_chk.checked == true) elem[i].checked = true;
                 if (document.myForm.all_chk.checked == false) elem[i].checked = false;
               }
             }
          }
  }

  function hide_show (id,act) {
	       if (act == 0) {
			 document.getElementById(id).style.display = 'none';
           } else {
			 document.getElementById(id).style.display = 'block';
		   }
  }
  
  function changeBorderLink (phid,naid,act) {
	       if (act == 1) {
			 document.getElementById(phid).style.borderColor = '#0187c5'; 
			 document.getElementById(naid).style.textDecoration = 'underline';
		   } else {
			 document.getElementById(phid).style.borderColor = '#dddddd';
			 document.getElementById(naid).style.textDecoration = 'none';
		   }
  }
  
  function changeBorderLink2 (photoID, linkID, action) {
		if (action == 1) {
			document.getElementById(photoID).style.borderColor = '#0187c5'; 
			document.getElementById(linkID).style.textDecoration = 'underline';
			document.getElementById(linkID).style.color = '#0187c5';
		} else {
			document.getElementById(photoID).style.borderColor = '#dddddd';
			document.getElementById(linkID).style.textDecoration = 'none';
			document.getElementById(linkID).style.color = '#333';
		}
  }
  
  function changeBorder(id, color) {
		document.getElementById(id).style.borderColor=color;
  }
  
  function NewsOnechange(int,cat) {
	    for (var i=0; i<3; i++) { 
		   document.getElementById("cat_title_"+int+"_"+i).className = null; 
		}
        document.getElementById("cat_photo_"+int).src = eval('img_cat'+int+'[cat].src');
		document.getElementById("cat_photo_"+int).title = eval('title_cat'+int+'[cat]');
		document.getElementById("cat_photo_"+int).alt = eval('title_cat'+int+'[cat]');
		document.getElementById("cat_link_"+int).href = eval('links_cat'+int+'[cat]');
		document.getElementById("cat_title_"+int+"_"+cat).className = "active";
  }
  
  function NewsOnerotate() {
	    
		if (fr == 1) {Onecurrent = 0;fr = 0;
		} else {
          if (Onecurrent == Slidestotal-1) {Onecurrent = 0;
		  } else if (Onecurrent >= 0 & Onecurrent <= 3) {Onecurrent = Onecurrent + 1;}
		}
		
		if (Onecurrent == 0) {re = 2;
		} else if (Onecurrent >= 1 & Onecurrent <= 3) {re = Onecurrent - 1;}
		document.getElementById("spotlight_"+re).className = null;
		document.getElementById("spot_img_top_link").href = spot_links[Onecurrent];
		document.getElementById("spot_title_link").href = spot_links[Onecurrent];
		document.getElementById("spot_full_link").href = spot_links[Onecurrent];
		document.getElementById("spot_img_top").src = spot_img_big[Onecurrent].src;
		document.getElementById("spot_img_top").title = spot_title[Onecurrent];
		document.getElementById("spot_img_top").alt = spot_title[Onecurrent];
		document.getElementById("spot_title_link").innerHTML = spot_title[Onecurrent];
		document.getElementById("spot_txt").innerHTML = spot_text[Onecurrent]+'... ';
		document.getElementById("spotlight_"+Onecurrent).className = "selected";
		idtimeout = window.setTimeout("NewsOnerotate()", Onerotate_delay);
		
  }
  
  function NewsOneclick(int) {
	  
	    Onecurrent = int;
		for (var i=0; i<Slidestotal; i++) { 
		   document.getElementById("spotlight_"+i).className = null;
		}
        document.getElementById("spot_img_top_link").href = spot_links[Onecurrent];
		document.getElementById("spot_title_link").href = spot_links[Onecurrent];
		document.getElementById("spot_full_link").href = spot_links[Onecurrent];
		document.getElementById("spot_img_top").src = spot_img_big[Onecurrent].src;
		document.getElementById("spot_img_top").title = spot_title[Onecurrent];
		document.getElementById("spot_img_top").alt = spot_title[Onecurrent];
		document.getElementById("spot_title_link").innerHTML = spot_title[Onecurrent];
		document.getElementById("spot_txt").innerHTML = spot_text[Onecurrent]+'... ';
		document.getElementById("spotlight_"+Onecurrent).className = "selected";
		clearTimeout(idtimeout);
		idtimeout = window.setTimeout("NewsOnerotate()", Onerotate_delay);
  }
  
  function resizeText(Size) {
        if (Size == 14) {
          document.getElementById('PlusA').style.display = "none";
          document.getElementById('MinusD').style.display = "none";
          document.getElementById('PlusD').style.display = "block";
          document.getElementById('MinusA').style.display = "block";
       }
       if (Size == 12) {
          document.getElementById('PlusD').style.display = "none";
          document.getElementById('MinusA').style.display = "none";
          document.getElementById('PlusA').style.display = "block";
          document.getElementById('MinusD').style.display = "block";
       }
       document.getElementById('NewsBody').style.fontSize = Size + "px";
  }
 
  function photoNavigator (course) {
      if (course == 1) {
          document.getElementById('LBorder').style.borderColor = '#0187c5';
          document.getElementById('LArrow').className = 'stripe photo-navigator-arrows p-nav-left-active';
      } else if (course == 2) {
          document.getElementById('LBorder').style.borderColor = '#b5b5b5';
          document.getElementById('LArrow').className = 'stripe photo-navigator-arrows p-nav-left';
      }
      if (course == 3) {
          document.getElementById('RBorder').style.borderColor = '#0187c5';
          document.getElementById('RArrow').className = 'stripe photo-navigator-arrows p-nav-right-active';
      } else if (course == 4) {
          document.getElementById('RBorder').style.borderColor = '#b5b5b5';
          document.getElementById('RArrow').className = 'stripe photo-navigator-arrows p-nav-right';
      }
  }
 
  function changeBg(id, color) {
		 document.getElementById(id).style.backgroundColor=color;
  }
  
  function searchMenu (id) {
		for (var i=1; i<4; i++) {
			document.getElementById(i).className = 'search_section';
    	}
			document.getElementById(id).className = 'search_section_active';
  }
  
  function searchLetter (id, alphabet) {
		var Tabs = ['TabAr', 'TabEn', 'TabFi'];
		var Alphabets = ['Arabic', 'English', 'Figures'];
		
		for (var i=0; i<3; i++) {
			document.getElementById(Tabs[i]).className = '';
			document.getElementById(Alphabets[i]).style.display = 'none';
    	}
			document.getElementById(id).className = 'active';
			document.getElementById(alphabet).style.display = 'block';
  }

  function jsMenu(o) {
        document.getElementById(o.e0).style.display = o.e2;
        document.getElementById('Submenu').style.display = o.e2;
        if (o.e2 == 'block')
          document.getElementById(o.e1).className = 'active';
        else
          document.getElementById(o.e1).className = '';
  }

  function ShowSelect() {
        document.getElementById('select_list').style.display = 'block';
        document.getElementById('selected').style.color = '#000';
        document.getElementById('pointer').className = 'stripe selectA';
  }
  function HideSelect() {
        document.getElementById('select_list').style.display = 'none';
        document.getElementById('selected').style.color = '#777';
        document.getElementById('pointer').className = 'stripe selectD';
  }
  function ValueSelect(option, item) {
        document.getElementById('SValue').value = option;
        document.getElementById('selected').innerHTML = item;
  }
function setElementOpacity(oElem, nOpacity)
{
	var p = getOpacityProperty();
	(setElementOpacity = p=="filter"?new Function('oElem', 'nOpacity', 'nOpacity *= 100;	var oAlpha = oElem.filters["DXImageTransform.Microsoft.alpha"] || oElem.filters.alpha;	if (oAlpha) oAlpha.opacity = nOpacity; else oElem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";'):p?new Function('oElem', 'nOpacity', 'oElem.style.'+p+' = nOpacity;'):new Function)(oElem, nOpacity);
}
function getOpacityProperty()
{
	var p;
	if (typeof document.body.style.opacity == 'string') p = 'opacity';
	else if (typeof document.body.style.MozOpacity == 'string') p =  'MozOpacity';
	else if (typeof document.body.style.KhtmlOpacity == 'string') p =  'KhtmlOpacity';
	else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) p =  'filter';

	return (getOpacityProperty = new Function("return '"+p+"';"))();
}
function fadeOpacity(sElemId, sRuleName, bBackward)
{
	var elem = document.getElementById(sElemId);
	if (!elem || !getOpacityProperty() || !fadeOpacity.aRules[sRuleName]) return;

	var rule = fadeOpacity.aRules[sRuleName];
	var nOpacity = rule.nStartOpacity;

	if (fadeOpacity.aProc[sElemId]) {clearInterval(fadeOpacity.aProc[sElemId].tId);nOpacity = fadeOpacity.aProc[sElemId].nOpacity;}
	if ((nOpacity==rule.nStartOpacity && bBackward) || (nOpacity==rule.nFinishOpacity && !bBackward)) return;

	fadeOpacity.aProc[sElemId] = {'nOpacity':nOpacity, 'tId':setInterval('fadeOpacity.run("'+sElemId+'")', fadeOpacity.aRules[sRuleName].nDalay), 'sRuleName':sRuleName, 'bBackward':Boolean(bBackward)};
}

fadeOpacity.addRule = function(sRuleName, nStartOpacity, nFinishOpacity, nDalay){fadeOpacity.aRules[sRuleName]={'nStartOpacity':nStartOpacity, 'nFinishOpacity':nFinishOpacity, 'nDalay':(nDalay || 30),'nDSign':(nFinishOpacity-nStartOpacity > 0?1:-1)};};

fadeOpacity.back = function(sElemId){fadeOpacity(sElemId,fadeOpacity.aProc[sElemId].sRuleName,true);};

fadeOpacity.run = function(sElemId)
{
	var proc = fadeOpacity.aProc[sElemId];
	var rule = fadeOpacity.aRules[proc.sRuleName];

	proc.nOpacity = Math.round(( proc.nOpacity + .1*rule.nDSign*(proc.bBackward?-1:1) )*10)/10;
	setElementOpacity(document.getElementById(sElemId), proc.nOpacity);

	if (proc.nOpacity==rule.nStartOpacity || proc.nOpacity==rule.nFinishOpacity) clearInterval(fadeOpacity.aProc[sElemId].tId);
}
fadeOpacity.aProc = {};
fadeOpacity.aRules = {};
fadeOpacity.addRule('oR1', .5, 1, 30);

  function chartsThumbs (photoID, linkID, action) {
    if (action == 1) {
        document.getElementById(photoID).className = 'Thumbnail chart-page-hover';
        document.getElementById(linkID).style.textDecoration = 'underline';
        document.getElementById(linkID).style.color = '#0187c5';
    } else {
        document.getElementById(photoID).className = 'Thumbnail chart-page';
	document.getElementById(linkID).style.textDecoration = 'none';
	document.getElementById(linkID).style.color = '#333';
    }
  }
  function chartsMenu (yid, wid) {
    for (var i=1; i<=2; i++) {
        document.getElementById('year_' + i).className = '';
        document.getElementById('weeks_' + i).style.display = 'none';
    }
    document.getElementById(yid).className = 'active';
    document.getElementById(wid).style.display = 'block';
  }

  function showPlayer(o) {
            var line = o.tline;
            if (playListObject[line] == undefined) playListObject[line] = new Array(o.url, o.tline, "", o.bg1, o.bgtype);
            var next = playListObject.next;

            if (swfobject.getFlashPlayerVersion().major == 0) {
                noFlashPlayer();
            } else {
                var pause;
                if (playListObject.isPlaing == line) {
                    var flashID = document.getElementById("lineI"+line);
                    if (document.getElementById("btn"+line).className == "play pause") {
                        pause = true;
                        document.getElementById("btn"+line).className = "play audio";
                        flashID.playPause("pause");
                    } else {
                        pause = false;
                        document.getElementById("btn"+line).className = "play pause";
                        flashID.playPause("plaing");
                    }
                } else if (playListObject.isPlaing >= 0) {
                    removePlayer(playListObject.isPlaing, false, '0');
                }

                if (pause == undefined) {
                    playListObject[line][2] = document.getElementById("lineO"+line).innerHTML;
                    playListObject.isPlaing = line;
                    if (o.liID != undefined) {
                        playListObject.isPlaingID = o.liID;
                        document.getElementById('table_'+o.liID).style.cursor = "default";
                    }
                    //CSS
                        document.getElementById("btn"+line).className = "play pause";
                        if (playListObject[line][4] != '3') {
                            if (playListObject[line][4] == '1')
                                document.getElementById("playerbg"+line).style.backgroundColor = "#5f6971";
                            document.getElementById("playlist"+line).className = "line-player";
                            document.getElementById("playlist"+line).style.backgroundColor = "#5f6971";
                        } else {
                            document.getElementById("playlist"+line).className = "search-playlist search-play-on";                            
                        }
                        //search-playlist search-play-on else


                    var flashvars = {};
                    flashvars.file = playListObject[line][0];
                    flashvars.line = line;
                    flashvars.next = next;
                    var volumeVal = readCookie("volumeVal");
                    if (volumeVal != null) {
                        flashvars.volumeVal = volumeVal;
                    }
                    swfobject.embedSWF(dom.site_url+"flash/player.swf?2", "lineI"+line, "220", "23", "9.0.0",
                               dom.img_site_url+"flash/expressInstall.swf",
                               flashvars,
                               {wmode: "opaque"},
                               {wmode: "opaque"});
                }
            }
        }

        function removePlayer(line, next, fromFlash) {
            if (fromFlash == '0') {
                swfobject.removeSWF("lineI"+line);
                document.getElementById("lineO"+line).innerHTML = playListObject[line][2];
                playListObject.isPlaing = -1;
                if (playListObject.isPlaingID != undefined) {
                    document.getElementById('table_'+playListObject.isPlaingID).style.cursor = "move";
                    playListObject.isPlaingID = undefined;
                }

                //CSS
                    document.getElementById("btn"+line).className = "play audio";
                    if (playListObject[line][4] == '1')
                        document.getElementById("playerbg"+line).style.backgroundColor = "#ffffff";
                    else if (playListObject[line][4] == '2') {
                        //document.getElementById("playerbg"+line).style.background = "none";
                        //document.getElementById("playerbg"+line).style.backgroundColor = playListObject[line][3];
                    }
                    if (playListObject[line][4] != '3') {
                        document.getElementById("playlist"+line).className = "";
                        document.getElementById("playlist"+line).style.backgroundColor = playListObject[line][3];
                    } else {
                        document.getElementById("playlist"+line).className = "search-playlist";
                    }
            } else {
                document.getElementById("btn"+line).className = "play audio";
                if (next == true && playListObject[line] != undefined) {
                    showPlayer({tline:(line+1)});
                }
            }
        }
        function saveVolume(volumeVal) {
            document.cookie = "volumeVal="+volumeVal+"; expires=; path=/";
        }
        function readCookie(name) {
                var nameEQ = name + "=";
                var ca = document.cookie.split(';');
                for(var i=0;i < ca.length;i++) {
                        var c = ca[i];
                        while (c.charAt(0)==' ') c = c.substring(1,c.length);
                        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
                }
                return null;
        }

        function changePlaylistHover(tr, line, cl) {
            if (playListObject.isPlaing != line) {
                tr.style.backgroundColor = cl;
            }
        }

         function showPlayer2(line) {
            if (swfobject.getFlashPlayerVersion().major == 0) {
                //noFlashPlayer();
            } else {
                    var flashvars = {};
                    flashvars.file = playListObject[line][0];
                    flashvars.line = line;
                    flashvars.next = false;
                    var volumeVal = readCookie("volumeVal");
                    if (volumeVal != null) {
                        flashvars.volumeVal = volumeVal;
                    }
                    swfobject.embedSWF(dom.site_url+"flash/player2.swf?3", "player", "504", "40", "9.0.0",
                               dom.img_site_url+"flash/expressInstall.swf",
                               flashvars,
                               {wmode: "opaque"},
                               {wmode: "opaque"});
            }
         }
         var noPlayerBox;

         function noFlashPlayer() {
             var flashPlayerURL = 'http://get.adobe.com/flashplayer/';
             if (noPlayerBox == undefined) {
                 noPlayerBox = new MessageBox({title: langPack.lang_33, width: 400, progress: false});
             }
             noPlayerBox.removeButtons();
             noPlayerBox.addButton({label: langPack.lang_30, btnClassName: 'cancel', onClick: function(){noPlayerBox.hide();}});
             noPlayerBox.addButton({label: langPack.lang_29, btnClassName: 'button', onClick: function(){window.location.href = flashPlayerURL;noPlayerBox.hide();}});
             var content= '<div style="padding:15px 0;">';
             content+= langPack.lang_32;
             content+= '<br/><br/>';
             content+= langPack.lang_31;
             noPlayerBox.content(content).show();
         }

         function wikiIsComparing(o) {
             var i, result = 0;
             var a, b = '';
             for(i=0; i<document.myForm.a.length;i++) {
                 if (document.myForm.a[i].type == 'radio' && document.myForm.a[i].checked) {
                     a = document.myForm.a[i].value;
                     result = 1;
                     break;
                 }
             }
             if (result == 1) {
                 result = 0;
                 for(i=0; i<document.myForm.b.length;i++) {
                     if (document.myForm.b[i].type == 'radio' && document.myForm.b[i].checked) {
                         b = document.myForm.b[i].value;
                         result = 1;
                         break;
                     }
                 }
             }
             if (result == 0) {
                 notifications({title: 'Error', fail: true, failText: langPack.lang_53});
             } else if (a == b) {
                 notifications({title: 'Error', fail: true, failText: langPack.lang_54});
             }
             else if (result == 1) window.location.href = o.sucurl + 'a=' + a + '&b=' + b;
         }
         function wikiClick(o) {
             document.getElementById(o.id).checked = true;
         }

         function wikiCompare(o) {
            var text1 = o.text1.replace(/<br[\/]{0,}>/gi, "\n");
            var text2 = o.text2.replace(/<br[\/]{0,}>/gi, "\n");

            dmp.Diff_Timeout = 5;      //timeout
            dmp.Diff_EditCost = 4;

            var d = dmp.diff_main(text1, text2);

            dmp.diff_cleanupSemantic(d);

            var ds = dmp.diff_prettyHtml(d);
            document.getElementById('resultDiv').innerHTML = ds;
         }

  function trackMenu(o) {
      var s = '';
      if (o.type == 'on') {
          if (globalObject.playlistWidgetClickID != o.id)
            document.getElementById('playlistWidgetAId_'+o.id).style.display = "block";
      } else if (o.type == 'off') {
          if (globalObject.playlistWidgetClickID != o.id)
            document.getElementById('playlistWidgetAId_'+o.id).style.display = "none";
      } else if (o.type == 'click') {
          if (globalObject.playlistWidgetClickID == o.id) {
              document.getElementById('playlistWidgetDivId_'+o.id).innerHTML = '';
              document.getElementById('playlistWidgetDivId_'+o.id).style.overflow = 'hidden';
              document.getElementById('playlistWidgetAId_'+o.id).className = "opacity track-list-tool";
              globalObject.playlistWidgetClickID = 0;
          } else {
              if (globalObject.playlistWidgetClickID != 0) {
                  trackMenuHide({id: globalObject.playlistWidgetClickID});
              }
              if (globalObject.playlistWidgetClickID != o.id) {
                  globalObject.playlistWidgetClickID = o.id;
                  document.getElementById('playlistWidgetAId_'+o.id).className = "opacity track-list-tool-active";
                  s+= '<ul class="tool-options">';
                  if (o.listO.share) {
                    s+= '<li><a href="#" id="share_track_'+o.id+'" onclick="return false;">'+langPack.share+'</a></li>';                   
                  }
                  if (o.listO.playlist) {
                    if (o.uid) {
                      s+= '<li><a href="#" onclick="addtoplaylist({tid:'+o.id+', color: \''+o.color+'\', rowid:'+o.rowid+'});return false;">'+langPack.lang_55+'</a></li>';
                    } else {
                      s+= '<li><a href="#" onclick="txtmess({txt:\''+langPack.lang_56+'\',winname:\''+langPack.lang_55+'\'});return false;">'+langPack.lang_55+'</a></li>';
                    }
                  }
                  if (o.listO.tag) {
                    s+= '<li><a href="#" onclick="return false;">Add tags</a></li>';
                  }
                  s+= '</ul>';
                  document.getElementById('playlistWidgetDivId_'+o.id).innerHTML = s;
                  document.getElementById('playlistWidgetDivId_'+o.id).style.overflow = 'visible';
           }
          }
      }
  }
  function trackMenuHide(o) {
        if (o.color != undefined) document.getElementById('playlist'+o.rowid).style.backgroundColor = o.color;

        document.getElementById('playlistWidgetAId_'+o.id).style.display = "none";
        document.getElementById('playlistWidgetDivId_'+o.id).innerHTML = '';
        document.getElementById('playlistWidgetDivId_'+o.id).style.overflow = 'hidden';
        document.getElementById('playlistWidgetAId_'+o.id).className = "opacity track-list-tool";
        globalObject.playlistWidgetClickID = 0;
  }

  function topUserTool() {
      if (document.getElementById('TUMSelect').style.display == 'block') {
          document.getElementById('TUMSelect').style.display = 'none';
          document.getElementById('TUMPointer').className = 'opacity top-user-menu';
      } else {
          document.getElementById('TUMPointer').className = 'opacity top-user-menu active';
          document.getElementById('TUMSelect').style.display = 'block';
      }
  }

  function mwExpander(lid, fid) {
      document.getElementById(lid).style.display = 'none';
      document.getElementById(fid).style.display = 'block';
  }
