function DisplayDiv(iddiv,direction)
{
	var div1 = document.getElementById(iddiv);

	if(direction==1)
	{
		div1.style.display='block';
	}
	else if(direction==-1)
	{
		div1.style.display='none';
	}
}

function ShowSubMenu(menuid){
    var p =document.getElementById(menuid);
    p.style.display='block';
}
function HideSubMenu(menuid){
    var p =document.getElementById(menuid);
    p.style.display='none';
}

function swapMenu(obj, img, activate)
{
    var onOff="";
    var flip=true;
    if(activate)
    {
        onOff="On";
    }
    else
    {
        if(id==img)
            flip=false;
    }

    if(flip)
        obj.src="public/images/AR/M"+img+onOff+".png";
}
function LangSwap(obj, img, activate)
{
    var div1=document.getElementById(obj);
    var onOff="";
    var flip=true;
    if(activate)
    {
        onOff="On";
    }
    else
    {
        if(id==img)
            flip=false;
    }

    if(flip && div1 != null)
        div1.src="public/images/AR/M"+img+onOff+".png";
}

var news_timeout;
CurrentPhoto = 3;  //start at photo 1 - Welcome Image
MaxPhoto = 3;     //maximum number of photos represented

PhotosArray = new Array ();
TextArray = new Array ();
HeadArray = new Array ();
LinkArray = new Array ();
PicsArray = new Array ();
DateArray = new Array ();

function slideNews(more,langs)
{
    NextPhoto(more,langs);news_timeout=setTimeout('slideNews(\''+more+'\',\''+langs+'\')',8000);
}

function NextPhoto(more,langs)
{
    document.getElementById('small'+(CurrentPhoto)).className="SmallPic";

    if(CurrentPhoto==MaxPhoto)
        CurrentPhoto=1;
    else
        CurrentPhoto++;
    var imgs='';

    if(PhotosArray[CurrentPhoto]=='../admin/images/electionsBanner/')
        imgs='public/images/common/default_image.png';
    else
        imgs=PhotosArray[CurrentPhoto];
    document.getElementById('showphoto').innerHTML="<a href=\""+LinkArray[CurrentPhoto]+"\"><img src=\""+imgs+"\"></a>";
    document.getElementById('imgLink').href=LinkArray[CurrentPhoto];
    document.getElementById('ShowText').innerHTML=TextArray[CurrentPhoto]+"... <a href=\""+LinkArray[CurrentPhoto]+"\"><img src=\"public/images/AR/arrow.gif\" alt=\"\"></a>";
    document.getElementById('Headline').innerHTML="<a href=\""+LinkArray[CurrentPhoto]+"\">"+HeadArray[CurrentPhoto]+"</a>";
    document.getElementById('newsDate').innerHTML=DateArray[CurrentPhoto];
    document.getElementById('small'+CurrentPhoto).className="SmallPicOn";
}

function News(id,more,langs)
{
    for(i=1;i<4;i++)
        document.getElementById('small'+i).className="SmallPic";

    CurrentPhoto=id;
    var imgs='';

    if(PhotosArray[id]=='../admin/images/electionsBanner/')
        imgs='public/images/common/default_image.png';
    else
        imgs=PhotosArray[id];

    document.getElementById('showphoto').innerHTML="<a href=\""+LinkArray[CurrentPhoto]+"\"><img src=\""+imgs+"\"></a>";
    document.getElementById('ShowText').innerHTML=TextArray[id]+"... <span id=\"Blue2\" class=\"Tahoma Size11\"><a href=\""+LinkArray[id]+"\"><img src=\"public/images/AR/arrow.gif\" alt=\"\"></a></span>";
    document.getElementById('Headline').innerHTML="<a href=\""+LinkArray[CurrentPhoto]+"\">"+HeadArray[id]+"</a>";
    document.getElementById('small'+id).className="SmallPicOn";

    clearTimeout(news_timeout);
    news_timeout=setTimeout('slideNews(\''+more+'\',\''+langs+'\')',8000);
}

