/*****************************************************************************
** -------------------- Program Name    : eCom Multi System © . --------------
** -------------------- Program Version :  v.3.5.3 ---------------------------
** -------------------- Program Author  : Athco Pros Team . ------------------
** -------------------- Graphics        : Athco Graphics . -------------------
** -------------------- Web Site        : www.Athco.com.sa -------------------
** -------------------- E-Mail          : Sales@Athco.com.sa -----------------
** -------------------- Last Modified   : 01.03.2009 -------------------------
** -------------------- Distribution    : Via  Web Site ----------------------
** -------------------- (C) Copyright 2005 Athco Co. -------------------------
*****************************************************************************/

 function xsToggleNavMore()  {
 var xsNavMoreButton = document.getElementById('NavMoreButton');
 xsNavMoreButton.className=(xsNavMoreButton.className=='NavMoreButtonOpen')?'NavMoreButtonClosed':'NavMoreButtonOpen';
 var xsNavMorePallet = document.getElementById('NavMore');
 xsNavMorePallet.className=(xsNavMorePallet.className=='NavMoreOpen')?'NavMoreClosed':'NavMoreOpen';
 }

//=====================================================
// Security Code
  var SecurityReloadCount = 0;
  var SecurityImageUrl = "SecurityCode.php";
  function NewSecurityCode() {
    if (SecurityImageUrl.indexOf('?') == -1) {
    document.getElementById('SecurityImage').src= SecurityImageUrl+'?dp='+SecurityReloadCount;
    } else {
    document.getElementById('SecurityImage').src= SecurityImageUrl+'&dp='+SecurityReloadCount;
    }

    document.getElementById('SecurityInput').value="";
    document.getElementById('SecurityInput').focus();
    SecurityReloadCount++;
  }

//=====================================================
// check Block Login
function checkArabicBlockLogin(){
      if (document.aTLogin.user.value==""){
      alert("Ù„Ù… ØªÙ‚Ù… Ø¨Ø§Ø¯Ø®Ø§Ù„ Ø§Ø³Ù… Ø§Ù„Ø¯Ø®ÙˆÙ„");
      document.aTLogin.user.focus();
      return false;
      }
      if (document.aTLogin.pass.value==""){
      alert("Ù„Ù… ØªÙ‚Ù… Ø¨Ø§Ø¯Ø®Ù„ ÙƒÙ„Ù…Ø© Ù…Ø±ÙˆØ±");
      document.aTLogin.pass.focus();
      return false;
      }
}

//=====================================================
// check Arabic Header Search
function checkArabicHeaderSearchSmartPages(){
      if (document.aTHeaderSearchSmartPages.SearchKeywords.value==""){
      alert("Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø§Ø¯Ø®Ø§Ù„ Ø§Ù„ÙƒÙ„Ù…Ø© Ø§Ùˆ Ø§Ù„Ø¹Ø¨Ø§Ø±Ø© Ø§Ù„ØªÙŠ ØªØ¨Ø­Ø« Ø¹Ù†Ù‡Ø§");
      document.aTHeaderSearchSmartPages.SearchKeywords.focus();
      return false;
      }
}
function checkArabicHeaderSearchNews(){
      if (document.aTHeaderSearchNews.SearchKeywords.value==""){
      alert("Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø§Ø¯Ø®Ø§Ù„ Ø§Ù„ÙƒÙ„Ù…Ø© Ø§Ùˆ Ø§Ù„Ø¹Ø¨Ø§Ø±Ø© Ø§Ù„ØªÙŠ ØªØ¨Ø­Ø« Ø¹Ù†Ù‡Ø§");
      document.aTHeaderSearchNews.SearchKeywords.focus();
      return false;
      }
}
function checkArabicHeaderSearchFaq(){
      if (document.aTHeaderSearchFaq.SearchKeywords.value==""){
      alert("Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø§Ø¯Ø®Ø§Ù„ Ø§Ù„ÙƒÙ„Ù…Ø© Ø§Ùˆ Ø§Ù„Ø¹Ø¨Ø§Ø±Ø© Ø§Ù„ØªÙŠ ØªØ¨Ø­Ø« Ø¹Ù†Ù‡Ø§");
      document.aTHeaderSearchFaq.SearchKeywords.focus();
      return false;
      }
}

//=====================================================
// Add Bookmark
function Bookmark( title, url )
{
        if (title == undefined)
                title = document.title;

        if (url == undefined)
                url = top.location.href;

        if (window.sidebar) // firefox
                window.sidebar.addPanel(title, url, '');
        else if(window.opera && window.print) // opera
        {
                var elem = document.createElement('a');
                elem.setAttribute('href',url);
                elem.setAttribute('title',title);
                elem.setAttribute('rel','sidebar');
                elem.click();
        }
        else if(document.all) // ie
                window.external.AddFavorite(url, title);
        else if (navigator.appName == "Netscape") //Netscape
                alert( 'To bookmark this site press "Ctrl+D".' );
        else
                alert( 'Your browser doesn\'t support this feature' );
}

//=====================================================
// Show Hide Help
function ShowHideHelp(N) {
        var H = document.getElementById('Help_'+N);
        //H.style.left  = -100+'px';
        H.style.top   = 0+'px';
        H.style.display = (H.style.display == "none") ? "block" : "none";
}

