﻿// JScript File
/* News SCroll */
function stopScroll()
{
    document.getElementById('mqScroll').stop();
}

function startScroll()
{
     document.getElementById('mqScroll').start();
}

function Over(obj)
{
  obj.className ='bgparentsublnk';
}
function Out(obj)
{
  obj.className='parentsublnk';
}
function OClick(obj,objSublinks,objArrow) 
{
  if(objSublinks.style.display == 'none')
  {
    objSublinks.style.display='block';
    objArrow.src=apath+ "en/_images/innerpage/left_navigation/bullet_02.png";
  }
  else if(objSublinks.style.display == 'block')
  {
    objSublinks.style.display='none';
    objArrow.src=apath+ "en/_images/innerpage/left_navigation/bullet_01.png";
    
  }
} 
  
function printDoc()
{
    window.print();
}
function back()
{
  window.history.back();
}
function ebc(mode)
{
    if(document.getElementById("F1") != null)
    {
        if(mode) document.getElementById("F1").style.position = 'static';
        else document.getElementById("F1").style.position = 'relative';
    }
}
function email(obj)
{
   ebc(true); 

   var cLeft = getposOffset(document.getElementById('lnkEmail'),"left");
   var cTop = getposOffset(document.getElementById('lnkEmail'),"top");
   
   document.getElementById('dvSend').style.left = (cLeft - 220) + "px";
   document.getElementById('dvSend').style.top = (cTop + 17 ) + "px";
   document.getElementById('dvSend').style.display = "block";
}

function eclose()
{
   ebc(false); 
   document.getElementById('dvSend').style.display = "none";
}

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 cSearch()
{
    if(document.getElementById(tSearch).value == 'Search Site')
    document.getElementById(tSearch).value = '';
}

function rSearch()
{
    if(document.getElementById(tSearch).value == '')
    document.getElementById(tSearch).value = 'Search Site';
}
function checksearch(oSrc, args)
{
    if(document.getElementById(tSearch).value == 'Search Site')
    {
        document.getElementById(tSearch).value = '';
        args.IsValid = false;
    }
    else 
    {
        args.IsValid = true;
    }
}
function ShowLocationMap()
{
        var iX = 820;
	    var iY = 480;

		window.open(apath + "en/_images/Location Map/Location Map.BMP", "popup", "width=" + iX + ",height=" + iY + ",status=1,resizable=1");
	    
}
function ShowYardMap()
{
       var iX = 820;
	   var iY = 950;
	    
		window.open(apath + "en/yardmap.htm", "popup", "width=" + iX + ",height=" + iY + ",status=1,resizable=1,scroll=yes,scrollbars=yes,top=0, left=200");
}

/* Rotating Banner */
 
var currentquote=0;	
function switchBnners()
{

  var cnt = document.getElementById(hidBanners).value.split('@').length;
  if(cnt > 0)
  {
    setQuote(currentquote);
    currentquote++;
    if(currentquote==cnt) currentquote=0;
  }
}
function setQuote(nId)
{
  var data = document.getElementById(hidBanners).value.split('@');
  var uniq = data[nId].split(',');
  if(uniq[4] == "False")
  {
    document.getElementById(bImage).style.display = 'block';
    document.getElementById(bImagePlane).style.display = 'none';
   
    document.getElementById(bImage).src = uniq[1];
    document.getElementById(hrefbImage).enabled = 'true';
    if(uniq[3].length > 7)
    {
        document.getElementById(hrefbImage).href = uniq[3];
        document.getElementById(hrefbImage).target = "_blank"
    }
    else
    {
        document.getElementById(bImage).style.display = 'none';
        document.getElementById(bImagePlane).style.display = 'block';
   
        document.getElementById(bImagePlane).src = uniq[1];
    }
    
  }
  else
  {
    document.getElementById(bImage).style.display = 'none';
    document.getElementById(bImagePlane).style.display = 'block';
   
    document.getElementById(bImagePlane).src = uniq[1];
  }
}

/*  Video Gallery  */   
function PlayMovie(filename)
{
    Ovideo();
    var player=document.getElementById('flvPlayer');
    player.innerHTML="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='387' height='302' bgcolor='#000000' id='myFlashMovie' name='myFlashMovie'><param name='movie' value='http://8.6.95.86/downloads/zoom.swf' /><param name='FlashVars' value='videos=http://8.6.95.86/downloads/files/"+ filename+"&fms=&app=' /><param name='allowFullScreen' value='true' /><param name='quality' value='high'/><embed src='http://8.6.95.86/downloads/zoom.swf' width='387' height='302' bgcolor='#000000' flashvars='videos=http://8.6.95.86/downloads/files/" + filename +"&fms=&app=' allowfullscreen='true' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'  id='myFlashMovie' name='myFlashMovie'/></object>";
}
function setScroll()
{
    var tPos = (screen.availHeight) ? (screen.availHeight - 500)/2 : 0;
    tPos += document.documentElement.scrollTop;
    document.getElementById('nxt').style.top = tPos + "px";
}
function fixScroll()
{
      if(document.getElementById('main1')!=null)
    {
      document.getElementById('main1').style.height = document.getElementById('tblHome').offsetHeight;
      document.getElementById('main1').style.width = screen.width-23;
      var lPos = (screen.width) ? (screen.width-300)/2 : 0;
      document.getElementById('nxt').style.left = lPos +'px';
      var tPos = (screen.availHeight) ? (screen.availHeight - 500)/2 : 0;
      document.getElementById('nxt').style.top = tPos+'px';
      

      var cleft=0;
      var cTop=0;
      var obj = document.getElementById('tdContent');
      if(obj != null)
        {
        if(obj.offsetParent)
            {
               
                while(true) 
                {
                    cleft += obj.offsetLeft;
                    cTop+=obj.offsetTop;
                    if(!obj.offsetParent) break;
                    obj = obj.offsetParent;
                }
            }
        }
    }
}
function Ovideo()
{
     document.getElementById('main1').style.display = 'block';
     document.getElementById('nxt').style.display = 'block';
}

function Cvideo()
{
    document.getElementById('main1').style.display = 'none';
    document.getElementById('nxt').style.display = 'none';
    var player=document.getElementById('flvPlayer');
    player.innerHTML='';
}

function Arabic()
{
   var Urls = location.href;
   if(Urls.length > 0)
   {
        var fixpath = Urls.split("/en/");
        if(fixpath.length > 1)
        {
            location.href = apath+"ar/"+fixpath[fixpath.length-1];
        }
      
   }
   else
   {
    location.href = apath+"ar/";
   }
}