/******** start flah *********/
var requiredVersion = 8;
var useRedirect = false;
var flashPage   = ""
var noFlashPage = ""
var upgradePage = ""
var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var flash7Installed = false;
var flash8Installed = false;
var flash9Installed = false;
var maxVersion = 9;
var actualVersion = 0;
var hasRightVersion = false;
var jsVersion = 1.0;

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
jsVersion = 1.1;

if(isIE && isWin){

  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
  document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
  document.write('<\/SCR' + 'IPT\> \n');

}

function detectFlash() {

  if (navigator.plugins) {
    if (navigator.plugins["Shockwave Flash 2.0"]
        || navigator.plugins["Shockwave Flash"]) {
      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
      var flashVersion = parseInt(flashDescription.substring(16));
      flash2Installed = flashVersion == 2;
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion == 6;
      flash7Installed = flashVersion == 7;
      flash8Installed = flashVersion == 8;
      flash9Installed = flashVersion >= 9;
    }
  }
  for (var i = 2; i <= maxVersion; i++) {
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 4;
  if (actualVersion >= requiredVersion) {
    if (useRedirect) {
      if(jsVersion > 1.0) {
        window.location.replace(flashPage);
      } else {
        window.location = flashPage;
      }
    }
    hasRightVersion = true;
  } else {
    if (useRedirect) {
      if(jsVersion > 1.0) {
        window.location.replace((actualVersion >= 2) ? upgradePage : noFlashPage);
      } else {
        window.location = (actualVersion >= 2) ? upgradePage : noFlashPage;
      }
    }
  }
}
detectFlash();

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?');
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs)
{
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret =
    AC_GetArgs

    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();

    switch (currArg){
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace":
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
/************* end flash *********/

/* AJAX function to print articles */
function print_article(type, id)
{
    xajax_wait();
    xajax_PrintArticle(type, id);
    return false;
}

function print_candidates(id)
{
    xajax_PrintCandidates(id);
    return false;
}

function print_list(from,limit,districtID,provinceID,locationID,record,KW,related,lname)
{
    //xajax_wait();
    xajax_PrintList(from,limit,districtID,provinceID,locationID,record,KW,related,lname,tagged);
    return false;
}

function print_function(content_vlue)
{
    var disp_setting="toolbar=no,location=no,directories=no,menubar=no,";
        disp_setting+="scrollbars=yes,width=800, height=800, left=100, top=100";
    //var content_vlue = document.getElementById("print_content").innerHTML;

    var docprint=window.open("","",disp_setting);

    docprint.document.open();
    docprint.document.write('<html><head><title>Al-Mustaqbal</title>');
    docprint.document.write('</head><body onLoad="self.print(); self.close();" style="margin:0px;padding:0px;"><center>');
    docprint.document.write(content_vlue);
    docprint.document.write('</center></body></html>');
    docprint.document.close();
    docprint.focus();
}

function print_functionCandidate(content_vlue)
{
    var disp_setting="toolbar=no,location=no,directories=no,menubar=no,";
        disp_setting+="scrollbars=yes,width=220, height=400, left=100, top=100";
    //var content_vlue = document.getElementById("print_content").innerHTML;

    var docprint=window.open("","",disp_setting);

    docprint.document.open();
    docprint.document.write('<html><head><title>Al-Mustaqbal</title>');
    docprint.document.write('</head><body onLoad="self.print(); self.close();" style="margin:0px;padding:0px;"><center>');
    docprint.document.write(content_vlue);
    docprint.document.write('</center></body></html>');
    docprint.document.close();
    docprint.focus();
}


function Preload(){
    MM_preloadImages('public/images/AR/M1.png','public/images/AR/M1On.png','public/images/AR/M2.png','public/images/AR/M2On.png','public/images/AR/M3.png','public/images/AR/M3On.png','public/images/AR/M4.png','public/images/AR/M4On.png','public/images/AR/M5.png','public/images/AR/M5On.png');
}
function MM_preloadImages() {
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) {
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() {
    var i,p,v,obj,args=MM_showHideLayers.arguments;
    for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function swaps(id,dir){
	var Sub	= document.getElementById(id);
	Sub.src="public/images/AR/"+ dir +".jpg?v=9";
}

function P7_Snap() {
	var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,pa='px',args=P7_Snap.arguments;a=parseInt(a);
	if(document.layers||window.opera){pa='';}for(k=0;k<(args.length);k+=4){
	if((g=MM_findObj(args[k]))!=null){if((el=MM_findObj(args[k+1]))!=null){
	a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
	da="document.all['"+args[k]+"']";if(document.getElementById){
	d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
	d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
	}else if(document.all){d=da;}if(document.all||document.getElementById){while(tx==1){
	p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
	}else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);tw=x+ox+y+oy;
	if(tw==0||(navigator.appVersion.indexOf("MSIE 4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){
	ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);}else{
	w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
	x=document.body.scrollLeft+event.clientX+bx;y=document.body.scrollTop+event.clientY;}}
	}else if(document.layers){x=g.x;y=g.y;q0=document.layers,dd="";for(var s=0;s<q0.length;s++){
	dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');
	break;}}}e=(document.layers)?el:el.style;xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
	if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
	xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);}
	e.left=xx+pa;e.top=yy+pa;}}}
}
//Below functions added by Ihab Arnous
///////////////////////////////////////////////////////////
//////Ihab General Functions used by validators////////////
String.prototype.Trim = function()
{
	return this.replace( /(^\s*)|(\s*$)/g,'');
}

