/***********************************************
You May Edit the following Menue
***********************************************/

//Contents for menu 1
var otherLinks = new Array()
otherLinks[0]='<a class="Menu9" href="' + PathPre + 'about-en/index.php"><span>For English </span></a></span>'
otherLinks[1]='<a class="Menu10" href="' + PathPre + 'media/ar.php"><span>صوتيات و مرئيات</span></a></span>'
//otherLinks[1]='<a class="Menu10" href="' + PathPre + 'links/nasheed/index.php"><span>دوحة النشـيد </span></a></span>'
//otherLinks[2]='<a class="Menu11" href="' + PathPre + 'links/photos/index.php"><span>حديث الصور</span></a></span>'
otherLinks[2]='<a class="Menu12" href="' + PathPre + 'links/sites/index.php"><span>مواقع إسلامية</span></a></span>'
otherLinks[3]='<a class="Menu13" href="' + PathPre + 'links/gb/index.php"><span>سجل الزوار</span></a></span>'
otherLinks[4]='<a class="Menu14" href="' + PathPre + 'links/contact/index.php"><span>اتصـل بنـا </span></a></span>'
otherLinks[5]='<a class="Menu30" href="' + PathPre + 'links/search/index.php"><span>بحث</span></a></span>'

var enOtherLinks = new Array()
enOtherLinks[0]='<a class="Menu6" href="' + PathPre + '"><span>عربي </span></a></span>'
enOtherLinks[1]='<a class="Menu7" href="' + PathPre + 'media/en.php"><span>Media</span></a></span>'
//enOtherLinks[1]='<a class="Menu7" href="' + PathPre + 'links/nasheed/index.php?Lang=en"><span>Nasheed Island </span></a></span>'
//enOtherLinks[2]='<a class="Menu8" href="' + PathPre + 'links/photos/index.php?Lang=en"><span>Photo Talk</span></a></span>'
enOtherLinks[2]='<a class="Menu9" href="' + PathPre + 'links/sites/index.php?Lang=en"><span>Islamic Sites</span></a></span>'
enOtherLinks[3]='<a class="Menu10" href="' + PathPre + 'links/gb-en/index.php"><span>Guest Book</span></a></span>'
enOtherLinks[4]='<a class="Menu11" href="' + PathPre + 'links/contact-en/index.php"><span>Contact Us</span></a></span>'
enOtherLinks[5]='<a class="Menu31" href="' + PathPre + 'links/search/index.php?Lang=en"><span>Search</span></a></span>'

var menuwidth='180px' //default menu width
var menubgcolor='#D9ECCE'  //menu bgcolor
var disappeardelay=100  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?
var lastSMEvt = null;
var dropmenuobj = null;
var delayhide = null;
var doHideMenu = true;
var hideMain = true;
/*******************************************************/
/////No further editting needed
/*******************************************************/
var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
{
document.write('<div id="dropmenudiv" style="Filter:revealTrans(duration=0.3, transition=12);visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="hideMain = false; clearhidemenu()" onMouseout="hideMain = true; dynamichide(event)"></div>')
document.write('<div id="dropmenudiv2" style="Filter:revealTrans(duration=0.3, transition=12);visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="hideMain = false" onMouseout="doHideMenu = true"></div>')
}

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth, divid){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}


if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
if(divid == null)
	divid = 'dropmenudiv';
else
{
	if(lastSMEvt != null)
		if(lastSMEvt.type == e.type)
			return false;
	lastSMEvt = e;
}
if(ie4)document.all[divid].filters[0].Apply();
obj.visibility=visible
if(ie4)document.all[divid].filters[0].Play();
else if (e.type=="click"){
	if(ie4)document.all[divid].filters[0].Apply();
	obj.visibility=hidden
	if(ie4)document.all[divid].filters[0].Play();
}
return true;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth, divid){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()

clearhidemenu();

if(divid == null || divid == "dropmenudiv")
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
else
	dropmenuobj=document.getElementById? document.getElementById(divid) : document.all[divid];

populatemenu(menucontents)

if (ie4||ns6){
w = (divid != null && divid != "dropmenudiv") ? menuwidth : (parseInt(menuwidth) + 30) + "px";
showhide(dropmenuobj.style, e, "visible", "hidden", w, divid)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
menuleftoffset = (divid != null && divid != "dropmenudiv") ? 70 : 0;
menutopoffset = (divid != null && divid != "dropmenudiv") ? -5 : 0;
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+menuleftoffset+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+menutopoffset+obj.offsetHeight+"px"
dropmenuobj.filters[1000] = "progid:DXImageTransform.Microsoft.Alpha(Opacity=75, FinishOpacity=0, Style=0, StartX=0, FinishX=0, StartY=0, FinishY=0)";
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
hidemenu2();
doHideMenu = false;
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
	if(dropmenuobj != null)
		dropmenuobj.style.visibility="hidden";
if(dropmenuobj != null)
	if(dropmenuobj.id != "dropmenudiv")
	{
		dropmenuobj=document.getElementById("dropmenudiv");
		lastSMEvt = e;
		if(hideMain == true)
			hidemenu(e);
	}
}
}

