var opic;
/*-------------------------------------------------------------------------*/
function restorepic(){
   document.getElementById('songCOVERIMAGETD').innerHTML=opic;
   setTimeout ( "do_AdInCoverImage_code()", 10000 );
}
/*-------------------------------------------------------------------------*/
function do_AdInCoverImage_code(){
    opic=document.getElementById('songCOVERIMAGETD').innerHTML;
    ln=document.getElementById('lang').value;

    tal="right";
    if (ln != "AR" ) {
       tal="left";
    }
    var g_news=new Array();
    g_news[0]='h';
    g_news[1]='w';    
    g_news[2]='b';
    g_news[3]='t';
    g_news[4]='el';
    g_news[5]='e';
    g_news[6]='s';
    var rn1=Math.floor(Math.random()*7);
    var rn2=Math.floor(Math.random()*7);
    if (rn1==rn2){
       rn2=Math.floor(Math.random()*7);
    }
    rn_c=g_news[rn1]+","+g_news[rn2];

    newsfeed="<iframe frameborder='0' align="+tal+" width='300px' height='250px' marginwidth='0' marginheight='0' ";
    newsfeed+="src='http://www.google.com/uds/modules/elements/newsshow/iframe.html?topic="+rn_c+"&rsz=large&hl="+ln+"&format=300x250'>";
    newsfeed+="</iframe>";

    t="<br><table border=0 align=center width=300px height=403px>";
    t+="<td style=text-align:center width=300 NOWRAP><strong>ضع أعلانك هنا </strong></td>";
    t+="<tr><td style=color:yellow;text-align:center width=300 NOWRAP><strong>(لا تنسَ أرسال كلمات اغاني للموقع) </strong></td>";
    t+="<tr><td style=text-align:"+tal+">";
    t+=newsfeed;
    t+="</table>"

    document.getElementById('songCOVERIMAGETD').innerHTML=t;
    setTimeout ( "restorepic()", 40000 );
}
/*-------------------------------------------------------------------------*/
function refHighQualitySongPic(HighQualityPicture) {
   if (HighQualityPicture != false) {
      document.getElementById('songCOVERIMAGE').src= HighQualityPicture;
   }
}
/*-------------------------------------------------------------------------*/
function do_get_high_quality_pic_of(songid) {
    x_get_high_quality_pic_of(songid, refHighQualitySongPic);
}
/*-------------------------------------------------------------------------*/

if (self != top) top.location.replace(self.location);  //Frame Buster

function do_show_artist_info(artistid, lang) {
   var url="/song_functions.htm?artistid="+artistid+"&lang="+lang+"&what=bio";
   newwin = window.open(url,'score_Page','top=10,left=50,width=750,height=700,resizable=yes,toolbar=no,menubar=no,status=yes,scrollbars=yes');
}

function do_show_musical_score(songmd, lang) {
   var url="/song_functions.htm?songmd="+songmd+"&lang="+lang+"&what=mso";
   newwin = window.open(url,'score_Page','top=10,left=50,width=750,height=700,resizable=yes,toolbar=no,menubar=no,status=yes,scrollbars=yes');
}
function do_print_lyrics(songmd, lang) {
   var url="/song_functions.htm?songmd="+songmd+"&lang="+lang+"&what=lyr";
   newwin = window.open(url,'score_Page','top=10,left=50,width=900,height=700,resizable=yes,toolbar=no,menubar=no,status=yes,scrollbars=yes');
}


/*------------------ Help -------------------- */
function helpPop(rootpath, anchor) {
    /* Add help button <a href='#' onclick='helpPop()'>Help</a> */
    url = rootpath+"/help_page.php#";
    if ( typeof anchor == 'undefined' ) {
        path = location.pathname;
        pathbits = path.split("/");
        file = pathbits[pathbits.length-1];
        if ( file == 'index.php' || file == '' || file == '#') {
            file = pathbits[pathbits.length-2] + "/index.php";
        }
        url += file;
    } else { url += anchor; }
    newwin = window.open(url,'Help_Page','top=440,left=50,width=900,height=420,resizable=yes,toolbar=no,menubar=no,status=yes,scrollbars=yes');
    if ( !newwin.opener ) newwin.opener = self;
}

/*-----------------------------------------*/
function UpdateStars(html) {
   document.getElementById('ScoreStarsSpan').innerHTML=html;
}