function isIE()
{
	return (navigator.appName == 'Microsoft Internet Explorer' )?true:false;
}

function isMoz()
{
	return (navigator.appName == 'Netscape' )?true:false;
}

function isEmail(email)
{
	var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

return email.match(emailRegEx);
}

function isDate(strDate)
{
	var dateRegEx = /^\d{1,2}(\-|\/|\.)\d{1,2}\1(\d{4}|\d{2})$/;

return strDate.match(dateRegEx);
}

function isHour(strHour)
{
	var hourRegEx = /^\d{1,2}$/;

return strHour.match(hourRegEx);
}
///////////////////////////////////////////////////////////

///////////////// Validation Functions////////////////////
function submitObjectionForm()
{
	var form = document.getElementById('objectform');
	var RecordNumber = document.getElementById('RecordNumber');
	var Name = document.getElementById('Name');
	var DOB = document.getElementById('DOB');
	var Gender = document.getElementById('Gender');
	var District = document.getElementById('district2');
	var Province = document.getElementById('province2');
	var Location = document.getElementById('location2');
	var phone = document.getElementById('phone');
	var email = document.getElementById('email');
	var message = document.getElementById('message');
	var err = document.getElementById('err');

	var sbmtFlag = true;

	 if(Name.value.Trim() == '')
	{
		sbmtFlag = false;
		err.innerHTML = "&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1573;&#1587;&#1605; &#1575;&#1604;&#1603;&#1575;&#1605;&#1604;";
		Name.focus();
	}
	else if(RecordNumber.value.Trim() == '')
	{
		sbmtFlag = false;
		err.innerHTML = "&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1585;&#1602;&#1605; &#1575;&#1604;&#1587;&#1580;&#1604;";
		RecordNumber.focus();
	}
	else if(!isDate(DOB.value))
	{
		sbmtFlag = false;
		err.innerHTML = "&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1578;&#1575;&#1585;&#1610;&#1582; &#1575;&#1604;&#1605;&#1610;&#1604;&#1575;&#1583; &#1610;&#1608;&#1605;/&#1588;&#1607;&#1585;/&#1587;&#1606;&#1577;";
		DOB.focus();
	}
	else if(District.selectedIndex==0)
	{
		sbmtFlag = false;
		err.innerHTML = "&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1605;&#1581;&#1575;&#1601;&#1592;&#1577;";
		District.focus();
	}
	else if(Province.selectedIndex == 0)
	{
		sbmtFlag = false;
		err.innerHTML = "&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1602;&#1590;&#1575;&#1569;";
		Province.focus();
	}
	else if(Location.selectedIndex == 0)
	{
		sbmtFlag = false;
		err.innerHTML = "&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1605;&#1606;&#1591;&#1602;&#1577;";
		Location.focus();
	}
	else if(phone.value.Trim() == '')
	{
		sbmtFlag = false;
		err.innerHTML = "&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1607;&#1575;&#1578;&#1601;";
		phone.focus();
	}
	else if(!isEmail(email.value))
	{
		sbmtFlag = false;
		err.innerHTML = "&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1576;&#1585;&#1610;&#1583; &#1575;&#1604;&#1575;&#1604;&#1603;&#1578;&#1585;&#1608;&#1606;&#1610; &#1576;&#1588;&#1603;&#1604; &#1589;&#1581;&#1610;&#1581;";
		email.focus();
	}
	else if(message.value.Trim()=='')
	{
		sbmtFlag = false;
		err.innerHTML = "&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1578;&#1593;&#1604;&#1610;&#1602;";
		message.focus();
	}

	if(sbmtFlag)
	{
		xajax_submitObjectionForm(xajax.getFormValues('objectform'));
	}
}

