// These variables are for supporting multilanguage.
var languages=new Array(10);
var languages_size=0;
var Language = "Ar";

// ============================================================
// Uncomment the downloaded languages below.
languages[languages_size++]="en"; // English
// languages[languages_size++]="tw"; // Traditional Chinese
// languages[languages_size++]="cn"; // Simplified Chinese
 languages[languages_size++]="Ar"; //  Arabic
// // languages[languages_size++]="kr"; // Korean
// ============================================================

// These variables are for the web counter
var sc_project=858897; 
var sc_invisible=1; 
var sc_partition=3; 
var sc_security="2963a6eb"; 
var sc_text;

var option1 = "scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=752,height=650";
var option2 = "scrollbars=yes,toolbar=yes,location=yes,status=yes,menubar=yes,resizable=yes";

var ie4=document.all;
var ns6=document.getElementById&&!document.all;

var menuType = "vertical";
var level = 0;
var DocRoot = "/";

function chkWindows() {
  var details = navigator.userAgent;
  return details.indexOf("Windows")!=-1;
}

function chkBrowser() {
  var appname = navigator.appName;
  var appversion = navigator.appVersion;

  if (appname = "Microsoft Internet Explorer") {
    var p1 = appversion.indexOf("MSIE") + 5;
    var s1 = appversion.substring(p1, p1+8);
    var p2 = s1.indexOf(";");
    var version = "0";

    if (p2 > 0) 
      version = s1.substring(0,p2);
    return (parseFloat(version) >= 5);
  }
  return false;
}

function openwindow(url,options) {
  if (options == null)
    window.open(url, "t1", option1);
  else
    window.open(url, "t2", options);
}

function resize_table() {
  var textarea=115300;
  var elem=document.getElementById("world");
  var myWidth=0, myHeight=0, textheight=0;
  if (elem) {
    if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
      //IE 4 compatible
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
    }
    textheight=textarea/myWidth;
    if (textheight<150) textheight=150;
    elem.style.height=myHeight-textheight;
  }
}

function Cortona(elemId, node, field, id, imageId, imageUrl) {
  elem = document.getElementById(elemId);
  if (elem && elem.Engine)
    elem.Engine.Nodes(node).Fields(field) = id;
  else
    document.getElementById(imageId).style.backgroundImage = "url(" + imageUrl + ")";
}

function getDocRoot() {
  var doc = location.href;
  var i = doc.length;
  while (i>1) {
    var j = i;
    doc = doc.substring(0,j);
    i = doc.lastIndexOf("/");
    if ((j-i) == 3) {
      DocRoot = doc.substring(0,i+1);
      Language = doc.substring(i+1,j+1);
      return i;
    }
  }
  return i;
}

function language(language_id) {
  var i = getDocRoot();
  var doc = location.href;
  if (i>1) {
    doc = DocRoot + language_id + location.href.substring(i+3);
    if (doc == location.href) return "#";
  }
  return doc;
}

function languageMenu(language_id,printVersionWidth) {
  getDocRoot();
  document.writeln('<table border="0" cellpadding="0" cellspacing="0">');
  document.writeln('<tr><td><table width="150" border="0" cellpadding="0" cellspacing="0"><tr><td>&nbsp;</td></tr></table></td>');
  document.writeln('<td><table width="400" border="0" cellpadding="0" cellspacing="0"><tr>');
  for (var i=0; i<4; i++) {
    if (i < languages_size) {
      var image='<img src="'+DocRoot+languages[i]+'/images/language.gif" border="0" width="51" height="12" style="margin:2px">';
      var page=language(languages[i]);
      document.writeln('<td width="100"><a class="language" href="'+page+'">'+image+'</a></td>');
    }
    else document.writeln('<td width="100">&nbsp;</td>');
  }
  document.writeln('</tr></table></td>');
  document.writeln('<td><table width="'+printVersionWidth+'" border="0" cellpadding="0" cellspacing="0"><tr><td>');
  document.writeln('<a class="printer" href="javascript:printerVersion()">');
  document.writeln('<img src="'+DocRoot+'images/print.gif" border="0" style="vertical-align:middle;"> ');
  document.writeln('<img src="'+DocRoot+'/'+language_id+'/images/printer_version.gif" border="0" style="vertical-align:middle;"></a>');
  document.writeln('</td></tr></table></td></tr></table>');
}

function fullpath(filename) {
  var doc;
  getDocRoot();
  doc = DocRoot + Language + "/" + filename;
  if (doc == location.href) return "#";
  return doc;  
}

var fifo = new Array();
var top = 0;

function queue(thing) {
  fifo[top++]=thing;
}

function unqueue() {
  if (top>0) {
    var thing=fifo[0];
    --top;
    for (var i=0; i<top; i++) fifo[i]=fifo[i+1];
    return thing;
  }
  else return null;
}

function remove(thing) {
  for (var i=0; i<top; i++) {
    if (fifo[i]==thing) {
      fifo[i]=null;
      return true;
    }
  }
  return false;
}


function displayItem(node) {
  var child;

  if (remove(node)) return;

  for (var i=0; i<node.childNodes.length; i++) {
    child = node.childNodes[i];
    if (child.nodeName=="UL") {
      child.style.display = "block";
      return;
    }
  }
}

function hideMenu() {
  var hideNode=unqueue();
  if (hideNode==null) return;
  for (var i=0; i<hideNode.childNodes.length; i++) {
    var child = hideNode.childNodes[i];
    if (child.nodeName=="UL" && child.className.length>0) {
      child.style.display = "none";
      return;
    }
  }
}

function hideItem(node) {
  queue(node);
  setTimeout("hideMenu()", 10);
}

function menu(mType) {
  menuType = mType;
  document.writeln('<ul class="' + menuType + '">');
}

function endMenu() {
  document.writeln('</ul>');
}

function menuItem(title, link) {
  document.writeln('<li><a href="'+link+'">' + title + '</a></li>');
}

function subMenu(title) {
  level++;
  document.writeln('<li class="' + menuType + '" onmouseover="displayItem(this)" onmouseout="hideItem(this)">');
  document.write('<a href="#">'+title);
  if (menuType == "vertical" || level > 1) document.write('<span>&gt;</span>');
  document.writeln('</a><ul class="' + menuType + '">');
}

function endSubMenu() {
  level--;
  document.writeln('</ul></li>');
}

function printerVersion() {
  window.open(location.href+"?printer=on", "PrinterVersion");
}

function resizeIFrame(myFrame) {
  if (myFrame.contentWindow) {
    myFrame.height = myFrame.contentWindow.document.body.scrollHeight + 10;
  }
}

function webCounter(invisible) {
  if (location.protocol == "http:") {
    sc_invisible=invisible;
    if (!invisible) sc_text=2;
    document.writeln('<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script>');
  }
}