//-------------------------------------------------------
//Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row:
var highlightbehavior="TR"
var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
  /*return;*/
  source=ie? event.srcElement : e.target
  if (source.tagName=="TABLE")
    return
  while(source.tagName!=highlightbehavior && source.tagName!="HTML" )
     source=ns6? source.parentNode : source.parentElement
  if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore") {
      source.style.backgroundColor=highlightcolor;
  }
}
//----------------------------------------------------------------------------------------
function contains_ns6(master, slave) { //check if slave is contained by master
    while (slave.parentNode)
       if ((slave = slave.parentNode) == master)
         return true;
    return false;
}
//--------------------------------------------------------------------------------------
function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
  return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
  return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
  source.style.backgroundColor=originalcolor
}
//----------------------------------------------------------------------------------------
function switchLang(formname,lang) {
     document.getElementById('lang').value=lang;
     callme.lang.value=lang;
     callme.submit();
}
//----------------------------------------------------------------------------------------
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";

        // check if cookies are enabled.
        var c_sts=document.cookie.indexOf(name);
        if (c_sts == -1) {
            st="Cookies are not enabled. Check <a target =_blank href='http://help.expedient.com/browsers/cookies.shtml'>here</a>";
            //document.write(st);
            return -1;
        }else{
            return 1;
        }
}
//----------------------------------------------------------------------------------------
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 eraseCookie(name) {
	createCookie(name,"",-1);
}
/*-----------------------------------------------------------------------------*/
function refresh_win(limit){
   if (document.images){
        var parselimit=limit.split(":")
        parselimit=parselimit[0]*60+parselimit[1]*1
   }
   if (parselimit==1)
             window.location.reload()
   else{
             parselimit-=1
             curmin=Math.floor(parselimit/60)
             cursec=parselimit%60
             if (curmin!=0) {
                  curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
             }else{
                  curtime=cursec+" seconds left until page refresh!"
             }
             nxtlimit=curmin+":"+cursec;
        window.status=curtime
        setTimeout("refresh_win(\""+nxtlimit+"\")",1000)
   }
}

var NextFuncTimer=-1;
/*-----------------------------------------------------------------------------*/
/*  Call another function periodically writing comments in status line */
/*-----------------------------------------------------------------------------*/
function bgPeriodicCallFunc(bglimit,origlimit,  funcName){
        //if (NextFuncTimer == -1 )
           //eval(funcName+"()");
        if (document.images){
            var parsebglimit=bglimit.split(":")
            parsebglimit=parsebglimit[0]*60+parsebglimit[1]*1
            curmin=Math.floor(parsebglimit/60)
            cursec=parsebglimit%60
            nxtbglimit=curmin+":"+cursec;
        }else
            return

        if (parsebglimit<=1) {
            eval(funcName+"()");
            NextFuncTimer=setTimeout("bgPeriodicCallFunc(\""+origlimit+"\",\""+origlimit+"\", \""+funcName+"\")",1000)
        } else{
             parsebglimit-=1
             curmin=Math.floor(parsebglimit/60)
             cursec=parsebglimit%60
             if (curmin!=0)
                  curtime=curmin+" minutes and "+cursec+" seconds left";
             else
                  curtime=cursec+" seconds left";
             //window.status=curtime;
             nxtbglimit=curmin+":"+cursec;
             NextFuncTimer=setTimeout("bgPeriodicCallFunc(\""+nxtbglimit+"\",\""+origlimit+"\",\""+funcName+"\")",1000)
        }
}
/*-----------------------------------------------------------------------------*/
/*  Call another function periodically without writing comments in status line */
/*-----------------------------------------------------------------------------*/
function bgPeriodicCallFuncNoSts(limit,  funcName){
        if (document.images){
            var PL=limit.split(":")
            PL=PL[0]*60+PL[1]*1
            curmin=Math.floor(PL/60)
            cursec=PL%60
            milli=curmin*60*10000+cursec*1000;

            eval(funcName+"()");
            NextFuncNoStsTimer=setTimeout("bgPeriodicCallFuncNoSts(\""+limit+"\",\""+funcName+"\")", milli)
        }else
            return
}
/*-----------------------------------------------------------------------------*/
/*    SEARCH FOR TEXT AND MARK IT ---*/
<!--
var TRange=null