function submitContactForm()
{
	var Subject = document.getElementById('Subject');
	var FName   = document.getElementById('FName');
	var Phone   = document.getElementById('Phone');
	var Email   = document.getElementById('Email');
	var Country = document.getElementById('Country');
	var Message = document.getElementById('Message');
	var err     = document.getElementById('cnt_err');

	if(Subject.selectedIndex == 0)
	{
		Subject.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1605;&#1608;&#1590;&#1608;&#1593;';
	}
	else if(FName.value.Trim() == '')
	{
		FName.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1573;&#1587;&#1605; &#1575;&#1604;&#1603;&#1575;&#1605;&#1604;';

	}
	else if(Phone.value.Trim() == '')
	{
		Phone.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1607;&#1575;&#1578;&#1601;';
	}
	else if(!isEmail(Email.value))
	{
		Email.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1576;&#1585;&#1610;&#1583; &#1575;&#1604;&#1575;&#1604;&#1603;&#1578;&#1585;&#1608;&#1606;&#1610;';

	}
	else if(Country.selectedIndex == 0)
	{
		Country.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1576;&#1604;&#1583;';

	}
	else if(Message.value.Trim() == '')
	{
		Message.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1578;&#1593;&#1576;&#1574;&#1577; &#1575;&#1604;&#1585;&#1587;&#1575;&#1604;&#1577;';
	}
	else
	{
		xajax_submitContactForm(xajax.getFormValues('contactform'));
	}
}



function verifyCompatibleBrowser(){
    this.ver=navigator.appVersion
    this.dom=document.getElementById?1:0
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
    this.ie4=(document.all && !this.dom)?1:0;
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;

    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
    return this
}
bw=new verifyCompatibleBrowser()


function ConstructObject(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
    this.up=MoveAreaUp;this.down=MoveAreaDown;

    this.scrollWidth=bw.ns4?this.css.document.width:this.el.offsetWidth
    this.clipWidth=bw.ns4?this.css.clip.width:this.el.offsetWidth
    this.left=MoveAreaLeft;this.right=MoveAreaRight;
	this.left2=MoveAreaLeft2;this.right2=MoveAreaRight2;


	this.css.zIndex="3";
    this.MoveArea=MoveArea; this.x=0; this.y=0;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}

function MoveArea(x,y){

	this.x=x;this.y=y
    this.css.left=this.x+'px';
    this.css.top=this.y+'px';
}

function MoveAreaDown(move){
   if(this.y>-this.scrollHeight+objContainer.clipHeight){
    this.MoveArea(this.x,this.y-move)
    if(loop) setTimeout(this.obj+".down("+move+")",speed)
   }
}
function MoveAreaUp(move){
   if(this.y<0){
    this.MoveArea(this.x,this.y-move)
    if(loop) setTimeout(this.obj+".up("+move+")",speed)
   }
}

function MoveAreaRight(move){
   if(-this.x + objContainer.clipWidth < this.scrollWidth){
    this.MoveArea(this.x-move,this.y)
    if(loop) setTimeout(this.obj+".right("+move+")",speed)
   }
   window.status = "right no action " + this.x;
}
function MoveAreaLeft(move){
   if(this.x<0){
    this.MoveArea(this.x-move,this.y)
    if(loop) setTimeout(this.obj+".left("+move+")",speed)
   }
   window.status = "left no action " + this.x;
}
function MoveAreaRight2(move){
   if(-this.x + objContainer2.clipWidth < this.scrollWidth){
    this.MoveArea(this.x-move,this.y)
    if(loop) setTimeout(this.obj+".right("+move+")",speed)
   }
   window.status = "right no action " + this.x;
}
function MoveAreaLeft2(move){
   if(this.x<0){
    this.MoveArea(this.x-move,this.y)
    if(loop) setTimeout(this.obj+".left("+move+")",speed)
   }
   window.status = "left no action " + this.x;
}
var speed=40

