function findElement(elemID)
{
	var obj;
	if(elemID!='') {
		if (document.getElementById) {
			obj = document.getElementById(elemID);
		} else if (document.all) {
			obj = document.all(elemID);
		} else if (document.layers) {
			obj = document.layers[elemID];
		}
	}
	else {
		obj=null;
	}
	return obj;
}

function buttonOver(button)
{
    button.className = 'toolbarButtonHighLight';
    window.status = button.title;
}

function buttonOut(button)
{
    button.className = 'toolbarButton';
    window.status = '';
}

function getForm(formName)
{
	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
		return document.forms[formName];
	}
	else {
		return document[formName];
	}
}

function countSelected(form)
{
    var item;
    var itemCount = 0;

    for( var i = 0; i < form.elements.length; i++ )
    {   
        item = form.elements[i];
        
        if( item.type && ( item.type == "checkbox" && item.checked ) )
        {
            itemCount++;
        }            
    }
        
    return itemCount;
}

function openURL(url) { window.open(url, "_self"); }

function lzf(number, length)
{
    var s;
    
    for(var i=0; i<length; i++ ) s+='0';
    
    s += number;
    
    return s.substring(s.length - length);
}

function openPopup(url)
{
	var x = (screen.availHeight - 535)/2;
	var y = (screen.availWidth - 675)/2;
	var features = 'top='+x+',left='+y+',height=535,width=675,status=no,scrollbars=yes,resizable=no,toolbar=0,menubar=0,location=0';
	window.open(url, 'popup', features);
}
function openPopup2(url)
{
	var x = (screen.availHeight - 610)/2;
	var y = (screen.availWidth - 600)/2;
	var features = 'top='+x+',left='+y+',height=610,width=600,status=no,scrollbars=yes,resizable=no,toolbar=0,menubar=0,location=0';
	window.open(url, 'popup', features);
}
function bytesToString(bytes)
{
    if( bytes <= 1024 )
        return bytes + ' bytes';

    if( bytes <= 102400 )
        return Math.round( bytes / 1024 ) / 100 + ' KB';
    else
        return Math.round( bytes / 10485.76 ) / 100 + ' MB';
}

function wrapString(oldString, maxLength)
{
    var element;
    var newString = '';
    var strBuffer = oldString.split(' ');

    for( x=0; x < strBuffer.length; x++ )
    {
        if( strBuffer[x].length > maxLength )
        {
            element = strBuffer[x].split('');
            
            for (y=0; y < element.length; y++ )
            {
                if( y % maxLength == 0 ) newString += '<BR>';
                newString += element[y]
            }
        }
        else newString += ' ' + strBuffer[x];
    }
    
    return newString;
}
function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1)
        { 
            c_start=c_start + c_name.length+1 ;
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        } 
    }
    return "";
}

function checkGuest()
{
    guest=getCookie('isGuest')
    if (guest!=null && guest!="")
        return guest;
    else 
    {
        return "unknown";
    }
}

function checkUncheckAll(check) 
{
    var theForm = document.forms[0];
    for(var z = 0; z < theForm.length; z++ )
    {
        if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall' )
        {
	        theForm[z].checked = check;
	    }
    }
}

function oBrowserInfo(){

	this.ua = navigator.userAgent.toLowerCase();

	/*** Browser Version ***/
    if( this.ua.indexOf("msie") != -1) {
        
        this.version = parseInt(this.ua.charAt(this.ua.indexOf("msie") + 5));
        
        this.isIE   = true;
		this.isIE2  = (this.version==2) ? true: false;
		this.isIE3  = (this.version==3) ? true: false;
		this.isIE4  = (this.version==4) ? true: false;
		this.isIE5  = (this.version==5) ? true: false;
		this.isIE6  = (this.version==6) ? true: false;
		this.isIE7  = (this.version>=7) ? true: false;
        
    } else if(this.ua.indexOf("netscape") != -1) {

        this.version = parseInt(this.ua.charAt(this.ua.indexOf("netscape") + 9));
        
        this.isNN   = true;
		this.isNN2  = (this.version==2) ? true: false;
		this.isNN3  = (this.version==3) ? true: false;
		this.isNN4  = (this.version==4) ? true: false;
		this.isNN5  = (this.version==5) ? true: false;
		this.isNN6  = (this.version>=6) ? true: false;
		
	} else if(this.ua.indexOf("aol") != -1) {
	
        this.version = parseInt(this.ua.charAt(this.ua.indexOf("aol") + 4));
		this.isAOL  = true;
		this.isAOL6 = (this.version==6) ? true: false;
		this.isAOL7 = (this.version==7) ? true: false;
		this.isAOL8 = (this.version>=8) ? true: false;
		
    } else if(this.ua.indexOf("opera") != -1) {
		
		this.isOpera = true;
        this.version = parseInt(this.ua.charAt(this.ua.indexOf("opera") + 8));
		
    } else if(this.ua.indexOf("mozilla") != -1) {

		this.isMozilla = true;
        this.version = parseInt(this.ua.charAt(this.ua.indexOf("mozilla") + 8));
    }

	/*** Operating System ***/
    this.isWin   = (this.ua.indexOf("windows") != -1)
	this.isWin16 = (this.ua.indexOf("windows 3.1") != -1 || this.ua.indexOf("win16") != -1) ? true: false;
	this.isWin32 = (this.isWin95 || this.isWin98 || this.isWinNT) ? true: false;
	this.isWinCE = (this.ua.indexOf("windows ce") != -1) ? true: false;
	this.isWin95 = (this.ua.indexOf("windows 95") != -1 || this.ua.indexOf("win95") != -1 ) ? true: false;
	this.isWin98 = (this.ua.indexOf("windows 98") != -1 || this.ua.indexOf("win98") != -1 ) ? true: false;
	this.isWinNT = (this.ua.indexOf("windows nt") != -1 || this.ua.indexOf("winnt") != -1 ) ? true: false;
    this.isWinXP = (this.ua.indexOf("nt 5") != -1);
    this.isWinXPSP2 = (this.ua.indexOf("sv1") != -1) || (this.isIE && this.version >= 7);
    this.isVista = (this.ua.indexOf("nt 6") != -1);
	this.isMac   = (this.ua.indexOf("mac") != -1) ? true: false;
	this.isOSX   = (this.isMac && this.ua.indexOf("mac os x") != -1 ) ? true: false;	
	this.isUnix  = (this.ua.indexOf("sunos") != -1 || this.ua.indexOf("hp-ux") != -1 || this.ua.indexOf("x11") != -1) ? true: false;
}

var oBrowser = new oBrowserInfo();