function findString (str) {
 str
 if (parseInt(navigator.appVersion)<4) return;
 var strFound;
 if (navigator.appName=="Netscape") {
  // NAVIGATOR-SPECIFIC CODE
  strFound=self.find(str);
  if (!strFound) {
   strFound=self.find(str,0,1)
   while (self.find(str,0,1)) continue
  }
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {

  // EXPLORER-SPECIFIC CODE

  if (TRange!=null) {
   TRange.collapse(false)
   strFound=TRange.findText(str)
   if (strFound) TRange.select()
  }
  if (TRange==null || strFound==0) {
   TRange=self.document.body.createTextRange()
   strFound=TRange.findText(str)
   if (strFound) TRange.select()
  }
 }
 if (!strFound) alert ("String '"+str+"' not found!")
}
//-->
/*------------------------- ANOTHER SEARCH with Highlight */
var ntimes=0;

function hex( n ) { 
   if ( n < 16 )
     var x='0'
   else
    var x=''
   return x + n.toString(16); 
}
function highlight(t, el) { 
  if (!t) return; 

  if (/^\s*$/.test(t)) return; 
  var p="gi";  /* case insensitive g=sensitive*/
  var r = new RegExp(t.split(/\s+/).join('|'), p);  /* sentence */
  //var r = new RegExp(t, p); 
  var s = [el||document.documentElement||document.body]; 

  var h = document.createElement('span'), i = 0, e, j, l, o, k,n=0; 
  //h.style.backgroundColor = '#ffffff'; 
  h.style.color = 'black'; 
  h.style.backgroundColor = '#'+( ntimes%2 ? ''+hex(((ntimes+1)%5)*51)+'ff' : 'ff'+hex((ntimes%5)*51)+'' )+'00';
  ntimes++;



  do { 
    e = s[i]; 
    if (e.nodeType == 3) { 
      r.lastIndex = 0; 
      l = r.exec(e.nodeValue); 
      if (l != null) { 
        k = l[0].length; 
        if (r.lastIndex > k) { 
          e.splitText(r.lastIndex-k); 
          e = e.nextSibling; 
        } 
        if (e.nodeValue.length > k) { 
          e.splitText(k); 
          s[i++] = e.nextSibling; 
        } 
        o = h.cloneNode(true); 
        o.appendChild(document.createTextNode(l[0]));
        n++; 
        e.parentNode.replaceChild(o, e); 
      } 
    } else { 
      j = e.childNodes.length; 
      while (j) s[i++] = e.childNodes.item(--j); 
    } 
  } while(i--); 
return n;

} 
/*---------------------------------------------------*/
function unhighlight( s, o ) {
 var d = window.document;
 s = s.replace(/([\\|^$()[\]{}.*+?])/g, '\\$1').split( /\s+/ ).join( '|' );
 o = o || d.documentElement || d.body;
 var a = o.getElementsByTagName( 'span' ), i = a.length, j,
  re = new RegExp( '^' + s + '$', 'i' );
 while( i-- ) {
  j = a[i].firstChild;
  if( j ) {
   if( j.nodeType===3 % re.test( j.nodeValue ) ) {
    a[i].parentNode.replaceChild( d.createTextNode( j.nodeValue ), a[i] );
   }
  }
 }
 return false;
}

















/*--------------------------------------------------*/
function getDocumentWidth () {
   if (document.all) {
        return document.body.offsetWidth 
   } else{   
        return window.innerWidth;
   }
}
/*--------------------------------------------------*/
function getDocumentHeight () {
   if (document.all) {
        return document.body.offsetHeight 
   } else{   
        return window.innerHeight;  
   }     
}
/*----------------------------------------------------*/
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  scrOfX=f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
  scrOfY =f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);

  return [ scrOfX, scrOfY ];
}
/*----------------------------*/
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
/*----------------------------*/
function getBrowserDims() {
     var intH = 0;
     var intW = 0;
     intW=f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
     intH=f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
     var scroll=getScrollXY() ;
     return { width: parseInt(intW+scroll[0]), height: parseInt(intH+scroll[1]) };
}  
/*----------------------------*/
function setLayerPosition() {

     if (document.getElementById("shadow")) {
        var shadow = document.getElementById("shadow");
     }
     if (document.getElementById("question")) {
       var question = document.getElementById("question");
     }

     if (document.getElementById("shadow")) {

       var bws = getBrowserDims();
       shadow.style.width = bws.width + "px";
       shadow.style.height = bws.height + "px";
     }

     if (document.getElementById("question")) {
       question.style.left = parseInt((bws.width - 350) / 2);
       question.style.top = parseInt((bws.height - 200) / 2);
     }
     if (document.getElementById("ALLDOC") ) {
        var H=document.getElementById("ALLDOC").offsetHeight;
        var W=document.getElementById("ALLDOC").offsetWidth;
     }

     if (document.getElementById("shadow")) {
     
        shadow.style.width = W+ "px";
        shadow.style.height = H+ "px";

        shadow = null;
     }
     if (document.getElementById("question")) {
        question = null;
     }
}
/*------------------------------------------------------------*/