var loop, timer

var initialised;
function InitialiseScrol(){
    objContainer=new ConstructObject('divContainer') ;
    objScroller=new ConstructObject('divContent','divContainer');
    objScroller.MoveArea(0,0) ;
    objContainer.css.visibility='visible' ;

    initialised=true;
}
function PerformScroll(direction,speed){
   if(initialised){
      loop=true;
	  if(direction == 0)
	  {
	        if(speed>0) objScroller.down(speed)
            else objScroller.up(speed)
	  }
	  else
	  {
	        if(speed>0) objScroller.right(speed)
            else objScroller.left(speed)
	  }
   }
}
function CeaseScroll(){
    loop=false;
    if(timer) clearTimeout(timer) ;
}

function filePopUp(file_id, type, id, width, height)
{
  if(!width) var width="720";
  if(!height) var height="740";
  var left = (screen.width/2) - width/2;
  var top = 10;
  var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
  var msgWindow = window.open("file_popup.php?FileID="+file_id+"&Type="+type+"&ID="+id,"msgWindow", styleStr);
  return false;
}

function candidatePrint(district_id)
{
  if(!width) var width="270";
  if(!height) var height="400";
  var left = (screen.width/2) - width/2;
  var top = 10;
  var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;


  var msgWindow = window.open("print_candidate.php?d_id="+district_id,"", styleStr);
  return false;
}

var speed2=40

var loop2, timer2
var initialised2;
function InitialiseScrol2(){
    objContainer2=new ConstructObject('divContainer2') ;
    objScroller2=new ConstructObject('divContent2','divContainer2');
    objScroller2.MoveArea(0,0) ;
    objContainer2.css.visibility='visible' ;

    initialised2=true;
}
function PerformScroll2(direction,speed){
   if(initialised2){
      loop2=true;
	  if(direction == 0)
	  {
	        if(speed>0) objScroller2.down(speed)
            else objScroller2.up(speed)
	  }
	  else
	  {
	        if(speed2>0) objScroller2.right2(speed)
            else objScroller2.left2(speed)
	  }
   }
}
function CeaseScroll2(){
    loop2=false;
    if(timer2) clearTimeout(timer2) ;
}


function swapArrow(obj, img)
{
	var div=document.getElementById(obj);
	div.src="images/"+img+".png";
}
/*menu*/
function swap(obj, img, activate)
{
	var onOff="";
	var flip=true;
	if(activate)
	{
		onOff="On";
	}
	/*else
	{
		if(id==img)
			flip=false;
	}*/

	if(flip)
		obj.src="public/images/AR/T"+img+onOff+".png";
}

function point_it(event){
    pos_x = event.offsetX?(event.offsetX):event.pageX-document.getElementById("pointer_div").offsetLeft;
    pos_y = event.offsetY?(event.offsetY):event.pageY-document.getElementById("pointer_div").offsetTop;
    document.getElementById("cross").style.left = (pos_x-1) ;
    document.getElementById("cross").style.top = (pos_y-15) ;
    document.getElementById("cross").style.visibility = "visible" ;
}
var tagEntry = new Array();
var tagedEntries = new Array();
var tagged = new Array();

