﻿/*---------------------------------------------------------------------------------------*/
//Hassan
function lyricsSearch(txt,chk)
{
   if(document.getElementById(chk).checked)
   {
        document.getElementById(txt).disabled =false;
       
   }
    else
    {
         document.getElementById(txt).disabled =true;
         document.getElementById(txt).value=""
    }
       
}

///////////////////////////////
function searchValidation(txtSingerID,txtSongID)
{
    if( document.getElementById(txtSingerID).disabled && document.getElementById(txtSongID).disabled)
    {
        showMessage("الرجاء إدخال الكلمة التي تبحثي عنها");
        return false;
    }
    
    if(!document.getElementById(txtSingerID).disabled && !document.getElementById(txtSongID).disabled)
    {
        return Req(txtSingerID,"الرجاء إدخال إسم المغني") && Req(txtSongID,"الرجاء إدخال إسم الأغنية");    
    }
   
    if( !document.getElementById(txtSingerID).disabled )
    {
        return Req(txtSingerID,"الرجاء إدخال إسم المغني");
    }
 
    if(!document.getElementById(txtSongID).disabled)
    {    
       return Req(txtSongID,"الرجاء إدخال إسم الأغنية");    
    }   
    return true;
}
/* Common Functions - Start */
function ctrl(ctrlID) /* get the control by search in all frames  */
{   
    for(var i=0 ; i < window.frames.length ; i++ )
    {
        try{
            if(ctrlID == window.frames[i].document.getElementById(ctrlID).id)
              return window.frames[i].document.getElementById(ctrlID);
        }catch(er){}
    }
    return document.getElementById(ctrlID); 
}
/*-----------------------------------------*/
function ctrlTop(ctrlID) /* get the control in the main frame  */
{    return top.document.getElementById(ctrlID); }
/*-----------------------------------------*/
function IsEmptyOrNull(strValue) /* check the value if Empty Or Null */
{ 
    if( strValue == null || strValue == 'undefined' || strValue == '' || strValue == '\t' || strValue == '\n' || strValue == '\r' )
        return true;
   
    try
    {
        while(strValue.indexOf(' ') != -1)
        {    strValue = strValue.replace(' ', ''); }
    }catch(er){}    
        
    if( strValue.length == 0)
        return true;
  
    return false;
}
/*-----------------------------------------*/
function selectDDl(ddlID,txt){ var ddl = document.getElementById(ddlID); if(ddl.selectedIndex == 0) { showMessage(txt); return false; } else { return true; } }
function Req(txtID,txt){ var inputtxt = document.getElementById(txtID);  if(inputtxt.value == '') { showMessage(txt,'',txtID); return false; } else { return true; } }
function EmailValue(txtID,txt){ var inputtxt = document.getElementById(txtID); var rx = new RegExp("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"); var matches = rx.exec(inputtxt.value); if (!(matches != null && inputtxt.value == matches[0])) {showMessage("الرجاء إدخال بريد إلكتروني صحيح",'',txtID);  inputtxt.focus();  return false; } else{ return true; } }
function EmailValueIFExist(txtID,txt){ var inputtxt = document.getElementById(txtID); if(inputtxt.value!='') {  var rx = new RegExp("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");	  var matches = rx.exec(inputtxt.value);  if (!(matches != null && inputtxt.value == matches[0])){showMessage(txt,'',txtID);  inputtxt.focus();  return false; } else{return true;} } else {return true;} }
function RemoveURL(txtId){ var txt=document.getElementById(txtId); var strNewURL = txt.value; if(strNewURL.indexOf("www.") != -1 || strNewURL.indexOf(".com") != -1 || strNewURL.indexOf(".in") != -1 || strNewURL.indexOf(".net") != -1 || strNewURL.indexOf(".org") != -1 || strNewURL.indexOf(".info") != -1 || strNewURL.indexOf(".biz") != -1 || strNewURL.indexOf(".us") != -1 || strNewURL.indexOf(".ws") != -1 || strNewURL.indexOf(".cc") != -1 || strNewURL.indexOf(".bz") != -1 || strNewURL.indexOf(".tv") != -1 || strNewURL.indexOf(".cn") != -1 || strNewURL.indexOf(".mobi") != -1 || strNewURL.indexOf(".ag") != -1 || strNewURL.indexOf(".sc") != -1 || strNewURL.indexOf(".la") != -1 || strNewURL.indexOf(".eu") != -1 || strNewURL.indexOf(".am") != -1 || strNewURL.indexOf(".fm") != -1 || strNewURL.indexOf(".ac") != -1 || strNewURL.indexOf(".io") != -1 || strNewURL.indexOf(".sh") != -1 || strNewURL.indexOf(".gs") != -1 || strNewURL.indexOf(".travel") != -1 || strNewURL.indexOf(".tl") != -1 || strNewURL.indexOf(".nf") != -1 || strNewURL.indexOf(".ki") != -1 || strNewURL.indexOf(".im") != -1 ) {showMessage("لا يمكنك ادخال موقع الكتروني", txtId);return false; } else { return true; } }

