var W3CDOM = (document.createElement && document.getElementsByTagName);
var buggyBastard = (navigator.userAgent.indexOf('MSIE') != -1 &&
    navigator.userAgent.indexOf('Mac') != -1)

if (W3CDOM)
{
    var tempDIV = document.createElement('div');var W3CDOM = (document.createElement && document.getElementsByTagName);
var buggyBastard = (navigator.userAgent.indexOf('MSIE') != -1 &&
    navigator.userAgent.indexOf('Mac') != -1)
    var tempDIV = document.createElement('div');
    tempDIV.className = 'overlibdiv';
}



function initOrchid()
{
	if (!W3CDOM) return;
    initMouseovers(document.getElementsByTagName('img'));
    initNav();

    var login_timeout = "";
    var logout_warning_interval = "";

    if( login_timeout && logout_warning_interval )
    {
        warn_after = ( login_timeout - logout_warning_interval ) * 1000;
        setTimeout("startTimer("+warn_after+")", 0); 
    }
    setNavHeight();
    var newFontSize = readCookie('fontsize');
    if (newFontSize)
        changeFont(newFontSize);
    if (self.init)
    {
        init(); 
    }
    if (self.preloadImages)
    {
        preloadImages();
    }
	}

function exitOrchid()
{
    if( ami_popupshown ) 
    { 
        ami_popup.close(); 
        ami_popupshown = false; 
    }
    if( typeof xit == 'function' ) 
    { 
        xit(); 
    }
}

window.onload = initOrchid;
window.onunload = exitOrchid;

var inside = false;

function initNav()
{
    //document.body.onmouseover = collapseMenu;

    var x = document.getElementsByTagName('div');
    for (var i=0;i<x.length;i++) {
        if (x[i].className == 'nav') {
            var y = x[i].getElementsByTagName('li');
            for (var j=0;j<y.length;j++) {
                var tmp = y[j].firstChild;
                if( tmp )
                {
                    while (tmp && tmp.nodeType != 1)
                    {
                        tmp = tmp.nextSibling;
                    }
                    if( tmp )
                    {
                        tmp.onmouseover = foldOut;
                    }
                }
                var tmp2 = y[j].lastChild;
                if( tmp2 )
                {
                    while (tmp2 && tmp2.nodeType != 1)
                    {
                        tmp2 = tmp2.previousSibling;
                    }
                    if( tmp2 )
                    {
                        tmp2.onmouseout = checkFoldIn;
                    }
                }
            }
        }
    }
}
// preloads mainnav images

        imgs1 = new Image();
        imgs1.src = "/ht/a/GetImageAction/i/3677";
        imgs2 = new Image();
        imgs2.src = "/ht/a/GetImageAction/i/3681";
        imgs3 = new Image();
        imgs3.src = "/ht/a/GetImageAction/i/3685";
        imgs4 = new Image();
        imgs4.src = "/ht/a/GetImageAction/i/3689";
        imgs5 = new Image();
        imgs5.src = "/ht/a/GetImageAction/i/3693";
        imgs6 = new Image();
        imgs6.src = "/ht/a/GetImageAction/i/3697";
        imgs7 = new Image();
        imgs7.src = "/ht/a/GetImageAction/i/3701";


var currentFold; // contains foldout that's currently opened
var closeMenu;

var fo_timeoutid = null; // crappy ppk foldouts need a semaphore

function startFoldoutTimer()
{	
    if( fo_timeoutid ) {
        clearTimeout( fo_timeoutid );
    }
    fo_timeoutid = setTimeout("foldIn()", 1000);
}

function clearFoldoutTimer()
{

    if( fo_timeoutid )
    {
        clearTimeout( fo_timeoutid );
    }
    fo_timeoutid = null;
}

function navMouseOut(e) {
  //inside = false;
  startFoldoutTimer();
}

function navMouseOver(e) {
  inside = true;
}

function collapseMenu(e) {
   if(!e) var e = window.event;
   var tg = (window.event) ? e.srcElement : e.target;
   if(tg) {
                if(!inside && tg.parentNode.parentNode.nodeName != 'UL' && tg.parentNode.parentNode.nodeName != 'LI') {
                    document.getElementById('mainnav1').src='/ht/a/GetImageAction/i/3679';
                    document.getElementById('mainnav2').src='/ht/a/GetImageAction/i/3683';
                    document.getElementById('mainnav3').src='/ht/a/GetImageAction/i/3687';
                    document.getElementById('mainnav4').src='/ht/a/GetImageAction/i/3691';
                    document.getElementById('mainnav5').src='/ht/a/GetImageAction/i/3695';
                    document.getElementById('mainnav6').src='/ht/a/GetImageAction/i/3699';
                    document.getElementById('mainnav7').src='/ht/a/GetImageAction/i/3703';
                    foldIn();
                }
            }
}

function foldIn()
{
    if (currentFold) {
        currentFold.className = '';
        currentFold.parentNode.style.zIndex = '0';
    }
	   
    currentFold = null;
    }