function storeTagged()
{
	j = 0;
	for (var i=0; i < tagEntry.length; i++){
		if (document.getElementById('tag'+tagEntry[i]).style.visibility == "visible")
		{
			tagged[j] = tagEntry[i];
			//alert(tagged[j]);
			j++;
		}
	}

}
function tagIndividual(indId,districtId,provinceId,locationId,sectId,record,user_search,kw)
{
	var tagURL = "";
	if (document.getElementById("tag"+indId).style.visibility == "visible")
    	document.getElementById("tag"+indId).style.visibility = "hidden";
    else
    	document.getElementById("tag"+indId).style.visibility = "visible";

	for (var i=0; i < tagEntry.length; i++){
		if (document.getElementById('tag'+tagEntry[i]).style.visibility == "visible")
		{
			if (i == 0)
				tagURL += tagEntry[i];
			else
				tagURL += "-"+tagEntry[i];

		}

  	}
  	if (tagURL != '')
  	{
  		linkPage = "district="+districtId+"|province="+provinceId+"|location="+locationId+"|sectId="+sectId+"|record="+record+"|USE_SEARCH="+user_search+"|KW="+kw;
		document.getElementById("popupSend").innerHTML = "<a rel=\"mobox[500,550]\" rev=\"popup_send_friend.php?recordsTagged="+tagURL+"&link="+linkPage+"\" href=\"javascript:;\"><img id=\"send_friend\" src=\"public/images/AR/snd-friend.jpg\" onMouseOver=\"swaps('send_friend','snd-friend-on')\" onMouseOut=\"swaps('send_friend','snd-friend')\"></a>";
		initiation();
		
		document.getElementById('send_friend').src = "public/images/AR/send_friend.gif";
  	}
  	else
		document.getElementById('send_friend').src = "public/images/AR/send_friend.jpg";
  	
}

function setDefaultndividual(districtId,provinceId,locationId,sectId,record,user_search,kw)
{
  		linkPage = "district="+districtId+"|province="+provinceId+"|location="+locationId+"|sectId="+sectId+"|record="+record+"|USE_SEARCH="+user_search+"|KW="+kw;
		document.getElementById("popupSend").innerHTML = "<a rel=\"mobox[500,550]\" rev=\"popup_send_friend.php?recordsTagged=&link="+linkPage+"\" href=\"javascript:;\"><img id=\"send_friend\" src=\"public/images/AR/snd-friend.jpg\" onMouseOver=\"swaps('send_friend','snd-friend-on')\" onMouseOut=\"swaps('send_friend','snd-friend')\"></a>";
		initiation();
}

function tagAllEntries()
{
	for (var i=0; i < tagEntry.length; i++){

		for (var j=0; j < tagedEntries.length; j++){
			if (tagEntry[i] == tagedEntries[j])
			{
				document.getElementById('tag'+tagEntry[i]).style.visibility = "visible";
			}
		}

  	}

}

function showToolTip(e,text,div_id){
	if(document.all)e = event;
	var obj = document.getElementById('bubble_tooltip');
	//var obj2 = document.getElementById('bubble_tooltip_content');
	//obj2.innerHTML = text;
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
	var leftPos = e.clientX - 100;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
}

function hideToolTip()
{
	document.getElementById('bubble_tooltip').style.display = 'none';

}
var dateFuture = new Date(2009,5,7,18,00,00);
function GetCount(){

	dateNow = new Date();									//grab current date
	amount = dateFuture.getTime() - dateNow.getTime();		//calc milliseconds between dates
	delete dateNow;

	// time is already past
	if(amount < 0){
		document.getElementById('countbox').innerHTML="Now!";
	}
	// date is still good
	else{
		days=0;hours=0;mins=0;secs=0;out="";

		amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs

		days=Math.floor(amount/86400);//days
		amount=amount%86400;

		hours=Math.floor(amount/3600);//hours
		amount=amount%3600;

		mins=Math.floor(amount/60);//minutes
		amount=amount%60;

		secs=Math.floor(amount);//seconds

		if(days != 0){out +="&#1576;&#1575;&#1602;&#1610;: " + "<span style=\"font-size:18px;\">"+days +"</span> "+((days!=1)?"&#1571;&#1610;&#1575;&#1605;":"&#1610;&#1608;&#1605;")+":";}
		if(days != 0 || hours != 0){out +="<span style=\"font-size:18px;\">"+hours +"</span> "+((hours!=1)?"&#1587;&#1575;&#1593;&#1575;&#1578;":"&#1587;&#1575;&#1593;&#1577;")+":";}
		if(days != 0 || hours != 0 || mins != 0){out +="<span style=\"font-size:18px;\">"+mins+"</span> "+((mins!=1)?"&#1583;&#1602;&#1575;&#1574;&#1602;":"&#1583;&#1602;&#1575;&#1574;&#1602;")+" ";}
		//out += secs +" seconds";
		document.getElementById('countbox').innerHTML=out;

		setTimeout("GetCount()", 1000);
	}

}