function ShowHide(pass)
{
	var t = document.getElementById(pass);
	var d = t.style.display;

	if ("block"==d ) 
	{
		Hide(pass) 
	}
	else
	{
	Show(pass)
	}
}

function Hide(pass)
{
	document.getElementById(pass).style.display='none'; 
}

function Show(pass)
{
	document.getElementById(pass).style.display='block';
}

    
function CheckComment(btnID,txtEmailID,txtNameID, txtCommentID)
{
    var boolValid = true;
    
    ctrl_txtCommentID = ctrl(txtCommentID);
       
    if (IsEmptyOrNull(ctrl_txtCommentID.value))
    {
        ctrl_txtCommentID.value = "";
        boolValid = false;
    }
    
    ctrl_txtNameID = ctrl(txtNameID);
       
    if ( boolValid == true &&  IsEmptyOrNull(ctrl_txtNameID.value))
    {
        ctrl_txtNameID.value = "";
        boolValid = false;
    }
    
    if ( boolValid == true && (! CheckEmailInputComment(txtEmailID)) )
    { 
        boolValid = false;
    }
     
    if(boolValid)
    {
        ctrl(btnID).disabled = true;
        GetPostBackComent();
    }
    else
    {
        ctrl(btnID).disabled = false;
    }
    
}