function foldOut(e)
{
        if (!e) var e = window.event;
                        var tg = (window.event) ? e.srcElement : e.target;
                        while (tg.nodeName != 'LI' && tg.nodeName != 'BODY')
                            tg = tg.parentNode;
                        if (tg.nodeName != 'LI') return;

                        nodeIndex = 0;
                        if(navigator.userAgent.indexOf('MSIE') == -1) {
                            nodeIndex = 1;
                        }

                        if(tg.childNodes[nodeIndex].childNodes[nodeIndex]) {
                            if(tg.childNodes[nodeIndex].childNodes[nodeIndex].id == 'mainnav1') {
                                document.getElementById('mainnav2').src='/ht/a/GetImageAction/i/3683';
                            }
                            if(tg.childNodes[nodeIndex].childNodes[nodeIndex].id == 'mainnav2') {
                                document.getElementById('mainnav1').src='/ht/a/GetImageAction/i/3679';
                                document.getElementById('mainnav3').src='/ht/a/GetImageAction/i/3687';
                            }
                            if(tg.childNodes[nodeIndex].childNodes[nodeIndex].id == 'mainnav3') {
                                document.getElementById('mainnav2').src='/ht/a/GetImageAction/i/3683';
                                document.getElementById('mainnav4').src='/ht/a/GetImageAction/i/3691';
                            }
                            if(tg.childNodes[nodeIndex].childNodes[nodeIndex].id == 'mainnav4') {
                                document.getElementById('mainnav3').src='/ht/a/GetImageAction/i/3687';
                                document.getElementById('mainnav5').src='/ht/a/GetImageAction/i/3695';
                            }
                            if(tg.childNodes[nodeIndex].childNodes[nodeIndex].id == 'mainnav5') {
                                document.getElementById('mainnav4').src='/ht/a/GetImageAction/i/3691';
                                document.getElementById('mainnav6').src='/ht/a/GetImageAction/i/3699';
                            }
                            if(tg.childNodes[nodeIndex].childNodes[nodeIndex].id == 'mainnav6') {
                                document.getElementById('mainnav5').src='/ht/a/GetImageAction/i/3695';
                                document.getElementById('mainnav7').src='/ht/a/GetImageAction/i/3703';
                            }
                            if(tg.childNodes[nodeIndex].childNodes[nodeIndex].id == 'mainnav7') {
                                document.getElementById('mainnav6').src='/ht/a/GetImageAction/i/3699';
                            }
                        }
                        if (currentFold)
                            foldIn();
                        var x = tg.getElementsByTagName('div');
                        if (x.length != 1) return;
                        x[0].className = 'foldOut';
                        tg.style.zIndex = '100';
                        currentFold = x[0];
} 

function checkFoldIn(e)
{
        if (!e) var e = window.event;
        var tg = (window.event) ? e.srcElement : e.target;
        if (tg.nodeName != 'DIV') return;
        var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
        while (reltg != tg && reltg.nodeName != 'BODY')
            reltg= reltg.parentNode;
        if (reltg == tg) return;
        foldIn();
}

// ...................................................... rolloverOn
// Turn on image rollover -- switch to "on" image.
// 
function rolloverOn(img)
{
    if( img.src.match( /gif$/ ) )
    {
        img.src = ( "https://commerce.orchidsuites.net/orchid/images/" + img.name + "-on.gif" );
    }
    else if( img.src.match( /jpg$/ ) )
    {
        img.src = ( "https://commerce.orchidsuites.net/orchid/images/" + img.name + "-on.jpg" );
    }
    else if( img.src.match( /png$/ ) )
    {
        img.src = ( "https://commerce.orchidsuites.net/orchid/images/" + img.name + "-on.png" );
    }
}

// ...................................................... rolloverOff
// Turn OFF image rollover -- switch to "off" image.
// 
function rolloverOff(img)
{
    if( img.src.match( /gif$/ ) )
    {
        img.src = ( "https://commerce.orchidsuites.net/orchid/images/" + img.name + ".gif" );
    }
    else if( img.src.match( /jpg$/ ) )
    {
        img.src = ( "https://commerce.orchidsuites.net/orchid/images/" + img.name + ".jpg" );
    }
    else if( img.src.match( /png$/ ) )
    {
        img.src = ( "https://commerce.orchidsuites.net/orchid/images/" + img.name + ".png" );
    }
}

// ...................................................... getElementByName
// Return an element, given the form and the element name.
// 
function getElementByName( formname, elementname )
{ 
    var elements = eval( "document." + formname + ".elements" );
    for( var i = 0; i < elements.length; i++ )
    {
        if( elements[i].name == elementname )
        {
            return elements[i];
        }
    }
    return null;
}

var mouseOvers = new Array();
var mouseOuts = new Array();

function initMouseovers(x)
{
    for (var i=0;i<x.length;i++)
    {
        if (x[i].getAttribute('behav') == 'mouseover')
        {
            x[i].onmouseover = mouseGoesOver;
            x[i].onmouseout = mouseGoesOut;
            var suffix = x[i].src.substring(x[i].src.lastIndexOf('.'));
            mouseOuts[i] = new Image();
            mouseOuts[i].src = x[i].src;
            mouseOvers[i] = new Image();
            mouseOvers[i].src = x[i].src.substring(0,x[i].src.lastIndexOf('.')) + "-on" + suffix;
            x[i].number = i;
        }
    }
}

function mouseGoesOver()
{
    this.src = mouseOvers[this.number].src;
    this.status = 'mo';
}

function mouseGoesOut()
{
    if (!this.status) return;
    this.src = mouseOuts[this.number].src;
    this.status = '';
}

function changeFont(size)
{
    document.body.style.fontSize = size;
    setNavHeight();
}

/* Manage cookies */

