﻿/* ********** Global vars and prototype functions ********** */
var _dayNames = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
var _dayLongNames = new Array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
var _monthNames = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var _monthLongNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
if (!Array.prototype._indexOf)
{
    Array.prototype._indexOf = function(elt)
    {
        var len = this.length;

        var from = Number(arguments[1]) || 0;
        from = (from < 0) ? Math.ceil(from) : Math.floor(from);
        if (from < 0)
            from += len;

        for (; from < len; from++)
        {
            if (from in this && this[from] === elt)
            return from;
        }
        return -1;
    };
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
String.prototype.RGBtoHex = function()
{
    var toHex = function(N)
    {
         if (N==null) 
            return "00";
         N=parseInt(N); 
         if (N==0 || isNaN(N)) 
            return "00";
         N=Math.max(0,N); 
         N=Math.min(N,255); 
         N=Math.round(N);
         return "0123456789ABCDEF".charAt((N-N%16)/16)
              + "0123456789ABCDEF".charAt(N%16);
    }
    
    rgb = this;
    if (rgb.indexOf("#") > -1)
    {
        return rgb.substring(1);
    }
    else
    {
        rgb = this.replace("rgb","").replace("(","").replace(")","").split(",");
        return toHex(rgb[0])+toHex(rgb[1])+toHex(rgb[2]);
    }
}

/* ---------- /Global vars and prototype functions ---------- */

function PageLoaded()
{    
    // Reset .net form action
    document.forms[0].action = window.location.href;    
    
    if (jQuery.browser.version == 6 && jQuery.browser.msie)
    {
        alert("Your browser is Microsoft Internet Explorer 6.\n\nWe highly recommend udating to the newer version (8) or installing the more secure web browser,\n Firefox - www.getfirefox.com");
    }
    
    InitCleverInputs();
	
	$(function(){
	    $('.scroll-pane').jScrollPane({scrollbarWidth:7});
    });	
    
    $("a.about").fancybox(); 
}

function InitCleverInputs()
{
	jQuery('.clever-input').each(function(){
		$this = jQuery(this);
		$this.data("text", { value : $this.attr("title") });
		$this
			.bind('click', function(){
				$this = jQuery(this);
				if ($this.val() == $this.data('text').value)
				{
					$this.val('')
				}
			})
			.blur(function(){
				$this = jQuery(this);
				if ($this.val() == '')
				{
					$this.val($this.data('text').value);
				}
			});
	});
}
