function openDownloadWindow(token)
{

	var screenHeight = window.screen.availHeight;
	var screenWidth = window.screen.availWidth;
	var windowTop = (screenHeight - 420) / 2;
	var windowLeft = (screenWidth - 600) / 2;

	var parameters = "height=420" + ",width=600"+
					",left=" + windowLeft + ",top=" + windowTop +
					",status=no,toolbar=no,menubar=no,location=no"+
					",resizable=no,scrollbars=no,titlebar=no"+
					",channelmode=no,directories=no,fullscreen=no";

      window.open("download.jsp?token=" + token, "", parameters);
}

function changeStyle( style )
{
	document.forms["styleForm"].action = window.location.href;
	document.forms["styleForm"].styleColor.value = style;
	document.forms["styleForm"].submit();
}

function changeLanguage( language )
{
       	document.forms["frmLanguage"].action = window.location.href;
	document.forms["frmLanguage"].selectedLanguage.value = language;
	document.forms["frmLanguage"].submit();
}

//---------------------------------------------------------------------------------
// Yousef Abu Aesheh Script
// this script is to disable right click
var message="Function Disabled!";

function clickIE4(){
if (event.button==2){
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false")

// the below script is to desable selection

var omitformtags=["input", "textarea", "select"]

omitformtags=omitformtags.join("|")

function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}

function reEnable(){
return true
}

if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}

//---------------------------------------------------------------------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  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) { //v4.01
  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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//----------------------------------------------------------------------------------
function setClipBoardData(){
     //setInterval("window.clipboardData.setData('text','')",20);
}
function blockError(){
     window.location.reload(true);
     return true;
}
window.onerror = blockError;


//////////////////Added Validations///////////////////////
function IsNumber(strValue)
{
    var checkOK = "0123456789.";
    var checkStr = strValue;
    var allValid = true;
    var allNum = "";

    if (checkStr.split('.').length > 2)
    {
        return false;
    }


    for (i = 0; i < checkStr.length; i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0; j < checkOK.length; j++)
            if (ch == checkOK.charAt(j))
                break;
        if (j == checkOK.length)
        {
            allValid = false;
            break;
        }
        allNum += ch;
    }
    if (!allValid)
    {

        return false;
    }

    return true;
}

function IsIntegerNumber(strValue)
{
    var checkOK = "0123456789";
    var checkStr = strValue;
    var allValid = true;
    var allNum = "";


    for (i = 0; i < checkStr.length; i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0; j < checkOK.length; j++)
            if (ch == checkOK.charAt(j))
                break;
        if (j == checkOK.length)
        {
            allValid = false;
            break;
        }
        allNum += ch;
    }
    if (!allValid)
    {

        return false;
    }

    return true;
}



function IsAlpha(strValue)
{
    var checkOK =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\u0630\u0636\u0635\u062B\u0642\u0641\u063A\u0639\u0647\u062E\u062D\u062C\u062F\u0634\u0633\u064A\u0628\u0644\u0627\u062A\u0646\u0645\u0643\u0637\u0626\u0621\u0624\u0631\u0644\u0627\u0649\u0629\u0648\u0632\u0638~\u0651\u064E\u064E\u064E\u064B\u064F\u064C\u064C\u0644\u0625\u0625\u0650\u064D\u0644\u0623\u0623\u0652\u0644\u0622\u0622-'.:";
    var checkStr = strValue;
    var allValid = true;
    var validGroups = true;


    if (checkStr.indexOf('"') > 0)
        return false;
        if (checkStr.substring(0, 1) == "\"")
            return false;


    for (i = 0; i < checkStr.length; i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0; j < checkOK.length; j++)
            if (ch == checkOK.charAt(j))
                break;
        if (j == checkOK.length)
        {
            allValid = false;
            break;
        }
    }
    if (!allValid)
    {

        return (false);
    }
    return true;
}


function isArabicChar(c) {
  if (c.length>1) { return false; }
  if ((c.charCodeAt(0)  >= 0x600) && (c.charCodeAt(0)  <= 0x6ff)){
    return true;
  }
  return false;
}


function containsArabic(str){
  for(var i=0;i<str.length;i++){
    if (isArabicChar(str.charAt(i))){
       return true;
    }
  }
  return false;
}


function checkEmail(strValue)
{

    var returnValue;
    var expression;


    var flag = true;

    if (Trim(strValue) != "")

    {




        expression =
            "[A-Za-z_]+[A-Za-z0-9_-]*[.]?[A-Za-z0-9_-]+[@][A-Za-z0-9_-]+[.][A-Za-z0-9_]+[.]?[A-Za-z0-9_]+";



        returnValue = strValue.match(expression);

        if (returnValue != strValue)

        {

            flag = false;

        }

    }


    // if(!flag)  alert(strAlert);
    return flag;

}

function IsEmpty(strValue)
{
    test = true;
    valtrimed = Trim(strValue);
    testlen = valtrimed.length;

    if (testlen == 0)
    {
        test = false;

    }
    return (test);
}

function LTrim(String)
{
    var i = 0;
    var j = String.length - 1;

    if (String == null)
        return (false);

    for (i = 0; i < String.length; i++)
    {
        if (String.substr(i, 1) != ' ' && String.substr(i, 1) != '\t')
            break;
    }

    if (i <= j)
        return (String.substr(i, (j + 1) - i));
    else
        return ('');
}

function RTrim(String)
{
    var i = 0;
    var j = String.length - 1;

    if (String == null)
        return (false);

    for (j = String.length - 1; j >= 0; j--)
    {
        if (String.substr(j, 1) != ' ' && String.substr(j, 1) != '\t')
            break;
    }

    if (i <= j)
        return (String.substr(i, (j + 1) - i));
    else
        return ('');
}


function Trim(String)
{
    if (String == null)
        return (false);
    return RTrim(LTrim(String));
}


///Added for side menu ////////////
function Toggle(item) {


   obj=document.getElementById(item);

   visible=(obj.style.display!="none")

   key=document.getElementById("xj" + item);

   if (visible) {

     obj.style.display="none";
     key.innerHTML="+";
   } else {

      obj.style.display="block";
      key.innerHTML="-";
   }
}



