
var rexUSZip = /^[0-9]{5}(-[0-9]{4})?$/;
var rexCAZip = /^[A-Z][0-9][A-Z]\s*[0-9][A-Z][0-9]$/i;

function tbTest_focus(e,o){
   if(o.firstTime){return}
      o.firstTime=true
      o.value=""
}

//---------------------------------------------------------
function cookiesEnabled()
{   
    var bEn = false;

    try {
        ArtSetCookie("testcookie", "testcookie");
        bEn = (ArtGetCookie("testcookie")=='testcookie') ? true : false;
        ArtDeleteCookie("testcookie");
    }
    catch (e) { }
    
    return bEn;
}

function ArtSetCookie(c_name,value,expiredays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    "; path=/"+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function ArtDeleteCookie(c_name) {
    document.cookie=c_name+ "="+
    ";path=/"+
    ";expires=expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function ArtGetCookie(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 showMessageBox(sType, sMessage, sImagePath)
{   
    if(!cookiesEnabled())
    {   
        document.write("<div class='messagebox_" + sType + "'><table cellpadding=0 cellspacing=0 border=0><tr><td valign=top><div class='icon' style='background-image: url(\"" + sImagePath + sType + ".gif\");'></div></td><td valign=top><div class='content'><div class='message'>" + sMessage + "</div></div></td></tr></table></div>");
    }
}

//---------------------------------------------------------
function formatCurrency(num, sSymbol)
{
	try
	{
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num)) num = "0";
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10) cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (sSymbol + num + '.' + cents);
	}
	catch(err)
	{
		return (sSymbol + "0.00");
	}
}
		
//---------------------------------------------------------
function getElementPosition(el)
{
	// Initializes the Coordinates object that will be returned by the function.
	var c = { x:0, y:0 } ;
	
	//go through the offset chain.
	while(el)
	{
		c.x += el.offsetLeft ;
		c.y += el.offsetTop ;
		el = el.offsetParent ;
	}

	// Return the Coordinates object
	return c;
}

//--------------------------------------------------------
function oJSONScriptReq(sURL)
{
	this.sSource = sURL;
	this.oObject = null;
	this.sId = "JSONScriptReq_" + oJSONScriptReq.sIdCounter;
	oJSONScriptReq.sIdCounter++;
}

//--------------------------------------------------------
oJSONScriptReq.sIdCounter = 1;

//--------------------------------------------------------
oJSONScriptReq.prototype.inject = function ()
{
	this.oObject = document.createElement("SCRIPT");
	this.oObject.setAttribute("type", "text/javascript");
	this.oObject.setAttribute("charset", "utf-8");
	this.oObject.setAttribute("src", this.sSource);
	this.oObject.setAttribute("id", this.sId);
  
  //inject
  document.getElementsByTagName("head").item(0).appendChild(this.oObject);
}

//---------------------------------------------------------
function injectScript(sSource)  
{ 
	var oReq = new oJSONScriptReq(sSource);
	oReq.inject();
} 

//---------------------------------------------------------
function fixLayerPNG()
{
	var aBaseClass = new Array("cando_floatie");
	var aSubClass = new Array("TR","TL","TM","MR","ML","BR","BL");
	
	var aEl = new Array;
	for(var i=0; i<aBaseClass.length; i++)
	{
		for(var j=0; j<aSubClass.length; j++)
		{
			//find all the floating layer elements and change then to use gifs
			aEl = aEl.concat(document.getElementsByClassName(aBaseClass[i] + "_" + aSubClass[j]));
		}
	}
	
	var sImg;
	for(var i=0; i<aEl.length; i++)
	{
		sImg = aEl[i].style.backgroundImage;
		aEl[i].style.backgroundImage = sImg.replace(/\.png/i,".gif");
	}
}

//---------------------------------------------------------
function MM_preloadImages() {
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