//=====================================================
// Show Hide Expands
function ShowHideExpands(Tag,N) {
        var H = document.getElementById( Tag + N );
        H.style.display = (H.style.display == "none") ? "block" : "none";
}

//=====================================================
// Box Display
      var ns6    = document.getElementById && !document.all ? 1 : 0
      var head   = "display : ''"
      var folder = ''
function expandit(curobj){
      folder = ns6 ? curobj.nextSibling.nextSibling.style : document.all[curobj.sourceIndex+1].style
      if (folder.display == "none")
      folder.display = ""
      else
      folder.display = "none"
}

//=====================================================
// Check Limit Text
function taLimit() {
 var taObj = event.srcElement;
  if (taObj.value.length == taObj.MaxLength*1) return false;
}
function taCount(visCnt) {
 var taObj = event.srcElement;
  if (taObj.value.length>taObj.MaxLength*1) taObj.value = taObj.value.substring(0,taObj.MaxLength*1);
  if (visCnt) visCnt.innerText = taObj.MaxLength-taObj.value.length;
}

//=====================================================
// The zoom Box
var maxW,maxH,fromX,fromY,toX,toY,adjX,adjY,zBox,zStep=0,zLink,zNew, eC_scrollbars, eC_resizable;

function zoomBox(evt,zlink,maxw,maxh, aT_scrollbars, aT_resizable,tox,toy) {
if (arguments.length > 2) zNew=1;
scrollH =(window.pageYOffset!= null) ? window.pageYOffset : document.body.scrollTop;
maxW = maxw ? maxw : window.innerWidth ? innerWidth : document.body.clientWidth;
maxH = maxh ? maxh : window.innerHeight ? innerHeight : document.body.clientHeight;
toX = tox?tox:0;
toY = (toy ? toy : 0)+scrollH;

eC_scrollbars = aT_scrollbars ? aT_scrollbars : 0 ;
eC_resizable  = aT_resizable ? aT_resizable : 0 ;

fromX = evt.pageX ? evt.pageX : evt.clientX;
fromY = (evt.pageY ? evt.pageY : evt.clientY)+(document.all ? scrollH :0 );
adjX = toX+evt.screenX-fromX;
adjY = toY+evt.screenY-fromY;

if (document.createElement && document.body.appendChild && !zBox) {
        zBox = document.createElement("div");
        zBox.style.position="absolute";
        document.body.appendChild(zBox);
} else if (document.all && !zBox) {
        document.all[document.all.length-1].outerHTML+=' <center><div id="zBoxDiv" style="position:absolute"></div></center>';
        zBox = document.all.zBoxDiv;
} else if (document.layers && !zBox) {
        zBox = new Layer(maxW);
        zBox.style=zBox;
        }
zLink = zlink;
doZoom();
}

function doZoom() {
zStep+=1;
zPct = (10-zStep)/10

 var toX = (screen.width - maxW) / 2;
 var toY = (screen.height - maxH) / 2;

if (document.layers) {
        zBox.moveTo(toX+zPct*(fromX-toX),toY+zPct*(fromY-toY));
        zBox.document.open();
        zBox.document.write("<table width='"+maxW*(1-zPct)+"' height="+maxH*(1-zPct)+" border=1 cellspacing=0><tr><td></td></tr></table>");
        zBox.document.close();
        } else {
        zBox.style.border="1px solid #EA8C0C ";
        zBox.style.left=toX+zPct*(fromX-toX);
        zBox.style.top=toY+zPct*(fromY-toY);
        zBox.style.width=maxW*(1-zPct);
        zBox.style.height=maxH*(1-zPct);
        }
zBox.style.visibility="visible";
if (zStep < 10) setTimeout("doZoom("+fromX+","+fromY+","+toX+","+toY+")",30);
else {
        zBox.style.visibility='hidden';
        zStep=0;

        if (zLink && !zNew) location.href=zLink.href;
        else if (zLink && zNew) {
            var winLeft = (screen.width - maxW) / 2;
            var winTop = (screen.height - maxH) / 2;

            winData = 'width='+maxW+',height='+maxH+',left='+winLeft+',top='+winTop+' ,scrollbars='+ eC_scrollbars +',resizable='+ eC_resizable +' ';
                var w = window.open(zLink.href, '', winData);


                zNew=null;
                }
        }
}
//---------------->---------------

/*****************************************************************************
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;

/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer   the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
*****************************************************************************/
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('TD');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

/**
 * Checks/unchecks all tables
 *
 * @param   string   the form name
 * @param   boolean  whether to check or to uncheck the element
 *
 * @return  boolean  always true
 */
function setCheckboxes(the_form, do_check)
{
    var elts      = (typeof(document.forms[the_form].elements['ID[]']) != 'undefined')
                  ? document.forms[the_form].elements['ID[]']
                  : (typeof(document.forms[the_form].elements['BoxID[]']) != 'undefined')
          ? document.forms[the_form].elements['BoxID[]']
          : document.forms[the_form].elements['CheckBox[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        } // end for
    } else {
        elts.checked        = do_check;
    } // end if... else

    return true;
} // end of the 'setCheckboxes()' function ;