
//***************
//  Browser Types
//***************

var __browsertype = new Object();
__BrowserType(__browsertype);

function __BrowserType(){
//var isIE	    = document.all;
//var isIE7	    = isIE && window.XMLHttpRequest && window.ActiveXObject;
//var isIE6	    = isIE && document.implementation;
//var isgteIE6	= isIE7 || isIE6;
//var isIE5	    = isIE && window.print && !isgteIE6;
//var isIEDOM2	= isIE5 || isgteIE6;
//var isIE4	    = isIE && !isIEDOM2 && navigator.cookieEnabled;
//var isIE3	    = isIE && !isIE4 && !isIEDOM2;
//var isNS	    = navigator.mimeTypes && !isIE;
//var isNS3	    = isNS && !navigator.language;
//var isNS4	    = document.layers;
//var isNS6	    = document.getElementById && !isIE;
//var isNS7	    = isNS6;
//var isNS71	    = document.designMode;
//var isNSDOM2	= isNS6;
//var isDOM2	    = isIEDOM2 || isNSDOM2;


    __browsertype.isIE	    = document.all;
    __browsertype.isIE7	    = __browsertype.isIE && window.XMLHttpRequest && window.ActiveXObject;
    __browsertype.isIE6	    = __browsertype.isIE && document.implementation;
    __browsertype.isgteIE6	= __browsertype.isIE7 || __browsertype.isIE6;
    __browsertype.isIE5	    = __browsertype.isIE && window.print && !__browsertype.isgteIE6;
    __browsertype.isIEDOM2	= __browsertype.isIE5 || __browsertype.isgteIE6;
    __browsertype.isIE4	    = __browsertype.isIE && !__browsertype.isIEDOM2 && navigator.cookieEnabled;
    __browsertype.isIE3	    = __browsertype.isIE && !__browsertype.isIE4 && !__browsertype.isIEDOM2;
    __browsertype.isNS	    = navigator.mimeTypes && !__browsertype.isIE;
    __browsertype.isNS3	    = __browsertype.isNS && !navigator.language;
    __browsertype.isNS4	    = document.layers;
    __browsertype.isNS6	    = document.getElementById && !__browsertype.isIE;
    __browsertype.isNS7	    = __browsertype.isNS6;
    __browsertype.isNS71	= document.designMode;
    __browsertype.isNSDOM2	= __browsertype.isNS6;
    __browsertype.isDOM2	= __browsertype.isIEDOM2 || __browsertype.isNSDOM
}

    
    
    
//var __browser=new __Browser();

//function __Browser(){
//	var a=navigator.userAgent.toLowerCase();
//	this.isOpera=(a.indexOf("opera")!=-1);
//	this.isKonq=(a.indexOf('konqueror')!=-1);
//	this.isSafari=(a.indexOf('safari')!=-1)&&(a.indexOf('mac')!=-1);
//	this.isKhtml=this.isSafari||this.isKonq;
//	this.isIE=(a.indexOf("msie")!=-1)&&!this.isOpera;
//	this.isWinIE=this.isIE&&(a.indexOf("win")!=-1);
//	this.isCSS1Compat=(!this.isIE)||(document.compatMode&&document.compatMode=="CSS1Compat");
//}


