﻿function managtab_click(obj,myid)
{
    var count=obj.parentNode.childNodes.length;
    for(var i=0 ;i<count;i++)
    {
    try{
        obj.parentNode.childNodes[i].className='tab2';
    }catch(e){}
    
    }
    obj.className='atab2';
       
    var response=aj.get_manag_subtabs(myid);
    document.getElementById('sublinks').innerHTML=response.value;
    if(document.getElementById('sublinks').childNodes[0]!=null)
    {
    eval(document.getElementById('sublinks').childNodes[0].href);
    }else
    {
        manage_get_arts(myid);
    }
}


function hi(obj,indx)
{

var qqq=obj.parentNode;
for(var i=0;i<qqq.childNodes.length;i++)
{
    try{
    qqq.childNodes[i].className='subtaba';
    }catch(e){}   
}

obj.className='subtabaselected';


var sss=obj.parentNode.parentNode.parentNode.parentNode.childNodes[2].childNodes[0];

for(var i=0;i<sss.childNodes.length;i++)
{
    sss.childNodes[i].style.display='none';
}
sss.childNodes[indx].style.display='';


}
function manage_get_arts(myid)
{
    var response=aj.get_manag_arts(myid);
    document.getElementById('mainarts').innerHTML=response.value;
}

function pausescroller(content, divId, divClass, delay){
this.content=content ;
this.tickerid=divId ;
this.delay=delay ;
this.mouseoverBol=0 ;
this.hiddendivpointer=1 ;
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) 
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent)
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) 
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}


pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

function show_mailing_div()
{
    if(document.getElementById('FloatSlideShow'))
    {
        document.getElementById('FloatSlideShow').style.display='';
    }
}

function hide_mailing_div()
{
    if(document.getElementById('FloatSlideShow'))
    {
        document.getElementById('FloatSlideShow').style.display='none';
    }
}
function subscrib_mailing_div(add)
{
    var email= document.getElementById('mailing_email').value; //
	email = email.replace(/^\s*|\s*$/g,"");
	if ( email != '')
	{
		
		if ( emailCheck(email))
		{
			document.getElementById('mailing_email').value = '';
			if(add)
			{
			    url = 'http://mail.islammemo.cc/MailingList/mailing_list.asp?mode=add&email=' + email;
			}else{
			    url ="http://mail.islammemo.cc/MailingList/mailing_list.asp?mode=delete&email=" + email;
			}
			window.open(url ,'AddMyEmail','resizable=no,left=' + (window.document.body.offsetWidth-450)/2 + ',top=' + (window.document.body.offsetHeight-150)/2 + ',width=450,height=150');
            hide_mailing_div();
		}else{alert('البريد غير صحيح');}
	}else{alert('ادخل عنوان البريد الإلكترونى')}
}


function lens_change(url,name,disc)
{
    setOpacity(document.getElementById('lens_main_img'), 0);
    document.getElementById('lens_main_img').src=url;
    document.getElementById('lens_main_disc').innerHTML=disc;
}
function setOpacity(obj, opacity)
{
  opacity = (opacity == 100)?99.999:opacity;
  obj.style.filter = "alpha(opacity:"+opacity+")";
  obj.style.KHTMLOpacity = opacity/100;
  obj.style.MozOpacity = opacity/100;
  obj.style.opacity = opacity/100;
}

function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	return false
}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
    return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
		return false
	    }
    }
    return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   return false
}
if (len<2) {
   alert(errStr)
   return false
}
return true;
}
function ChangeQueryStringValue(action,qsname,qsvalue)
{
    	if (action.indexOf('?') == -1 )	 //If no querystring present
    	{
    		return (action+"?"+qsname+"="+UrlEncode(qsvalue)); //x.asp?Name=Peter+Paul
    	}
    	else
    	{		
    		if ( (action.indexOf("?"+qsname+"=") == -1 ) && (action.indexOf("&"+qsname+"=") == -1 ) ) //Passed querystring not already present		

        	{
        			return (action+"&"+qsname+"="+UrlEncode(qsvalue)); //x.asp?Age=25&Name=Peter+Paul;
        	}
        	else //Passed Querystring already present, replace it no matter if it is ?Name= or &Name=
            {
            			var replaceQSPrefix=(action.indexOf("?"+qsname+"=")==-1)?"&"+qsname+"=":"?"+qsname+"=";
            			var replaceQSSuffix=""; //This will be John in case of ?Name=John or &Name=John 
            			startpos=action.indexOf(replaceQSPrefix);
            			
            			for (a=(startpos+replaceQSPrefix.length);a<action.length;a++)
                			{
                				if ( action.charAt(a)=='&' ) //Next querystring beginning
                					break;
                				else
                					replaceQSSuffix += action.charAt(a);
                			}
                			newaction=action.replace(replaceQSPrefix+replaceQSSuffix,replaceQSPrefix+UrlEncode(qsvalue));
                			return newaction;
                		}	
                	}		
}
function UrlEncode(text) 
{		
                	text=ReplaceAll(text, "?", "%3F");
                	text=ReplaceAll(text, "=", "%3D");
                	text=ReplaceAll(text, "&", "%26");
                	text=ReplaceAll(text, " ", "+");
                	text=ReplaceAll(text, ",", "%2c");	
                	
                	return text;
}
function ReplaceAll(varb, replaceThis, replaceBy)
{	
                	newvarbarray=varb.split(replaceThis);
                	newvarb=newvarbarray.join(replaceBy);	
                	return newvarb;
}

 function changestyle(aa)
 {
    setActiveStyleSheet(aa);
    switch(aa)
    {
        case 1:
        aa="01";
        break;
        case 2:
        aa="02";
        break;
        case 3:
        aa="03";
        break;
        case 4:
        aa="04";        
        break;
    }
     document.getElementById(poll_client_id).src=ChangeQueryStringValue(document.getElementById(poll_client_id).src,"style",aa.toString());
    
 }
 
 function show_color_div()
{
    if(document.getElementById('floatchoosecolor'))
    {
        document.getElementById('floatchoosecolor').style.display='';
    }
}

function hide_color_div()
{
    if(document.getElementById('floatchoosecolor'))
    {
        document.getElementById('floatchoosecolor').style.display='none';
    }
}
 
 