function hidemenu2()
{
	document.getElementById('dropmenudiv2').style.visibility = "hidden";
	lastSMEvt = null;
}

function delayhidemenu(){
if (ie4||ns6)
	delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (delayhide!=null)
{
	clearTimeout(delayhide)
	delayhide = null;
}
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

function uploadpic(table_imgID,tableID)
{
	var table = document.getElementById(tableID);
	var table_img = document.getElementById(table_imgID);
	table.style.display = (table.style.display == "none") ? "block" : "none";
	table_img.style.display = (table_img.style.display == "block") ? "none" : "block";
}

function Validator(frmname)
{
  this.formobj=document.forms[frmname];
	if(!this.formobj)
	{
	  alert("BUG: couldnot get Form object "+frmname);
		return;
	}
	if(this.formobj.onsubmit)
	{
	 this.formobj.old_onsubmit = this.formobj.onsubmit;
	 this.formobj.onsubmit=null;
	}
	else
	{
	 this.formobj.old_onsubmit = null;
	}
	this.formobj.onsubmit=form_submit_handler;
	this.addValidation = add_validation;
	this.setAddnlValidationFunction=set_addnl_vfunction;
	this.clearAllValidations = clear_all_validations;
}
function set_addnl_vfunction(functionname)
{
  this.formobj.addnlvalidation = functionname;
}
function clear_all_validations()
{
	for(var itr=0;itr < this.formobj.elements.length;itr++)
	{
		this.formobj.elements[itr].validationset = null;
	}
}
function form_submit_handler()
{
	for(var itr=0;itr < this.elements.length;itr++)
	{
		if(this.elements[itr].validationset &&
	   !this.elements[itr].validationset.validate())
		{
		  return false;
		}
	}
	if(this.addnlvalidation)
	{
	  str =" var ret = "+this.addnlvalidation+"()";
	  eval(str);
    if(!ret) return ret;
	}
	return true;
}
function add_validation(itemname,descriptor,errstr)
{
  if(!this.formobj)
	{
	  alert("BUG: the form object is not set properly");
		return;
	}//if
	var itemobj = this.formobj[itemname];
  if(!itemobj)
	{
	  alert("BUG: Couldnot get the input object named: "+itemname);
		return;
	}
	if(!itemobj.validationset)
	{
	  itemobj.validationset = new ValidationSet(itemobj);
	}
  itemobj.validationset.add(descriptor,errstr);
}
function ValidationDesc(inputitem,desc,error)
{
  this.desc=desc;
	this.error=error;
	this.itemobj = inputitem;
	this.validate=vdesc_validate;
}
function vdesc_validate()
{
 if(!V2validateData(this.desc,this.itemobj,this.error))
 {
    this.itemobj.focus();
		return false;
 }
 return true;
}
function ValidationSet(inputitem)
{
    this.vSet=new Array();
	this.add= add_validationdesc;
	this.validate= vset_validate;
	this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
  this.vSet[this.vSet.length]= 
	  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
	 {
	   if(!this.vSet[itr].validate())
		 {
		   return false;
		 }
	 }
	 return true;
}
function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function V2validateData(strValidateStr,objValue,strError) 
{ 
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    } 
    switch(command) 
    { 
        case "req": 
        case "required": 
         { 
           if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : Required Field"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : "+cmdvalue+" characters maximum "; 
               }//if 
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false; 
             }//if 
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : " + cmdvalue + " characters minimum  "; 
               }//if               
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false;                 
             }//if 
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alpha-numeric characters allowed "; 
                }//if 
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//case alphanumeric 
        case "num": 
        case "numeric": 
           { 
              var charpos = objValue.value.search("[^0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only digits allowed "; 
                }//if               
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break;               
           }//numeric 
        case "alphabetic": 
        case "alpha": 
           { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alphabetic characters allowed "; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//alpha 
		case "alnumhyphen":
			{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _"; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 			
			break;
			}
        case "email": 
          { 
               if(!validateEmailv2(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Enter a valid Email address "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email 
        case "lt": 
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : value should be less than "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : value should be greater than "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = objValue.name+": Invalid characters found "; 
	              }//if                                                               
	              alert(strError); 
	              return false;                   
	            }//if 
			}
           break; 
         }//case regexp 
        case "dontselect": 
         { 
            if(objValue.selectedIndex == null) 
            { 
              alert("BUG: dontselect command for non-select Item"); 
              return false; 
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError = objValue.name+": Please Select one option "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
             break; 
         }//case dontselect 
    }//switch 
    return true; 
}