//*****************************************
//  Display Measurements
//  See examples of use in LPSingleUploader
//*****************************************
function TestViewportSizes()
{
    var viewport = new Object();
    Viewport(viewport);
    alert(viewport.windowX);
    alert(viewport.windowY);
    alert(viewport.scrollX);
    alert(viewport.scrollY);
    alert(viewport.pageX);
    alert(viewport.pageY);
}
    
    
function Viewport(viewport)
{ 
    viewport.windowX = (document.documentElement && document.documentElement.clientWidth) || 
    window.innerWidth || self.innerWidth || document.body.clientWidth; 
                
    viewport.windowY = (document.documentElement && document.documentElement.clientHeight) || 
    window.innerHeight || self.innerHeight || document.body.clientHeight; 
        
    viewport.scrollX = (document.documentElement && document.documentElement.scrollLeft) || 
    window.pageXOffset || self.pageXOffset || document.body.scrollLeft; 
        
    viewport.scrollY = (document.documentElement && document.documentElement.scrollTop) || 
    window.pageYOffset || self.pageYOffset || document.body.scrollTop; 
        
    viewport.pageX = (document.documentElement && document.documentElement.scrollWidth) ? document.documentElement.scrollWidth : (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth; 
        
    viewport.pageY = (document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;
}


function GetWindowPane(pane) { 
  var width;
  var height;
  var CScrollX;
  var CScrollY; 

  if (__browsertype.isNS) 
  { 
    width = self.innerWidth; 
    height = self.innerHeight; 
    CScrollX = window.pageXOffset; 
    CScrollY = window.pageYOffset; 
  } 
  else if (__browsertype.isIE6) 
  { 
    width = document.documentElement.clientWidth; 
    height = document.documentElement.clientHeight; 
    if (width==0) 
    { 
      width = document.body.clientWidth; 
      height = document.body.clientHeight; 
    } 
    CScrollX = document.body.scrollLeft + 
               document.documentElement.scrollLeft; 
    CScrollY = document.body.scrollTop + 
               document.documentElement.scrollTop; 
  } 
  else if (__browsertype.isIE) 
  { 
    width = document.body.clientWidth; 
    height = document.body.clientHeight; 
    CScrollX = document.body.scrollLeft; 
    CScrollY = document.body.scrollTop; 
  } 
  else if (__browsertype.isIE7)
  {
  }
  
  pane.Left    = CScrollX; 
  pane.Right   = width + CScrollX; 
  pane.Top     = CScrollY; 
  pane.Bottom  = height + CScrollY; 
  pane.xMiddle = Math.round(width/2) + CScrollX; 
  pane.yMiddle = Math.round(height/2) + CScrollY; 
  pane.VisibleWidth = width;
  pane.VisibleHeight = height;
} 

//    Element properties
function getCoords (element) 
{
    var coords = { x: 0, y: 0, width: element.offsetWidth, height: element.offsetHeight };
    while (element) 
    {
        coords.x += element.offsetLeft;
        coords.y += element.offsetTop;
        element = element.offsetParent;
    }
    
    return coords;
}   

//***************************
//  User Interface Components
//***************************


//  Reference http://scriptasylum.com/
var w3c=(document.getElementById)?true:false;
var ie=(document.all)?true:false;
var N=-1;

function createBar(w,h,bgc,brdW,brdC,blkC,speed,blocks,count,action){
if(ie||w3c){
var t='<div id="_xpbar'+(++N)+'" style="visibility:visible; position:relative; overflow:hidden; width:'+w+'px; height:'+h+'px; background-color:'+bgc+'; border-color:'+brdC+'; border-width:'+brdW+'px; border-style:solid; font-size:1px;">';
t+='<span id="blocks'+N+'" style="left:-'+(h*2+1)+'px; position:absolute; font-size:1px">';
for(i=0;i<blocks;i++){
t+='<span style="background-color:'+blkC+'; left:-'+((h*i)+i)+'px; font-size:1px; position:absolute; width:'+h+'px; height:'+h+'px; '
t+=(ie)?'filter:alpha(opacity='+(100-i*(100/blocks))+')':'-Moz-opacity:'+((100-i*(100/blocks))/100);
t+='"></span>';
}
t+='</span></div>';
document.write(t);
var bA=(ie)?document.all['blocks'+N]:document.getElementById('blocks'+N);
bA.bar=(ie)?document.all['_xpbar'+N]:document.getElementById('_xpbar'+N);
bA.blocks=blocks;
bA.N=N;
bA.w=w;
bA.h=h;
bA.speed=speed;
bA.ctr=0;
bA.count=count;
bA.action=action;
bA.togglePause=togglePause;


bA.showBar=function(){
this.bar.style.visibility="visible";
}

bA.hideBar=function(){
this.bar.style.visibility="hidden";
}

bA.tid=setInterval('startBar('+N+')',speed);
return bA;
}
}

function startBar(bn){
var t=(ie)?document.all['blocks'+bn]:document.getElementById('blocks'+bn);
if(parseInt(t.style.left)+t.h+1-(t.blocks*t.h+t.blocks)>t.w){
t.style.left=-(t.h*2+1)+'px';
t.ctr++;
if(t.ctr>=t.count){
eval(t.action);
t.ctr=0;
}}else t.style.left=(parseInt(t.style.left)+t.h+1)+'px';
}

function togglePause(){
if(this.tid==0){
this.tid=setInterval('startBar('+this.N+')',this.speed);
}else{
clearInterval(this.tid);
this.tid=0;
}}

function togglePause(){
if(this.tid==0){
this.tid=setInterval('startBar('+this.N+')',this.speed);
}else{
clearInterval(this.tid);
this.tid=0;
}}

function openWin(path, windowName, width, height) {
    var wLeft = 0, wTop = 0;
    wLeft = (screen.width - width) / 2;
    wTop = (screen.height - height) / 2;
    
    win = window.open(path, windowName, "status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=0, scrollbars=0, width=" + width + ", height=" + height + ", left=" + wLeft + ", top=" + wTop);
    win.moveTo(wLeft, wTop);
}