function createCookie(name,value,days)
{
    if (days)
    {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++)
    {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name)
{
    createCookie(name,"",-1);
}

// ...................................................... save
// Save the value of a form element
// 
var savedvals = new Array();
function save( element )
{ 
    savedvals[ element.name ] = element.value;
}
// ...................................................... restore
// Restore the value of a form element
// 
function restore( element )
{ 
    element.value = savedvals[ element.name ];
}
// ...................................................... saveMain
// Save all values in the main form.
// 
function saveMain( )
{ 
    if( document.main && document.main.elements )
    {
        var elements = document.main.elements;
        if( elements.length )
        {
            for( var i = 0; i < elements.length; i++ )
            {
                savedvals[ elements[i].name ] = elements[i].value;
            }
        }
    }
}
// ...................................................... unsortRolloverOn
// Rollover the unsort icon.
// 
var saved_sortimage_index;
var saved_sortimage_src;
var saved_unsortimage_index;
var saved_unsortimage_src;
function unsortRolloverOn()
{ 
    for( var i = 0; document.images && i < document.images.length; i++ )
    {
        if(  "sort-down" == document.images[i].name
          || "sort-up" == document.images[i].name
          )
        {
            saved_sortimage_index = i;
            saved_sortimage_src = document.images[i].src;
            document.images[i].src = "https://commerce.orchidsuites.net/orchid/images/" + "sort-none.gif";
            break;
        }
        else
        {
            saved_sortimage_index = 0;
            saved_sortimage_src = '';
        }
    }
}
// ...................................................... unsortRolloverOff
// UN-Rollover the unsort icon.
// 
function unsortRolloverOff()
{ 
    if( saved_sortimage_index && saved_sortimage_src )
    {
        document.images[saved_sortimage_index].src = saved_sortimage_src;
        saved_sortimage_index = 0;
        saved_sortimage_src = '';
    }
}
// ...................................................... sortRolloverOn
// Rollover some sort icon.
// 
function sortRolloverOn( img )
{ 
    saved_sortimage_index = 0;
    saved_sortimage_src = '';
    saved_unsortimage_index = 0;
    saved_unsortimage_src = '';
    for( var i = 0; document.images && i < document.images.length; i++ )
    {
        if(  "sort-down" == document.images[i].name
          || "sort-up" == document.images[i].name
          )
        {
            if( ! saved_sortimage_index )
            {
                saved_sortimage_index = i;
                saved_sortimage_src = document.images[i].src;
                document.images[i].src = "https://commerce.orchidsuites.net/orchid/images/" + "sort-none.gif";
            }
        }
        else if( "nounsort" == document.images[i].name )
        {
            if( ! saved_unsortimage_index )
            {
                saved_unsortimage_index = i;
                saved_unsortimage_src = document.images[i].src;
                document.images[i].src = "https://commerce.orchidsuites.net/orchid/images/" + "unsort.gif";
            }
        }
    }
}
// ...................................................... sortRolloverOff
// UN-Rollover some sort icon.
// 
function sortRolloverOff()
{ 
    if( saved_sortimage_index && saved_sortimage_src )
    {
        document.images[saved_sortimage_index].src = saved_sortimage_src;
        saved_sortimage_index = 0;
        saved_sortimage_src = '';
    }
    if( saved_unsortimage_index && saved_sortimage_src )
    {
        document.images[saved_unsortimage_index].src = saved_unsortimage_src;
        saved_unsortimage_index = 0;
        saved_unsortimage_src = '';
    }
}
var alertShown = false;
// ...................................................... badvalue
// The element value was bad, so tell user and restore
// old value
// ppkpatch: 
// This function is called from everywhere, but it should work with both old Admin and new Public scripts.
// showAlertNew() is new W3C DOM validation script, only in Public pages.
// if it is present in the page, call it, and also send an HTML element.
// If it's not present, send only text info.
// To be solved eventually
//
function badValue( element, info )
{ 
    restore( element );
    if (self.showAlertNew)
        showAlertNew( element,info );
    else
        showAlert(info);
}

// ...................................................... showAlert
// Display an alert if one hasn't been displayed for
// this particular call to checkForm().
//
function showAlert( text )
{
    if( ! alertShown )
    {
         alert( text );
        alertShown = true;
    }
}  

// ...................................................... confirmTimeout
// The session is about to time out, so open a popup
// to inform the user.
// 
function confirmTimeout()
{
    var ratio = "1.25";
    var h = 150;
    if( ratio )
    {
        h = Math.abs(ratio * h);
    }
    
    showPopup( 'ConfirmTimeout', '0', h, 500  );
}
// ...................................................... startTimer
// Start timer to count down milliseconds until user
// should be informed that session is about to expire.
// 
function startTimer( timeLeft )
{
    setTimeout( "confirmTimeout()", timeLeft );
}
// ...................................................... trim
// Trims whitespace off each side of a string.
// 
function trim( s )
{
    if( s )
    {
        s = s.replace( /^\s+/, "" );
        s = s.replace( /\s+$/, "" );
    }
    return s;
}

// ...................................................... getDateDifference
// Get the difference between two dates
//
function getDateDifference( date1, date2 )
{  
    //split date in year, month, day

    dateSplitter1 = date1.split("/");  
    dateSplitter2 = date2.split("/");         
    var newdate1 =new Date(dateSplitter1[2], dateSplitter1[0]-1, dateSplitter1[1]);
    var newdate2 = new Date(dateSplitter2[2], dateSplitter2[0]-1, dateSplitter2[1]);
    
    //Set 1 day in milliseconds

    var one_day=1000*60*60*24



    //Calculate difference btw the two dates, and convert to days

    return Math.ceil((newdate1.getTime()-newdate2.getTime())/(one_day));
}

// ...................................................... dateChanged
// Checks formatting for changed date text input.
// Also guesses what the year should be.  If difference
// between current year and entered year is > 85,
// 100 is added to the year.  In other words, the
// date is assumed to be in the future.
// 
function dateChanged( element, monthyear )
{   var value = trim( element.value );
    if( value )
    {
        if( monthyear )
        {
            var thedate = value.split( "/" );
            if( 2 == thedate.length )
            {
                value = thedate[0] + "/01/" + thedate[1];
            }
            else if( 3 == thedate.length )
            {
                value = thedate[0] + "/01/" + thedate[2];
            }
            else
            {
                badValue( element, "Sorry, '" + element.value + "' is not a valid date.  Please enter a date in mm/yyyy format." );
                return;
            }
        }
        var today = new Date();
        var currentyear = today.getFullYear();
        var ts = Date.parse( value );
        var dt = new Date(ts);
        var m = dt.getMonth() + 1;
        var d = dt.getDate();
        var y = dt.getFullYear();
        if( isNaN(m) || isNaN(d) || isNaN(y) )
        {
            if( monthyear )
            {
                badValue( element, "Sorry, '" + element.value + "' is not a valid date.  Please enter a date in mm/yyyy format." );
            }
            else
            {
                badValue( element, "Sorry, '" + element.value + "' is not a valid date.  Please enter a date in mm/dd/yyyy format." );
            }
        }
        else
        {
            if( currentyear - y > 85 )
            {
                y = y + 100;
            }
            if( monthyear )
            {
                element.value = m + "/" + y;
            }
            else
            {
                element.value = m + "/" + d + "/" + y;
            }
        }
    }
}
// ...................................................... wordChanged
// Checks to make sure the input is a single word.
// 
function wordChanged( element )
{   var value = trim( element.value );
    if( value )
    {
        if( value.match( /^.*\s.*$/ ) )
        {
            badValue( element, "Sorry, '" + element.value + "' contains a whitespace character.  It may not contain any spaces." );
            alertShown = false;
            return;
        }
    }
}
// ...................................................... amountChanged
// Checks formatting for changed currency input (US style)
// 
function amountChanged( element )
{   var value = trim( element.value );
    if( value )
    {
        // replace commas and spaces
        value = value.replace( /[ ,]/, '' );
        if( !value.match( /^\d+(\.\d\d)?$/ ) )
        {
            badValue( element, "Sorry, '" + element.value + "' is not a valid amount.  Please enter a whole number, such as 78, or a decimal value, such as 27.45" );
            alertShown = false;
            return;
        }
    }
}
// ...................................................... integerChanged
// Checks to make sure the input is an integer.
// 
function integerChanged( element )
{   var value = trim( element.value );
    if( value )
    {
        if( !value.match( /^\d+$/ ) )
        {
            badValue( element, "Sorry, '" + element.value + "' is not a valid number.  Please enter a positive integer." );
            alertShown = false;
            return;
        }
    }
}
// ...................................................... checkRange
// Checks value of a bounded integer.
// 
function checkRange( element, min, max )
{   var value = trim( element.value );
    if( value )
    {
        if( !value.match( /^\d+$/ ) )
        {
            badValue( element, "Sorry, '" + element.value + "' is not a valid number.  Please enter a positive integer." );
            alertShown = false;
            return;
        }
        else if( ( min && value < min ) || ( max && value > max ) )
        {
            badValue( element, "Sorry, " + element.value + " is not a number from " + min + " to " + max + ".  Please enter another number." );
            alertShown = false;
            return;
        }
    }
}
// ...................................................... phoneChanged
// Checks formatting for changed phone number text input.
// 
function phoneChanged( element )
{   var val = trim( element.value );
    var phone_format = "";
    if( val.length > 0 && phone_format == "us" )
    {
        if( val.match( /^1/ ) )
        {
            val = val.substr( 1 );
        }
        val = val.replace( /\D/g, "" )
        if( val.length < 10 )
        {
            badValue( element, "The phone number is garbled or not long enough!" );
            alertShown = false;
            return;
        }
        else if( val.length > 10 )
        {
            badValue( element, "The phone number is garbled or too long!" );
            alertShown = false;
            return;
        }
        var acode = val.substring(0, 3);
        var exchange = val.substring(3,6);
        var number = val.substring(6,10);
        val = acode + "-" + exchange + "-" + number;
    }
    element.value = val;
}
// ...................................................... emailChanged
// Checks formatting for changed email text input.
// 
function emailChanged( element )
{   var val = trim( element.value );
    if( val.length > 0 )
    {
        parts = val.split( "@" );
        if( 2 != parts.length || parts[0].match( /^.*\s.*$/ ) )
        {
            badValue( element, "That doesn't look like a valid email address." );
            alertShown = false;
            return;
        }
        domainparts = parts[1].split( "." );
        if ( domainparts.length < 2 )
        {
            badValue( element, "That doesn't look like a valid email address." );
            alertShown = false;
            return;
        }
        else
        {
            for( var i=0; i < domainparts.length; i++ )
            {
                if( i + 1 == domainparts.length )
                {
                    if( ! domainparts[i].match( /^[A-Za-z]{2,10}$/ ) )
                    {
                        badValue( element, "That doesn't look like a valid email address." );
                        alertShown = false;
                        return;
                    }
                }
                else
                {
                    // Had to spell out letters and numerals because
                    // a hyphen was included and it seemed to break the
                    // use of character ranges.
                    if( ! domainparts[i].match( /^[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-]+$/ ) )
                    {
                        badValue( element, "That doesn't look like a valid email address." );
                        alertShown = false;
                        return;
                    }
                }
            }
        }
    }
    return true;
}

// ...................................................... codeChanged
// Checks to make sure the input is a single word, capitalized
// and alphanumeric.
function codeChanged( element )
{   var val = trim( element.value );
    if( val.length > 0 )
    {
        if( val.match( /[^0-9A-Z\\_#%-]/ ) )
        {
            badValue( element, "Sorry, '" + element.name + "' must contain only numbers or uppercase letters" );       
            alertShown = false;
            return;
        }
    }
    element.value = val;
}




///  ***********************************************************   from orchid-js



// ...................................................... showPopup
// Display a popup.
// 
var ami_popupshown = false;
var ami_popup;
function showPopup( display, id, h, w )
{
    if( ! h ) h = 400;
    if( ! w ) w = 500;
   
    var ratio = "1.25";
    if( ratio )
    {
        h = Math.abs(ratio * h);
    }
    if( ami_popupshown )
    {
        ami_popup.resizeTo( w, h );
    }
    ami_popup = window.open( "/ht/display/"+display+"/i/" + id + "/displaytype/popup", "ami_popup", "height="+h+",width="+w+",resizable,scrollbars");
    ami_popup.focus();
}


function sizeText(amount)
{
    var fontSize = (document.body.style.fontSize) ? parseFloat(document.body.style.fontSize) : 0.75;
    var newFontSize = fontSize + (amount/10) + 'em';
    changeFont(newFontSize);
    createCookie('fontsize',newFontSize,30);
    return false;    
}


function setNavHeight()
{
    if (!W3CDOM) return;
    var compare = new Array('nav2','main','extra');
    for (var i=0;i<compare.length;i++)
    {
        if (document.getElementById(compare[i]))
            document.getElementById(compare[i]).style.height = 'auto';

    }
    if (document.getElementById('nav2') &&
        document.getElementById('nav2').parentNode.className != 'normal') 
    {
        var maxHeight = 0;
        for (var i=0;i<compare.length;i++)
        {
            if (document.getElementById(compare[i]))
            {
                var newHeight = document.getElementById(compare[i]).offsetHeight;
                if (newHeight > maxHeight) maxHeight = newHeight;
            }
        }
        for (var i=0;i<compare.length;i++)
        {
            if (document.getElementById(compare[i]))
                document.getElementById(compare[i]).style.height = maxHeight + 'px';
        }
    }
}

// ------------------------------------------------------------
//  Useful and common functions
// ------------------------------------------------------------
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function formatNumber(num,prefix){
   prefix = prefix || '';
   num += '';
   var splitStr = num.split('.');
   var splitLeft = splitStr[0];
   var splitRight = splitStr.length > 1 ? '.' + splitStr[1] : '';
   var regx = /(\d+)(\d{3})/;
   while (regx.test(splitLeft)) {
      splitLeft = splitLeft.replace(regx, '$1' + ',' + '$2');
   }
   return prefix + splitLeft + splitRight;
}

function unformatNumber(num) {
   return num.replace(/([^0-9\.\-])/g,'')*1;
}

function cookiesAllowed() {
   setCookie('checkCookie', 'test', 1);
   if (getCookie('checkCookie')) {
      deleteCookie('checkCookie');
      return true;
   }
   return false;
}

function setCookie(name,value,expires, options) {
   if (options===undefined) { options = {}; }
   if ( expires ) {
      var expires_date = new Date();
      expires_date.setDate(expires_date.getDate() + expires)
   }
   document.cookie = name+'='+escape( value ) +
      ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + 
      ( ( options.path ) ? ';path=' + options.path : '' ) +
      ( ( options.domain ) ? ';domain=' + options.domain : '' ) +
      ( ( options.secure ) ? ';secure' : '' );
}

function getCookie( name ) {
   var start = document.cookie.indexOf( name + "=" );
   var len = start + name.length + 1;
   if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
      return null;
   }
   if ( start == -1 ) return null;
   var end = document.cookie.indexOf( ';', len );
   if ( end == -1 ) end = document.cookie.length;
   return unescape( document.cookie.substring( len, end ) );
}

function deleteCookie( name, path, domain ) {
   if ( getCookie( name ) ) document.cookie = name + '=' +
      ( ( path ) ? ';path=' + path : '') +
      ( ( domain ) ? ';domain=' + domain : '' ) +
      ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function getCSSRule(ruleName, deleteFlag) {
   ruleName=ruleName.toLowerCase(); 
   if (document.styleSheets) {      
      for (var i=0; i<document.styleSheets.length; i++) { 
         var styleSheet=document.styleSheets[i];
         var ii=0;                              
         var cssRule=false;                      
         do {                                   
            if (styleSheet.cssRules) {          
               cssRule = styleSheet.cssRules[ii];
            } else {                             
               cssRule = styleSheet.rules[ii];    
            }                                    
            if (cssRule)  {                      
               if (cssRule.selectorText.toLowerCase()==ruleName) { 
                  if (deleteFlag=='delete') {    
                     if (styleSheet.cssRules) {  
                        styleSheet.deleteRule(ii);
                     } else {                     
                        styleSheet.removeRule(ii);
                     }                            
                     return true;                 
                  } else {                        
                     return cssRule;              
                  }                               
               }                                  
            }                                     
            ii++;                                 
         } while (cssRule)                        
      }                                           
   }                                              
   return false;                                  
}                                                  

function killCSSRule(ruleName) {     
  return getCSSRule(ruleName,'delete');  
}                                         

function addCSSRule(ruleName) {       
  if (document.styleSheets) {        
    if (!getCSSRule(ruleName)) {    
      if (document.styleSheets[0].addRule) {       
        document.styleSheets[0].addRule(ruleName, null,0);
      } else {                   
        document.styleSheets[0].insertRule(ruleName+' { }', 0);
      }        
    }           
  }              
  return getCSSRule(ruleName);   
} 

function insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}

function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}




// I'm sure a lot of this stuff is crap that just needs to go...

// ------------------------------------------------------------
//  Additions to javascript native objects
// ------------------------------------------------------------

String.prototype.trim = function() {
   return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
   return this.replace(/^\s+/g,"");
}
String.prototype.rtrim = function() {
   return this.replace(/\s+$/g,"");
}

String.prototype.htmlEntities = function () {
   return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
};

Array.prototype.map = function(f) {
  var returnArray=[];
  for (i=0; i<this.length; i++) {
    returnArray.push(f(this[i]));
  }
  return returnArray;
}

Array.prototype.sortNum = function() {
   return this.sort( function (a,b) { return a-b; } );
}

Array.prototype.find = function(searchStr) {
  var returnArray = false;
  for (i=0; i<this.length; i++) {
    if (typeof(searchStr) == 'function') {
      if (searchStr.test(this[i])) {
        if (!returnArray) { returnArray = [] }
        returnArray.push(i);
      }
    } else {
      if (this[i]===searchStr) {
        if (!returnArray) { returnArray = [] }
        returnArray.push(i);
      }
    }
  }
  return returnArray;
}

// ------------------------------------------------------------
//  Ojax functions - orchid ajax 2009-09-15
// ------------------------------------------------------------

// Set up XML request object for Ajax requests
var os_xmlhttp;
var os_ajaxdata;

if( window.XMLHttpRequest )
{
    var os_xmlhttp = new XMLHttpRequest();   // Modern browsers...
}
else if( window.ActiveXObject )
{
    var os_xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");  // IE6 and older...
}

// ...................................................... ajaxRequest
// Submit an ajax request
//    url       where to send request
//    meth      method, e.g. POST or GET
//    query     the query string
//    callback  string to evaluate upon return
//
function os_ajaxRequest( url, query, meth, callback )
{
    os_xmlhttp.open( meth, url+query, true );
    os_xmlhttp.onreadystatechange=function()
    {
        if( os_xmlhttp.readyState == 4 )
        {
            os_ajaxdata = os_xmlhttp.responseText;
            eval( callback );
        }
    }
    os_xmlhttp.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
    os_xmlhttp.setRequestHeader( "Content-length", query.length );
    os_xmlhttp.setRequestHeader( "Connection", "close" );
    os_xmlhttp.send( query );
}


// ------------------------------------------------------------
//  AJAX functions
// ------------------------------------------------------------

// ...................................................... updateContent
// makes an ajax call to a url via GET and updates a container using the specified id
// 	
function updateContent( id, url  ) 
{
	if( YAHOO.util.Connect )
	{
		YAHOO.util.Connect.asyncRequest( "GET", url, {
			success: function(o) {
				document.getElementById( id ).innerHTML = o.responseText;
			}
		});
	}
}

/* ajax */ 
function OS_UpdateContent(area, url) {
	Spry.Utils.updateContent(area, url + '/OS_area/' + area);
}

/* effects */
function OS_Toggle(toggle, on, off) {
	toggle.start();
	document.getElementById(on).style.display = 'inline';		
	document.getElementById(off).style.display = 'none';		
}

function OS_HoverBox(url, title) {
	if(showIbox(url,title, '')) {
		showBG();	
		window.onscroll = maintPos;
		window.onresize = maintPos;		
	}
}

function OS_Hide(element) {
	document.getElementById(element).style.display =  'none';
}

function OS_Show(element) {
	document.getElementById(element).style.display = 'inline';
}

function OS_ToggleDisplay(element) {
	document.getElementById(element).style.display = '';
}

function OS_CookiesAllowed() {
   setCookie('checkCookie', 'test', 1);
   if (getCookie('checkCookie')) {
      deleteCookie('checkCookie');
      return true;
   }
   return false;
}

function OS_SetCookie(name,value,expires, options) {
   if (options===undefined) { options = {}; }
   if ( expires ) {
      var expires_date = new Date();
      expires_date.setDate(expires_date.getDate() + expires)
   }
   document.cookie = name+'='+escape( value ) +
      ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + 
      ( ( options.path ) ? ';path=' + options.path : '' ) +
      ( ( options.domain ) ? ';domain=' + options.domain : '' ) +
      ( ( options.secure ) ? ';secure' : '' );
}

function OS_GetCookie( name ) {
   var start = document.cookie.indexOf( name + "=" );
   var len = start + name.length + 1;
   if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
      return null;
   }
   if ( start == -1 ) return null;
   var end = document.cookie.indexOf( ';', len );
   if ( end == -1 ) end = document.cookie.length;
   return unescape( document.cookie.substring( len, end ) );
}

function OS_DeleteCookie( name, path, domain ) {
   if ( getCookie( name ) ) document.cookie = name + '=' +
      ( ( path ) ? ';path=' + path : '') +
      ( ( domain ) ? ';domain=' + domain : '' ) +
      ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

function OS_SetCookieArray(name){
    this.length = OS_SetCookieArray.arguments.length - 1;
        for (var i = 0; i < this.length; i++) {
        data = OS_SetCookieArray.arguments[i + 1]
        setCookie (name + i, data, expdate);
        }        
    }
	
/* get cookie string and return it as array. string should be , delimited */	
function OS_GetCookieArray(name) {
	var string = OS_GetCookie(name);
	return string.split(',');
}

/********************************************************
For more info & download: http://www.ibegin.com/blog/p_ibox.html
Created for iBegin.com - local search done right
MIT Licensed Style
Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*********************************************************/
var indicator_img_path = "https://commerce.orchidsuites.net/orchid/images/indicator.gif";
var indicator_img_html = "<img name=\"ibox_indicator\" src=\""+indicator_img_path+"\" alt=\"Loading...\" style=\"width:128px;height:128px;\"/>"; // don't remove the name

var opacity_level = 8; // how transparent our overlay bg is
var ibAttr = "rel"; 	// our attribute identifier for our iBox elements
	

var imgPreloader = new Image(); // create an preloader object
function init_ibox() {
	var elem_wrapper = "ibox";
	
	createIbox(document.getElementsByTagName("body")[0]); //create our ibox

	//	elements here start the look up from the start non <a> tags
	//var docRoot = (document.all) ? document.all : document.getElementsByTagName("*");
	
	// Or make sure we only check <a> tags
	/*
	var docRoot = document.getElementsByTagName("a");

	var e;
	for (var i = 0; i < docRoot.length - 1; i++) {
			e = docRoot[i];
			if(e.getAttribute(ibAttr)) {
				var t = e.getAttribute(ibAttr);
				if ((t.indexOf("ibox") != -1)  ||  t.toLowerCase() == "ibox") { // check if this element is an iBox element
						e.onclick = function() { // rather assign an onclick event
							var t = this.getAttribute(ibAttr);
							var params = parseQuery(t.substr(5,999));
							var url = this.href;
							if(this.target != "") {url = this.target} 
	
							var title = this.title;

							if(showIbox(url,title,params)) {
								showBG();
								window.onscroll = maintPos;
								window.onresize = maintPos;
							}
							return false;
						}; 
						
				}
			}
     }
	 */
}

showBG = function() {
	var box_w = getElem('ibox_w');
	

	box_w.style.opacity = 0;
	box_w.style.filter = 'alpha(opacity=0)';
	setBGOpacity = setOpacity;
	for (var i=0;i<=opacity_level;i++) {setTimeout("setIboxOpacity('ibox_w',"+i+")",70*i);} // from quirksmode.org
	
		
	box_w.style.display = "";
	var pagesize = new getPageSize();
	var scrollPos = new getScrollPos();
	var ua = navigator.userAgent;
	
	if(ua.indexOf("MSIE ") != -1) {box_w.style.width = pagesize.width+'px';} 
	/*else {box_w.style.width = pagesize.width-20+'px';}*/ // scrollbars removed! Hurray!
	box_w.style.height = pagesize.height+scrollPos.scrollY+'px';

}

hideBG = function() {
	var box_w = getElem('ibox_w');
	box_w.style.display = "none";

}

var loadCancelled = false;
showIndicator = function() {
	var ibox_p = getElem('ibox_progress');
	ibox_p.style.display = "";
	posToCenter(ibox_p);
	ibox_p.onclick = function() {hideIbox();hideIndicator();loadCancelled = true;}
}


hideIndicator = function() {
	var ibox_p = getElem('ibox_progress');
	ibox_p.style.display = "none";
	ibox_p.onclick = null;
}

createIbox = function(elem) {
	// a trick on just creating an ibox wrapper then doing an innerHTML on our root ibox element
	var strHTML = "<div id=\"ibox_w\" style=\"display:none;\"></div>";
	strHTML +=	"<div id=\"ibox_progress\" style=\"display:none;\">";
	strHTML +=  indicator_img_html;
	strHTML +=  "</div>";
	strHTML +=	"<div id=\"ibox_wrapper\" style=\"display:none\">";
	strHTML +=	"<div id=\"ibox_content\"></div>";
	strHTML +=	"<div id=\"ibox_footer_wrapper\"><div id=\"ibox_close\" style=\"float:right;\">";
	strHTML +=	"<a id=\"ibox_close_a\" href=\"javascript:void(null);\" >Click here to close</a></div>";
	strHTML +=  "<div id=\"ibox_footer\">&nbsp;</div></div></div></div>";

	var docBody = document.getElementsByTagName("body")[0];
	var ibox = document.createElement("div");
	ibox.setAttribute("id","ibox");
	ibox.style.display = '';
	ibox.innerHTML = strHTML;
	elem.appendChild(ibox);
}

var ibox_w_height = 0;
showIbox = function(url,title,params) {
	
	var ibox = getElem('ibox_wrapper');
	var ibox_type = 0;
												
	// set title here
	var ibox_footer = getElem('ibox_footer');
	if(title != "") {ibox_footer.innerHTML = title;} else {ibox_footer.innerHTML = "&nbsp;";}
	
	// file checking code borrowed from thickbox
	var urlString = /\.jpg|\.jpeg|\.png|\.gif|\.html|\.htm|\.php|\.cfm|\.asp|\.aspx|\.jsp|\.jst|\.rb|\.rhtml|\.txt/g;
	
	var urlType = url.match(urlString);

	if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif'){
		ibox_type = 1;
	} else if(url.indexOf("#") != -1) {
		ibox_type = 2;
	} else if(urlType=='.htm'||urlType=='.html'||urlType=='.php'||
			 urlType=='.asp'||urlType=='.aspx'||urlType=='.jsp'||
			 urlType=='.jst'||urlType=='.rb'||urlType=='.txt'||urlType=='.rhtml'||
			 urlType=='.cfm') {
		ibox_type = 3;
	} else {
		// override our ibox type if forced param exist
		if(params['type']) {ibox_type = parseInt(params['type']);}
		else{hideIbox();return false;}
	}
	
	ibox_type = parseInt(ibox_type);


	switch(ibox_type) {
		
		case 1:

			showIndicator();
			
			imgPreloader = new Image();
			
			imgPreloader.onload = function(){
	
				imgPreloader = resizeImageToScreen(imgPreloader);
				hideIndicator();
	
				var strHTML = "<img name=\"ibox_img\" src=\""+url+"\" style=\"width:"+imgPreloader.width+"px;height:"+imgPreloader.height+"px;border:0;cursor:hand;margin:0;padding:0;position:absolute;\"/>";
	
				if(loadCancelled == false) {
					
					// set width and height
					ibox.style.height = imgPreloader.height+'px';
					ibox.style.width = imgPreloader.width+'px';
				
					ibox.style.display = "";
					ibox.style.visibility = "hidden";
					posToCenter(ibox); 	
					ibox.style.visibility = "visible";

					setIBoxContent(strHTML);
				}
					
			}
			
			loadCancelled = false;
			imgPreloader.src = url;
			
			break;

		case 2:
			
			var strHTML = "";

			
			if(params['height']) {ibox.style.height = params['height']+'px';} 
			else {ibox.style.height = '280px';}
			
			if(params['width']) {ibox.style.width = params['width']+'px';} 
			else {ibox.style.width = '450px';}

		
			ibox.style.display = "";
			ibox.style.visibility = "hidden";
			posToCenter(ibox); 	
			ibox.style.visibility = "visible";
			
			getElem('ibox_content').style.overflow = "auto";
			
			var elemSrcId = url.substr(url.indexOf("#") + 1,1000);
			
			var elemSrc = getElem(elemSrcId);
			
			if(elemSrc) {strHTML = elemSrc.innerHTML;}
		
			setIBoxContent(strHTML);
			
			break;
			
		case 3:
			showIndicator();
			http.open('get',url,true);

			http.onreadystatechange = function() {
				if(http.readyState == 4){
					hideIndicator();
					
					if(params['height']) {ibox.style.height = params['height']+'px';} 
					else {ibox.style.height = '280px';}
					
					if(params['width']) {ibox.style.width = params['width']+'px';} 
					else {ibox.style.width = '450px';}
		
					ibox.style.display = "";
					ibox.style.visibility = "hidden";
					posToCenter(ibox); 	
					ibox.style.visibility = "visible";
					getElem('ibox_content').style.overflow = "auto";
					
					var response = http.responseText;
					setIBoxContent(response);
					
				}
			}
			
			http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
			http.send(null);
			break;
		
		default:
			
	 } 
	 
	
	ibox.style.opacity = 0;
	ibox.style.filter = 'alpha(opacity=0)';	
	var ibox_op_level = 10;
	
	setIboxOpacity = setOpacity;
	for (var i=0;i<=ibox_op_level;i++) {setTimeout("setIboxOpacity('ibox_wrapper',"+i+")",30*i);}

	if(ibox_type == 2 || ibox_type == 3) {
		ibox.onclick = null;getElem("ibox_close_a").onclick = function() {hideIbox();}
	} else {ibox.onclick = hideIbox;getElem("ibox_close_a").onclick = null;}

	return true;
}

setOpacity = function (elemid,value)	{
		var e = getElem(elemid);
		e.style.opacity = value/10;
		e.style.filter = 'alpha(opacity=' + value*10 + ')';
}

resizeImageToScreen = function(objImg) {
	
	var pagesize = new getPageSize();
	
	var x = pagesize.width - 100;
	var y = pagesize.height - 100;

	if(objImg.width > x) { 
		objImg.height = objImg.height * (x/objImg.width); 
		objImg.width = x; 
		if(objImg.height > y) { 
			objImg.width = objImg.width * (y/objImg.height); 
			objImg.height = y; 
		}
	} 

	else if(objImg.height > y) { 
		objImg.width = objImg.width * (y/objImg.height); 
		objImg.height = y; 
		if(objImg.width > x) { 
			objImg.height = objImg.height * (x/objImg.width); 
			objImg.width = x;
		}
	}

	return objImg;
}

maintPos = function() {
	
	var ibox = getElem('ibox_wrapper');
	var box_w = getElem('ibox_w');
	var pagesize = new getPageSize();
	var scrollPos = new getScrollPos();
	var ua = navigator.userAgent;

	if(ua.indexOf("MSIE ") != -1) {box_w.style.width = pagesize.width+'px';} 
	/*else {box_w.style.width = pagesize.width-20+'px';}*/

	if(ua.indexOf("Opera/9") != -1) {box_w.style.height = document.body.scrollHeight+'px';}
	else {box_w.style.height = pagesize.height+scrollPos.scrollY+'px';}
	
	// alternative 1
	//box_w.style.height = document.body.scrollHeight+50+'px';	
	
	posToCenter(ibox);
	
}

hideIbox = function() {
	hideBG();
	var ibox = getElem('ibox_wrapper');
	ibox.style.display = "none";

	clearIboxContent();
	window.onscroll = null;
}

posToCenter = function(elem) {
	var scrollPos = new getScrollPos();
	var pageSize = new getPageSize();
	var emSize = new getElementSize(elem);
	var x = Math.round(pageSize.width/2) - (emSize.width /2) + scrollPos.scrollX;
	var y = Math.round(pageSize.height/2) - (emSize.height /2) + scrollPos.scrollY;	
	elem.style.left = x+'px';
	elem.style.top = y+'px';	
}

getScrollPos = function() {
	var docElem = document.documentElement;
	this.scrollX = self.pageXOffset || (docElem&&docElem.scrollLeft) || document.body.scrollLeft;
	this.scrollY = self.pageYOffset || (docElem&&docElem.scrollTop) || document.body.scrollTop;
}

getPageSize = function() {
	var docElem = document.documentElement
	this.width = self.innerWidth || (docElem&&docElem.clientWidth) || document.body.clientWidth;
	this.height = self.innerHeight || (docElem&&docElem.clientHeight) || document.body.clientHeight;
}

getElementSize = function(elem) {
	this.width = elem.offsetWidth ||  elem.style.pixelWidth;
	this.height = elem.offsetHeight || elem.style.pixelHeight;
}

setIBoxContent = function(str) {
	clearIboxContent();
	var e = getElem('ibox_content');
	e.style.overflow = "auto";
	e.innerHTML = str;
	
}
clearIboxContent = function() {
	var e = getElem('ibox_content');
	e.innerHTML = "";

}




getElem = function(elemId) {
	return document.getElementById(elemId);	
}

// parseQuery code borrowed from thickbox, Thanks Cody!
parseQuery = function(query) {
   var Params = new Object ();
   if (!query) return Params; 
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;

   }
   
   return Params;
}

/********************************************************
 Make this IE7 Compatible ;)
 http://ajaxian.com/archives/ajax-on-ie-7-check-native-first
*********************************************************/
createRequestObject = function() {
	var xmlhttp;
		/*@cc_on
	@if (@_jscript_version>= 5)
			try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
					try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
					catch (E) {xmlhttp = false;}
			}
	@else
		xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != "undefined") {
			try {xmlhttp = new XMLHttpRequest();} catch (e) {xmlhttp = false;}
	}
	return xmlhttp;
}

var http = createRequestObject();

function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}
addEvent(window, 'load', init_ibox);

tempDIV.className = 'overlibdiv';

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}