function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';                          
  } else {
     dark.style.display='none';
  }
}
/*------------------------------------------------------*/
function windowHeight(){
if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  return window.innerHeight-16;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  return document.body.offsetHeight-20;
 }
}
}
/*------------------------------------------------------*/
function windowWidth(){
if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  return window.innerWidth-16;
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  return  document.body.offsetWidth-20;
 }
}

}
/*------------------------------------------------------*/
function My_Tip(msg ){
  var ns6=document.getElementById&&!document.all;
  var ie=document.all;

  //if (ns6){
    //UnTip();
    //return   Tip(msg, TEXTALIGN,'center', OPACITY,98, CENTERMOUSE,true,OFFSETX, 0);
  //}
  nd();

//#F5DEB3
  return overlib(msg,TEXTSIZE,'12px',FGCOLOR, '#98AFC7', VAUTO,HAUTO,CENTER, ABOVE);
}
/*------------------------------------------------------*/
function My_UnTip(){
  var ns6=document.getElementById&&!document.all;
  var ie=document.all;

  //if (ns6) {
    // return UnTip();
  //}
  return nd();
}
/*------------------------------------------------------*/
/*#736F6E  6D7B8D*/
function My_lyric_Tip(msg){
  var ns6=document.getElementById&&!document.all;
  var ie=document.all;

  var W=windowWidth()-50;
  var H=windowHeight()-50;


  if (ns6){
     UnTip();
     return  Tip(msg,TEXTALIGN,'center', OPACITY,98, OFFSETX, 0,HEIGHT,-H,WIDTH,-W,CLOSEBTN,true,STICKY,true,FADEIN,100,FADEOUT,100,DURATION,60000,BORDERCOLOR,'#000000', SHADOW,true,SHADOWCOLOR,'#EBDDE2',SHADOWWIDTH,20,ABOVE,true ,BGCOLOR,'#150517',CENTERWINDOW, true, CENTERALWAYS, true,OPACITY,95);
  }
  nd();
  overlib(msg,FGCOLOR, '#150517', HEIGHT,H-100,BORDER,4,TEXTSIZE,14,RELX,500,RELY,0, CLOSECLICK, TIMEOUT, 60000,  STICKY,CAPTION,'Lyrics', DELAY,100, WRAP,100)
}
/*------------------------------------------------------*/

function returnDocument() {
    var file_name = document.location.href;
    var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
    return file_name.substring(file_name.lastIndexOf("/")+1, end);
}
/*------------------------------------------------------*/
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
 		 return true					
}
/*------------------------------------------------------*/
function getClientDateTime() {
  var today=new Date();
  var Y=today.getFullYear();
  var M=1+today.getMonth();
  var D=today.getDate();
  var h=today.getHours();
  var m=today.getMinutes();
  var s=today.getSeconds();

  return( Y+"-"+M+"-"+D+" "+h+":"+m+":"+s);
}
/*------------------------------------------------------*/
function CountLeft(txtid, limitid,max) {
 var field=document.getElementById(txtid).value;
 var len = field.length;
 if(len > max){
        CutText = field.substring(0,max);
        document.getElementById(txtid).value=CutText;
        return false;
 }
 document.getElementById(limitid).value=max-len;
}
/*------------------------------------------------------*/
function OverPicZoomAlbum(pic) {
var newImg = new Image();
newImg.src = pic;
if(newImg.height > 500 ) newImg.height=500;
if(newImg.width  > 400 ) newImg.width=400;
var Hi = newImg.height;
var Wi = newImg.width;
     overlib('',WIDTH,Wi,HEIGHT,Hi,ABOVE,HAUTO,VAUTO,FGBACKGROUND,pic);
}