function CheckEmailInputComment(txtID)
{
    var objTxt = document.getElementById(txtID)
    if(objTxt.value=="")
    {
        return false;
    }
   
    var rx = new RegExp("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
    var matches = rx.exec(objTxt.value);
    if (!(matches != null && objTxt.value == matches[0]))
    { 
        return false;
    }
    checkInjection(txtID);
    
     return true;
}
    

    var fadeVal=100;
    var turn=1;
    var imgsNum=4;
    var flip=1;
    var imgPaths = new String();//;"http://helwa.maktoob.com/HelwaImages/Articles/d4af3e13-3d2b-4604-8ee3-09062fb25e9d/1l.jpg,http://helwa.maktoob.com/HelwaImages/Articles/19d4cf59-29cc-4544-ac3b-0ae2754fb8b1/1l.jpg,http://helwa.maktoob.com/HelwaImages/Articles/93e194dc-4466-48b5-b1ef-73518bdb2877/1l.jpg");
    var strHeader = new String();
    var strIntro = new String();
    var strPrefix = new String();
    var strRefId = new String();
    var playStatus="Play";
    var Playtimer;
    function FeatureImgPrepareData(strImgs,Header,Intro,Prefix,RefIDs)
    {
        imgPaths=strImgs;
        strHeader=Header;
        strIntro=Intro;
        strPrefix=Prefix;
        strRefId=RefIDs;
        //alert(strRefId);
        btnplay();
    }
    function MoveImgNext()
    {
        if(parseInt(fadeVal,10)>0)
        {
            document.getElementById("HeadHolder").innerHTML ="<a href='Article" + strRefId.split("%sep%")[turn] + "-.htm'>" + strHeader.split("%sep%")[turn] + "</a>";
            document.getElementById("LinkFeature").innerHTML ="<a href='Article" + strRefId.split("%sep%")[turn] + "-.htm'>" + "...المزيد</a>";
            
            document.getElementById("IntroHolder").innerHTML = strIntro.split("%sep%")[turn];
            fadeVal = fadeVal - 5;
            document.getElementById(strPrefix + flip).style.filter="alpha(opacity=" + fadeVal + ")";
            document.getElementById(strPrefix + flip).style.MozOpacity=fadeVal/100;
            setTimeout("MoveImgNext()",100);
        }
        else
        {
           if(turn==imgPaths.split("%sep%").length-1)
           turn=0;
           else
           turn=turn+1; 
           document.getElementById(strPrefix + flip).src=imgPaths.split("%sep%")[turn];
           document.getElementById(strPrefix + flip).style.zIndex=0;
           document.getElementById(strPrefix + flip).style.filter="alpha(opacity=100)";
           document.getElementById(strPrefix + flip).style.MozOpacity=100;
           if(flip==1)
                flip=2;
           else
                flip=1;
           fadeVal=100;
           document.getElementById(strPrefix + flip).style.zIndex=2;
        }
    }
    function btnNext_click()
    {
        document.getElementById("btnPlay").src="images/plyBtn.gif";
        playStatus="Pause";
        clearTimeout(Playtimer);
        MoveImgNext();
    }
    function btnPrev_Click()
    {
        document.getElementById("btnPlay").src="images/plyBtn.gif";
        playStatus="Pause";
        clearTimeout(Playtimer);
        if(parseInt(fadeVal,10)>0)
        {
            fadeVal = fadeVal - 5;
            document.getElementById(strPrefix + flip).style.filter="alpha(opacity=" + fadeVal + ")";
            setTimeout("MoveImgNext()",100);
        }
        else
        {
           if(turn==1)
           turn=imgPaths.split("%sep%").length-1;
           else
           turn=turn-1;
           document.getElementById(strPrefix + flip).src=imgPaths.split("%sep%")[turn];
           document.getElementById(strPrefix + flip).style.zIndex=0;
           document.getElementById(strPrefix + flip).style.filter="alpha(opacity=100)";
           if(flip==1)
                flip=2;
           else
                flip=1;
           fadeVal=100;
           document.getElementById(strPrefix + flip).style.zIndex=2;
        }
    }
    
    function btnplay()
    {
        //document.getElementById("btnPause").style.display ="block";
        if(document.getElementById("btnPlay").src.indexOf("images/plyBtn.gif") > -1)
        {
            document.getElementById("btnPlay").src="images/PauseBtn.gif";
            playStatus="Play";
            play();
        }
        else
        {
            
            document.getElementById("btnPlay").src="images/plyBtn.gif";
            playStatus="Pause";
            clearTimeout(Playtimer);
        }
    }
    function play()
    {
         if(playStatus=="Play")
        {
            MoveImgNext();
            Playtimer =  setTimeout("play()",4000);
        }
    }
    function Close_Form()
	{
		document.getElementById('regform1').style.display="none";
	}
	function show_From()
    {
	    document.getElementById('regform1').style.display="block";
}
function ClearForm()
{
        var elements = document.forms[0];
        for (var i = 0; i < elements.length; ++i)
        {
            var e = elements[i];
            if (e.type == "checkbox")
            e.checked = false;
            if (e.type == "text" || e.type == "password" )
            e.value = "";
        }
} 
function ShowHide(pass)
{
	var t = document.getElementById(pass);
	var d = t.style.display;

	if ("block"==d ) 
	{
		Hide(pass);
	}
	else
	{
	Show(pass);
	}
}

function Hide(pass)
{
	document.getElementById(pass).style.display='none'; 
}

function Show(pass)
{
	document.getElementById(pass).style.display='block';
}

//--------------------------------------------------------
function taLimit(link) {
	if (link.value.length==link.maxLength*1) return false;
}

function taCount(link, visCnt, intMaxLen) { 
    if (link.value.length > intMaxLen)
	{
	    link.value = link.value.substring(0, intMaxLen);
	}
	
	var mySpan =document.getElementById(visCnt);
	mySpan.innerHTML = intMaxLen - link.value.length;
	
}

function show_menu(pass)
{
    var totalOffset=0;
    document.getElementById(pass).style.display='block';

}
function hide_menu(pass)
{
    document.getElementById(pass).style.display='none';

}
function mailValidate(obj)
	{
		var ValidateResult3 = document.getElementById("ValidateResult3");
		ValidateResult3.className = "lfont9 red";
		txt_mail=document.getElementById(obj);
		if(txt_mail.value=="")
		{
				ValidateResult3.innerHTML="(Enter your email)";
				return false;
		}
		else
		{
			var rx = new RegExp("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
            var matches = rx.exec(txt_mail.value);
            if (!(matches != null && txt_mail.value == matches[0]))
            { 
				ValidateResult3.innerHTML="(Enter a valid email)";
				return false;
			}
			else 
			{
			    return true;
			}
		}
	}
function LetterSub(txtID,regxID)
{
    var objTxt = document.getElementById(txtID);
    if(objTxt.value=="")
    {
        showMessage("الرجاء إدخال البريد الإلكتروني");
        return false;
    }
    
    var rx = new RegExp("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
    var matches = rx.exec(objTxt.value);
    if (!(matches != null && objTxt.value == matches[0]))
    { 
        showMessage("الرجاء إدخال بريد إلكتروني صحيح");
        return false;
    }
    checkInjection(txtID);
    self.location.href="Alert-" + objTxt.value + ".htm";

}
var strType ="self";
     
    function ClearAllTabsStyles(strTempExt)
    {
        document.getElementById(strTempExt + "tab_self").className ="";
        document.getElementById(strTempExt + "tab_maktoob").className ="";
        document.getElementById(strTempExt + "tab_internet").className  ="";
    }
     
    function SetTabStyle(link)
    {
      var strTempName = link.substring(link.search("tab_"));
      var strTempExt = link.substring(0,link.search("tab_"));
     
      
       ClearAllTabsStyles(strTempExt);
       document.getElementById(link).className  ="on"; 
       
      
       switch(strTempName)
       {
         case "tab_self":
          strType = "self";
            break;
        
        case "tab_maktoob":
          strType = "maktoob";
            break;
            
         case "tab_internet":
          strType = "internet";
            break;
       }
       
    }
    
     function GoSearch(txtID, SitePath)
     {
      try{       
        Ctrl_txtID = document.getElementById(txtID);
        var tempValueCtrl= Ctrl_txtID.value;
       }catch(err)
       {
        Ctrl_txtID = txtID;
       }
       
        if (Ctrl_txtID.value == "")
        {
            showMessage('يجب ان تملاء حقل البحث');
            
        }else
        {
            window.location = SitePath + "SearchResults.aspx?Key=" + decodeURI(Ctrl_txtID.value)  + "&SearchType=" + strType;
        }
     }
     
       function GoSearchYahoo(txtID)
     {
      try{       
        Ctrl_txtID = document.getElementById(txtID);
        var tempValueCtrl= Ctrl_txtID.value;
       }catch(err)
       {
        Ctrl_txtID = txtID;
       }
                     
        if (Ctrl_txtID.value == "")
        {
            showMessage('يجب ان تملأ حقل البحث','', txtID);          
        }else
        {
      
          var strYahooSearch ;
          var strKey = encodeURI(Ctrl_txtID.value) ;
          var frCode = "mt-47" ;
           
          if(strType == "internet")
             {strYahooSearch = "http://maktoob.search.yahoo.com/search?fr=" + frCode + "&q=" + strKey ;}
          if(strType == "self")
             {strYahooSearch = "http://maktoob.search.yahoo.com/search?fr=" + frCode + "&p=" + strKey + "&vs=under20.maktoob.com"; }
          if (strType == "maktoob")
             {strYahooSearch = "http://maktoob.search.yahoo.com/search?fr=" + frCode + "&p=" + strKey + "&vs=maktoob.com"; }
         window.location = strYahooSearch;
        }
        
     }
     
     function SetValueAndTabStyle(strKey, txtID ,link){ SetTabStyle(link); try{ Ctrl_txtID = document.getElementById(txtID);  var tempValueCtrl= Ctrl_txtID.value; }catch(err) {  Ctrl_txtID = txtID; } Ctrl_txtID.value = strKey; }
    function checkInjection(txtID)
    {
   
    var strText = new String();
    
     try{       
        Ctrl_txtID = document.getElementById(txtID);
        var tempValueCtrl= Ctrl_txtID.value;
       }catch(err)
       {
        Ctrl_txtID = txtID;
       }
       
        strText = Ctrl_txtID.value; 
   
        while(strText.indexOf("<") > -1 && strText.indexOf(">") > -1)
        {
            strText = strText.replace("<","");
            strText = strText.replace(">","");
        }
        
           while(strText.indexOf("<",0) != -1)
            {
                strText = strText.replace("<","&lt;");
            }
            
            while(strText.indexOf(">",0) != -1)
            {
                 strText = strText.replace(">","&gt;");
            }
            
        document.getElementById(txtID).value = strText;
         }
     
     function RemoveSpicalChars(txtID){ var strText = new String();  strText = trim(document.getElementById(txtID).value);
for(i=0;i<=strText.length;i++){strText = strText.replace("_","");strText = strText.replace("|","");strText = strText.replace(">"," ");strText = strText.replace("<"," ");strText = strText.replace("*",""); strText = strText.replace("%",""); strText = strText.replace("/",""); strText = strText.replace("\\",""); strText = strText.replace("#",""); strText = strText.replace("$",""); strText = strText.replace("^",""); strText = strText.replace("&",""); strText = strText.replace("!",""); strText = strText.replace("(",""); strText = strText.replace(")",""); strText = strText.replace("{",""); strText = strText.replace("}",""); strText = strText.replace("[",""); strText = strText.replace("]",""); strText = strText.replace(";",""); strText = strText.replace(":",""); strText = strText.replace(",",""); strText = strText.replace("\'",""); strText = strText.replace(".",""); strText = strText.replace("\"",""); strText = strText.replace("-",""); strText = strText.replace("~",""); strText = strText.replace("?",""); strText = strText.replace("=",""); strText = strText.replace("+",""); strText = strText.replace("@",""); strText = strText.replace("0","");} document.getElementById(txtID).value = trim(strText); }

     
    //------------------------------------------
     var calendar = null;
    function selected(cal, date)
    {
        cal.sel.value = date;
        if (cal.sel.id == "date")
            cal.callCloseHandler();
    }
    function hideDropDownList()
    {   
        var items = document.getElementsByTagName('select');
        var i=0;
        for (i=0;i<items.length;i++)
        {
             items[i].style.display = "none";
        }
   }
    
    
function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
    function showDropDownList()
    {   
        var items = document.getElementsByTagName('select');
        var i=0;
        for (i=0;i<items.length;i++)
        {
             items[i].style.display = "block";
        }
    }
    
    function checkSelectedAlerts(){
        alert('ok');
    
    }
 
 
 
 
 
 function clickButton(e, buttonid){ 

    var bt = document.getElementById(buttonid); //buttonid); 
	if (typeof bt == 'object'){ 
			if(navigator.appName.indexOf("Netscape")>(-1)){ 
				if (e.keyCode == 13){ 
						bt.click(); 
						return false; 
				} 
			} 
			if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
				if (event.keyCode == 13){ 
						bt.click(); 
						return false; 
				} 
			} 
	} 
	
} 

function AlertsSub(txtID,regxID,strURL)
{
    var objTxt = document.getElementById(txtID);
    if(objTxt.value=="")
    {
        showMessage("الرجاء إدخال البريد الإلكتروني");
        return false;
    }
  
    var rx = new RegExp("\\w+([-+.\']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
    var matches = rx.exec(objTxt.value);
    if (!(matches != null && objTxt.value == matches[0]))
    { 
        showMessage("الرجاء إدخال البريد الإلكتروني صحيح");
        return false;
    }
     return true;
} 
/////////////////////////
function gotoComments()
{
var txt1 = document.getElementById("ctl00_ContentPlaceHolderMid_ctl00_Comments1_txtComment");
if(txt1!=null)
{txt1.focus();}
}
/////////////////////////
function checkAllalert(chkID){ var chk = document.getElementById(chkID); if ( chk.checked == true ){ for (var i = 0; i < document.getElementsByTagName("input").length ; ++i){ if(document.getElementsByTagName("input")[i].type == "checkbox"){document.getElementsByTagName("input")[i].checked = true;} } } if ( chk.checked == false ){ for (var i = 0; i < document.getElementsByTagName("input").length ; ++i){ if(document.getElementsByTagName("input")[i].type == "checkbox"){document.getElementsByTagName("input")[i].checked = false;} } } }
////////////////////////
function checkOne()
{
var flag = false;
var checkname;
for (var i = 0; i < document.getElementsByTagName("input").length ; ++i)
{ 
if(document.getElementsByTagName("input")[i].type == "checkbox" && document.getElementsByTagName("input")[i].id.indexOf('chkLstSections') != -1 && document.getElementsByTagName("input")[i].checked == true )
flag = true;
} 
if(flag == false)
showMessage("الرجاء اختيار قناة على الأقل");

return flag
}
////////////////////////////////////
var cv;  /* Value of my cookie */  var myCookie; /* Name of my cookie */  var allCookies;  /* Gets all cookies */
function expireDate( nDays ) {/* nDays  // No. of days in future to expire */  var one_second = 1000 ;/* 1 sec = 1000 milliseconds */  var one_hour= 3600 * one_second;  var one_day = 24 * one_hour;  var expire  = new Date( (new Date()).getTime() + nDays*one_day);  return  expire.toGMTString(); /* Time to expire cookie */  }  
/*  Extracts 1st substring in 'myString' bounded by 'delim1' and 'delim2' */ /*  It is OK if the 'delim2' is missing */
function extractSubstring( myString, delim1, delim2 ) { var substr1 = myString.split( delim1 ); if ( substr1 == myString ) return -1 ; /* delim1 not found */ var substr2 = substr1[1].split( delim2 ); var len1 = substr1[0].length + delim1.length; var len2 = substr2[0].length; return myString.substring( len1, len1+len2 );} 
function StoreCookie( myCookie , cv,  nDays) { var cookie = myCookie + '=' + cv + '; expires=' + expireDate(nDays) ;  document.cookie = cookie;  }  
function ReadCookie( myCookie ) { allCookies = document.cookie;  return extractSubstring( allCookies, myCookie+'=', ';' ); } 