/*function validateQuick()
{
	var name3 = document.getElementById('name3');
	var rec = document.getElementById('rec');
	var err     = document.getElementById('quick_err');

	if(name3.value.Trim() == '')
	{
		name3.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1573;&#1587;&#1605; &#1575;&#1604;&#1603;&#1575;&#1605;&#1604;';

	}
	else if(rec.value.Trim() == '')
	{
		rec.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569;&#1548; &#1573;&#1583;&#1582;&#1575;&#1604; &#1575;&#1604;&#1607;&#1575;&#1578;&#1601;';
	}

	else
	{
		xajax_submitQuick(xajax.getFormValues('quickform'));
	}
}*/
function validateQuick()
{
	var name3 = document.getElementById('name3');
	var rec = document.getElementById('rec');
	var err     = document.getElementById('quick_err');

	if(name3.value.Trim() == '')
	{
		name3.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569; &#1571;&#1583;&#1582;&#1604; &#1575;&#1604;&#1573;&#1587;&#1605; &#1575;&#1604;&#1579;&#1604;&#1575;&#1579;&#1610;';

	}
	else if(rec.value.Trim() == '')
	{
		rec.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569; &#1571;&#1583;&#1582;&#1604; &#1585;&#1602;&#1605; &#1575;&#1604;&#1587;&#1580;&#1604;';
	}
	else if(isNaN(rec.value))
	{
		rec.focus();
		err.innerHTML = '&#1610;&#1580;&#1576; &#1571;&#1606; &#1610;&#1603;&#1608;&#1606; &#1585;&#1602;&#1605; &#1575;&#1604;&#1587;&#1580;&#1604; &#1585;&#1602;&#1605;&#1575;&#1611;';
	}
	else
	{
		var disp_setting="toolbar=no,location=no,directories=no,menubar=no,";
        disp_setting+="scrollbars=yes,width=520, height=270, left=100, top=100";
		//xajax_submitQuick(xajax.getFormValues('quickform'));
		window.open("quick_popup.php?n="+name3.value+"&r="+rec.value,"",disp_setting);
	}
}

function validateComplain()
{
	var cname = document.getElementById('cname');
	var pen = document.getElementById('pen');
	var phone_num = document.getElementById('phone_num');
	var comp = document.getElementById('comp');
	var err  = document.getElementById('comp_err');
	var form = document.getElementById('comp_form');
	var subFlag = true;


	if(cname.value.Trim() == '')
	{
		subFlag = false;
		cname.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569; &#1571;&#1583;&#1582;&#1604; &#1575;&#1604;&#1573;&#1587;&#1605;';
	}
	else if(phone_num.value.Trim() == '')
	{
		subFlag = false;
		phone_num.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569; &#1573;&#1583;&#1582;&#1575;&#1604; &#1585;&#1602;&#1605; &#1575;&#1604;&#1607;&#1575;&#1578;&#1601; ';
	}
	else if(pen.value.Trim() == '')
	{
		subFlag = false;
		pen.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569; &#1571;&#1583;&#1582;&#1604; &#1585;&#1602;&#1605; &#1575;&#1604;&#1602;&#1604;&#1605; ';
	}
	else if(comp.value.Trim() == '')
	{
		subFlag = false;
		comp.focus();
		err.innerHTML = '&#1575;&#1604;&#1585;&#1580;&#1575;&#1569; &#1571;&#1583;&#1582;&#1604; &#1575;&#1604;&#1581;&#1575;&#1583;&#1579;&#1577; &#1575;&#1604;&#1578;&#1610; &#1581;&#1589;&#1604;&#1578;';
	}

	if(subFlag == true)
	{
		xajax_submitCompForm(xajax.getFormValues('comp_form'));
	}
}

function resetComplaint()
{
	document.getElementById('cname').value = '';
	document.getElementById('pen').value='';
	document.getElementById('phone_num').value='';
	document.getElementById('comp').innerText=null;
}