// base object
_S = new Object();
// core variables
_S.V = new Object();
// hooks
_S.__H = new Array();
_S.__H[0] = new Array();
_S.__H[1] = new Array();
_S.__H[2] = new Array();

_W = window;
_D = window.document;

var _L = new Array();

// screen dimensions
_S.V.SW = (screen?(screen.availWidth?screen.availWidth:screen.width):640);
_S.V.SH = (screen?(screen.availHeight?screen.availHeight:screen.height):480);

// popup default width/height values
_S.V.PW = '700';
_S.V.PH = '600';
_S.V.PR = 1; //sizeable
_S.V.PSB = 1; // scrollbar


_S.V.__page_load_chk = -1;


// open window
_S.W = function(U,T,P){
	return window.open(U,T,P);
}


// main popup. only url is required
_S.P = function(U,pW,pH,bSB,bM,bRT){
  var X,Y,W,H,O,bFS;
	W=pW?pW:_S.V.PW;
	H=pH?pH:_S.V.PH;
	X=(_S.V.SW>W?((_S.V.SW/2)-(W/2)):0);
	Y=(_S.V.SH>H?((_S.V.SH/2)-(H/2)):0);
	bFS = (_S.V.SW<W||_S.V.SH<H);
	O=_S.W(U,"","scrollbars="+(((typeof(bSB)=="undefined"?_S.V.PSB:bSB)||bFS)?1:0)+",toolbar=0,status=0,menubar=0,directories=0,resizable="+((_S.V.PR||bFS)?'1'+(bFS?',maximized=1':''):0)+",location=0,"+(screen?"width="+(_S.V.SW<W?_S.V.SW:W)+",height="+(_S.V.SH<H?_S.V.SH:H)+",":'')+"left="+X+",top="+Y+",screenX="+X+",screenY="+Y+',modal='+(bM?1:0));
//	O.opener=self;
	if(O.focus){O.focus()};
	if(bRT){return O};
};

// popup dialog
_S.PD = function(U,pW,pH,bSB){
	return _S.P(U,pW,pH,bSB,1);
}

// popup text
_S.PT = function(T,pW,pH,bSB){
	var k=_S.P('',pW,pH,bSB,1,1);var d=k.document;d.write("<html><head></head><body style='background-color:#fff;margin:0;padding:0;'>"+T+"</body></html>");d.close();
}

_S.PP = function(U,W,H){
	var k=_S.P('',W,H,0,0,1);var d=k.document;d.write("<html><head><title>"+W+"x"+H+"</title></head><body style='background-color:#fff;margin:0;padding:0;'><a href='javascript:close()' style='display: block' title='Click to close'><img src='"+U+"' width='"+W+"' height='"+H+"' border='0' alt='Click to close'></a></body></html>");d.close();
}



function _G(id){
	if(document.getElementById){return document.getElementById(id+'');}else{return false;}
}

function _GA(o,id){
	var t='';if(typeof(o)=='object'){if(o.getAttribute){t = o.getAttribute(id+'');};return t;};
}

// add hook
_S.H = function(n,f,t){
	var p = t=='before'?0:(t=='after'?2:1);
	if(typeof(_S.__H[p][n])!='object')
	{
		_S.__H[p][n]=new Array();
	};
	_S.__H[p][n][f]=true;
}

// del hook
_S.HD = function(n,f){
	if(typeof(_S.__H[1][n])!='object'){return;};_S.__H[1][n][f]=false;
}

// reset hook
_S.HR = function(n){
	_S.__H[1][n]=new Array();
}

// count hook
_S.HC = function(n,t){
	var p=t=='before'?0:(t=='after'?2:1),i=0,f;if(typeof(_S.__H[p][n])!='object'){return 0;};for(f in _S.__H[p][n]){if(_S.__H[p][n][f]){i++;};};return i;
}

// exec hook
_S.HE = function(n,bR,p1,p2,p3,p4,p5){
	_S.HE0(n,'before',false,p1,p2,p3,p4,p5);_S.HE0(n,0,bR,p1,p2,p3,p4,p5);_S.HE0(n,'after',false,p1,p2,p3,p4,p5);
}
_S.HE0 = function(n,t,bR,p1,p2,p3,p4,p5){
	var f,p=t=='before'?0:(t=='after'?2:1);if(typeof(_S.__H[p][n]) == 'object'){for(f in _S.__H[p][n]){if(_S.__H[p][n][f] == true && typeof(eval(f)) == 'function'){eval(f)(p1,p2,p3,p4,p5);};};if(bR){_S.HR(n);};};
}




// basic hooks
_W.onload = function(){
	if(_S.V.__page_load_chk >= 0)
	{
		_S.SHD(_S.V.__page_load_chk);
		_S.V.__page_load_chk = -1;
		_S.HE('Page_OnLoad');
	}

	if(_W.opener)
	{
		try {
			_W.opener.__current_dialog = _W;
		}catch(e){};
	}



	if(_S.b.ie)
	{
	    theObjects = document.getElementsByTagName("object");
	    for (var i = 0; i < theObjects.length; i++)
	    {
		theObjects[i].outerHTML = theObjects[i].outerHTML;
		theObjects[i].play();
	    }
	}
								    


	_S.HE('Window_OnLoad');
}
document.onclick = function(){
	_S.HE('Window_OnClick');
}
_W.onmousedown = function(){
	_S.HE('Window_OnClick');
}
_W.onfocus = function(){
	_S.HE('Window_OnFocus');
}
_W.onunload = function(){
	_S.HE('Window_OnUnload');
}
if(typeof(_W.onresizeend) == 'function')
{
	_W.onresizeend = function(){
		_S.HE('Window_OnResize');
	}
}else{
	_W.onresize = function(){
		_S.HE('Window_OnResize');
	}
}

/*
window.document.oncontextmenu = function(e){
	return false;
}
*/

// browser ident
_S.b = new Object();
_ua = navigator.userAgent.toUpperCase();
_S.b.mac = (_ua.indexOf("MAC") != -1) ? true : false;
_S.b.opera = (_ua.indexOf("OPERA") != -1) ? true : false;
_S.b.safari = (_ua.indexOf("SAFARI") != -1) ? true : false;
_S.b.ie = ((document.all&&!_S.b.opera) ? true : false);




// string functions
function T(s){
	s = (s+''); while(1){if(s.charAt(0)==' '){s = s.substring(1,s.length);}else{break;};};while(1){if(s.charAt(s.length-1)==' '){s = s.substring(0,s.length-1);}else{break;};};return s;
}
function UC(s){
	return (s+'').toUpperCase();
}
function LC(s){
	return (s+'').toLowerCase();
}

function pad(s,l,p){
	var i,r=(s+'');for(i=s.length;i<l;i++){r=p+r;};return r;
}



// get cookie (name)
_S.C = function(n){
 var dc=document.cookie,p=n+"=",b=dc.indexOf("; "+p),e; if(b == -1){b=dc.indexOf(p);if(b != 0) return null;}else{b += 2;};e=dc.indexOf(";",b);if(e == -1){e = dc.length;};return unescape(dc.substring(b+p.length,e));
}
// set cookie (name, value, days = 1)
_S.CS = function(n,v,d){
 var t = new Date(),e=t;if (d==null||d==0)d=1;e.setTime(t.getTime() + 3600000*24*d);document.cookie=n+"="+escape(v)+"; expires="+e.toGMTString()+'; path=/';
}
// del cookie (name, path, domain = '')
_S.CD = function(n,p,d){
 if(_S.C(n)){document.cookie=n+"="+((p)?"; path="+p:"")+((d)?"; domain="+d:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";};
}






_ie_use_bg = true;

// create iframe
_S._FL = function(id){
  var o;
	o = document.createElement("IFRAME");
	o.style.display = "none";
	document.body.appendChild(o);
	if(id)
	{
		o.id = id;
	}
	return o;
}

// show layer
_S.LS = function(o, x, y, w, h, c, s){
 var bg,bs,os;
	if(!o)
	{
		o = document.createElement("DIV");
		o.style.display = "none";
		document.body.appendChild(o);
	}
	os = o.style;

	o.className += " visible";
	os.position = "absolute";
	os.display = "block";
	os.zIndex = 99;

	if(x>=0)
	{
		os.left = x + 'px';
	}
	if(y>=0)
	{
		os.top = y + 'px';
	}
	if(w>0)
	{
		os.width = w + 'px';
	}
	if(h>0)
	{
		os.height = h + 'px';
	}


	if((c!='undefined') && (c!=null))
	{
		o.innerHTML = c;
	}


	if(_S.b.ie && _ie_use_bg)
	{
		bg = o.getAttribute('_ie_bg');

		if(!bg)
		{
			bg = _S._FL();
			o.setAttribute('_ie_bg', bg);
		}

		bs = bg.style;
		bs.overflow = 'hidden';
		bs.zIndex = 98;
		bs.position = "absolute";
		if(x>=0)
		{
			bs.left = x + 'px';
		}
		if(y>=0)
		{
			bs.top = y + 'px';
		}
		bs.width = (w>0?w:o.clientWidth) + 'px';
		bs.height = (h>0?h:o.clientHeight) + 'px';
		bs.display = "block";
	}

	return o;
}


// hide layer
_S.LH = function(o){
 var bg;
	if(o)
	{
		if(_S.b.ie && _ie_use_bg)
		{
			bg = o.getAttribute('_ie_bg');
			bg.style.display = "none";
		}
		o.style.display = "none";
		o.className = o.className.replace("visible",'');
	}
}







// scheduler
// add task (fn,delay ms)
_S.SH = function(f,n){
	var i,k=_S.__SH.length,t=100,m;id = k;for(i=k-1;i>=0;i--){if(_S.__SH[i]==null){id = i;};if(_S.__SH[i]!=null){m=_S.__SH[i][1];t=(m<t)&&(t>0)?m:t;}};_S.__SH[id]=Array(f,n,0);_S.__SH_T = t;if(_S.__SH_O == null){_S.__SHE();};return id;
}
// remove task
_S.SHD = function(id){
	_S.__SH[id]=null;
}
// internal handler
_S.__SHE = function(){
	var i,a=_S.__SH,k=a.length,f,d,m;for(i=0;i<k;i++){if(a[i]!=null){f=a[i][0];m=a[i][1];d=a[i][2];if(d>m){eval(f);if(_S.__SH[i]!=null){_S.__SH[i][2]=0;}};if(_S.__SH[i]!=null){_S.__SH[i][2] +=_S.__SH_T;}}};_S.__SH_O = setTimeout('_S.__SHE()', _S.__SH_T);
}
// remove all tasks
_S.SHR = function(){
	if(_S.__SH_O != null){clearTimeout(_S.__SH_O);};
	_S.__SH = new Array();
	_S.__SH_O = null;
	_S.__SH_T = 0;
}
_S.SHR();//init







function sprintf()
{
	if(!arguments || arguments.length < 1 || !RegExp)
	{
		return;
	}
	
	var str = arguments[0];
	var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
	var a = b = [], numSubstitutions = 0, numMatches = 0;

	while (a = re.exec(str))
	{
		var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
		var pPrecision = a[5], pType = a[6], rightPart = a[7];
				
		//alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision);

		numMatches++;

		if (pType == '%')
		{
			subst = '%';
		}else{
			numSubstitutions++;

			if(numSubstitutions >= arguments.length)
			{
				alert('sprintf :: Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).');
			}
					
					var param = arguments[numSubstitutions];
					var pad = '';
					       if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
					  else if (pPad) pad = pPad;
					var justifyRight = true;
					       if (pJustify && pJustify === "-") justifyRight = false;
					var minLength = -1;
					       if (pMinLength) minLength = parseInt(pMinLength);
					var precision = -1;
					       if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
					var subst = param;
					       if (pType == 'b') subst = parseInt(param).toString(2);
					  else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
					  else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
					  else if (pType == 'u') subst = Math.abs(param);
					  else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
					  else if (pType == 'o') subst = parseInt(param).toString(8);
					  else if (pType == 's') subst = param;
					  else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
					  else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
				}
				str = leftpart + subst + rightPart;
	}

	return str;
}








function toDbl(s)
{
  var v, t, i, sign;

        v = '';
	t = trim(s);
	sign = t.charAt(0)=='-' ? '-' : '';
	sign = t.charAt(0)=='(' ? '-' : sign;

	for(i=0; i<t.length; i++)
	{
		if(t.charAt(i) == '0' || t.charAt(i) == '.' || t.charAt(i) * 1 > 0)
		{
			v += t.charAt(i);
		}
	}

	v = parseFloat(sign + v, 10);
	return  v ? v : 0;
}



function toCur(s)
{
  var v, i, j, t, m, sign;
	v = (toDbl(s) + '').replace(')','');
	i = v.indexOf('.');
        t = i>=0 ? v.substr(i,3) : '.00';
        v = i>=0 ? v.substr(0,i) : v;
	m = '';
	j = 0;

	sign = v.charAt(0)=='-' ? '-' : '';
	sign = v.charAt(0)=='(' ? '-' : sign;

	for(i=v.length-1; i>=(sign==''?0:1); i--)
	{
	        m = v.charAt(i) + ((j%3==0)&&(j>0)?',':'') + m;
		j++;
	}
	return (sign=='-'?'(':'')+'$'+m+t+(t.length==2?'0':(t.length==1?'00':''))+(sign=='-'?')':'');
}













function days_in_month(y, m){
	var days = Array(31, (y%4)==0?29:28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); return days[m - 1];
}



function _prompt(t, v, title)
{
	if(window.showModalDialog)
	{
		return window.showModalDialog(__site_index+"?action=prompt&title="+escape(title?title:"Attention Required")+'&query='+escape(t)+'&value='+escape(v?v:''), "", "dialogWidth:300px;dialogHeight:185px;center:yes;edge:sunken;help:no;resizable:no;scroll:no;status:0;unadorned:1");
	}else{
		return prompt(t, v ? v : '');
	}
}

function _confirm(text,title,byes,bno)
{
	if(window.showModalDialog)
	{
		return window.showModalDialog(__site_index+"?action=confirm&title="+escape(title?title:"Attention Required")+'&text='+escape(text)+'&byes='+escape(byes?byes:"Yes")+'&bno='+escape(bno?bno:"No"), "", "dialogWidth:600px;dialogHeight:125px;center:yes;edge:sunken;help:no;resizable:no;scroll:no;status:0;unadorned:1");
	}else{
		return confirm(text);
	}
}







// months as they appear in the calendar's title
_L['MONTHS'] = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
// week day titles as they appear on the calendar
_L['WEEKDAYS'] = new Array("Su", "Mo", "Tu", "We", "Th", "Fr", "Sa");
// day week starts from (normally 0-Su or 1-Mo)
_L['WEEKSTART'] = 0;
_L['TODAY'] = 'Today';
_L['DATE_FMT'] = '%Y-%M-%D';
_L['DATE_FMT_PARSER'] = function(v){var a=v.split('-'); return a[1]+'/'+a[2]+'/'+a[0];};





function calendar(p1,p2,e)
{
var a,i,t='',n,b=true,v,bd=true,dv=new Date(),d0=new Date(),Y,M;

	calendar.lrt = 1;

	if(typeof(p1)=='object')
	{
		calendar.x = (window.event ? window.event.clientX: (e ? (e.pageX ? e.pageX : 0) : 0));
		calendar.y = (window.event ? window.event.clientY: (e ? (e.pageY ? e.pageY : 0) : 0));

		this._o = p1;
		this._o2 = p2;

		v = UC(T(p1.value));
		if((v!='')&&(v!='FROM')&&(v!='TO'))
		{
			dv = new Date(typeof _L['DATE_FMT_PARSER']=='function' ? _L['DATE_FMT_PARSER'](v) : v);
		}
	}else{
		switch(p1)
		{
			case 'set':
				a = p2.split('|');
				dv = new Date(a[0]*1,a[1]*1);
				break;
			case 'select':

				if(typeof(this._o)=='object')
				{
					a = p2.split('-');
					this._o.value = (_L['DATE_FMT']+'').replace('%Y',a[0]).replace('%M',pad(a[1],2,'0')).replace('%D',pad(a[2],2,'0'));
				}
				if(this._o2 != null)
				{
					if(typeof(this._o2)=='object')
					{
						this._o2.value = this._o.value;
					}
				}
				_S.LH(this.lr);
				bd = false;
				break;
			case 'close':
				_S.LH(this.lr);
				bd = false;
				break;
		}
	}

	Y = dv.getYear();
	M = dv.getMonth();
	Y = Y<1000?Y+1900:Y;

	var d3,d1=new Date(Y,M,1),d2=new Date(Y,M+1,0),d=d2.getDate(),w=d1.getDay()+1;

	if(bd)
	{
		d0 = new Date(d0.getYear(),d0.getMonth(),d0.getDate());

		for(i=0; i<7; i++)
		{
			n=(_L['WEEKSTART']+i)%7;
			t += '<th'+(n==0||n==6?' class="weekend"':'')+'>'+_L['WEEKDAYS'][n]+'</th>';
		}
		t='<table border=1 class="calendar"><caption>'+_L['MONTHS'][M]+', '+Y+'</caption><tr><td><a href="javascript:calendar(&quot;set&quot;,&quot;'+(Y-1)+'|'+M+'&quot;)">&lt;&lt;</a></td><td><a href="javascript:calendar(&quot;set&quot;,&quot;'+Y+'|'+(M-1)+'&quot;)">&lt;</a></td><td colspan="3" class="now"><a href="javascript:calendar(&quot;set&quot;,&quot;'+d0.getYear()+'|'+d0.getMonth()+'&quot;)">'+_L['TODAY']+'</a></td><td><a href="javascript:calendar(&quot;set&quot;,&quot;'+Y+'|'+(M+1)+'&quot;)">&gt;</a></td><td><a href="javascript:calendar(&quot;set&quot;,&quot;'+(Y+1)+'|'+M+'&quot;)">&gt;&gt;</a></td></tr><tr>'+t+'</tr>';


		i=1;
		while(b)
		{
			t+='<tr>';
			for(n=1;n<=7;n++)
			{
				v='';
				if(!((i==1)&&(n<w)))
				{
					if(b)
					{
						v = i;
					}
					i++;
				}
				if(i>d)
				{
					b=false;
				}
				d3=new Date(Y,M,v);
				t+='<td class="'+(n==1||n==7?'weekend':'')+(d0.toString()==d3.toString()?' today':'')+'">'+ (v==''?'&nbsp;':'<a href="javascript:calendar(&quot;select&quot;,&quot;'+(Y)+'-'+(M+1)+'-'+v+'&quot;)">'+v+'</a>') +'</td>';
			}
			t+='</tr>';
		}
		t+='</table>';

		this.lr = _S.LS(this.lr,calendar.x,calendar.y,0,0,t,'');
		i = this.lr.clientWidth + calendar.x;
		if(i>_D.body.clientWidth)
		{
			_S.LS(this.lr,_D.body.clientWidth-this.lr.clientWidth-10,calendar.y,0,0,t,'');
		}
	}
}

function add_cal()
{
	calendar(document.forms['test']['field1']);
}
//_S.H('Page_OnLoad','add_cal');



function calendar_close()
{
	if(calendar.lrt==0)
	{
		calendar('close');
	}
	calendar.lrt = 0;
}
//_S.H('Window_OnClick','calendar_close');









var digitArray = new Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
function toHex(n)
{
    var result = ''
    var start = true;
    for (var i=32; i>0;)
	{
        i-=4;
        var digit = (n>>i) & 0xf;
        if (!start || digit != 0)
		{
            start = false;
            result += digitArray[digit];
        }
    }
    return (result==''?'0':result);
}

function ntos(n)
{
    n=n.toString(16);
    if (n.length == 1) n="0"+n;
    n="%"+n;
    return unescape(n);
}



function encodeHex(str)
{
    var result = "";
    for (var i=0; i<str.length; i++)
	{
        result += pad(toHex(str.charCodeAt(i)&0xff),2,'0');
    }
    return result;
}

function decodeHex(str)
{
    str = str.replace(new RegExp("s/[^0-9a-zA-Z]//g"));
    var result = "";
    var nextchar = "";
    for (var i=0; i<str.length; i++){
        nextchar += str.charAt(i);
        if (nextchar.length == 2){
            result += ntos(eval('0x'+nextchar));
            nextchar = "";
        }
    }
    return result;
    
}




function page_load_checker() {
	if(document.body)
	{
		var c = document.body.innerHTML;
		if((c.indexOf('=footer>') > 0) || (c.indexOf('="footer">') > 0))
		{
			_S.SHD(_S.V.__page_load_chk);
			_S.V.__page_load_chk = -1;
			_S.HE('Page_OnLoad');
		}
	}
}
_S.V.__page_load_chk = _S.SH('page_load_checker()', 5);




function FAQ_Switch(id)
{
	var dd = _G('faq_dd_'+id);
	var a = _G('faq_a_'+id);

	if(dd.className.indexOf('hidden')>=0)
	{
		dd.className = dd.className.replace(/\s*hidden/ig, '');
	}else{
		dd.className += 'hidden';
	}


	var t = a.title;
	a.title = a.innerHTML;
	a.innerHTML = t;
}




__subsr_t = 'enter your e-mail';


var g_x=0,g_y=0;



function SUBSCR_Set()
{
	if(document.forms['subscribe'])
	{
		var o = document.forms['subscribe']['email'];
		if(o)
		{
			document.forms['subscribe'].onsubmit = function(){
				var o = this['email'];
				if(o.value == __subsr_t || T(o.value)=='' || o.value.indexOf('@')<=0)
				{
					alert(__subsr_t);
					return false;
				}
				return true;
			}

			if(o.value=='' || o.value==__subsr_t)
			{
				o.value=__subsr_t;
			}
		}
		o.onclick = function(){
			if(this.value==__subsr_t)
			{
				this.value='';
			}
		}
		o.onblur = function(){
			if(T(this.value)=='')
			{
				this.value=__subsr_t;
			}
		}
	}

	document.body.onmousemove = function(e){
		g_x = (window.event ? window.event.clientX: (e ? (e.pageX ? e.pageX : 0) : 0));
		g_y = (window.event ? window.event.clientY: (e ? (e.pageY ? e.pageY : 0) : 0));
	}
}
_S.H('Page_OnLoad','SUBSCR_Set');














function ValidateForm(oFORM)
{
  var i, j, f, v, t, formName, fName, fType, bRet = true, msg = '', rq=' required',rf,rn,nf='',err;

	formName = oFORM.name;



	rf = "Please fill in the following fields:\n-------------------------------";
	rn = "Fields not found in form:\n-------------------------------";


	try {

			for(f in __FORMS[formName])
			{
				v = __FORMS[formName][f];
				fName = v[0];
				fType = v[1];

				if(!oFORM[f])
				{
					continue;
				}

				oFORM[f].className = oFORM[f].className.replace(/(\s*(required))/ig, '');


				if(__FORMS[formName][f][2])
				{
					if(oFORM[f].value == __FORMS[formName][f][2])
					{
						oFORM[f].value = '';
					}
				}


				switch(fType)
				{
					case 'text':
						try {
							v = T(oFORM[f].value);
						}catch(e){
							nf += "\n" + fName;
						}
						if(!v)
						{
							msg += "\n" + fName;
							bRet = false;
							oFORM[f].className += rq;
						}
						break;

					case 'zip':
						try {
							v = T(oFORM[f].value);
						}catch(e){
							nf += "\n" + fName;
						}
						if(!v || !parseInt(v))
						{
							msg += "\n" + fName;
							bRet = false;
							oFORM[f].className += rq;
						}
						break;

					case 'email':
						try {
							v = T(oFORM[f].value);
						}catch(e){
							nf += "\n" + fName;
						}
						if(!v)
						{
							msg += "\n" + fName;
							oFORM[f].className += rq;
						}else{
							if(v.indexOf('@') < 0)
							{
								msg += "\n" + '"' + fName + '" is not a valid e-mail address';
								bRet = false;
								oFORM[f].className += rq;
							}
						}
						break;

					case 'phone':
						try {
							v = T(oFORM[f].value);
						}catch(e){
							nf += "\n" + fName;
						}

						if(!v && __FORMS[formName][f][2])
						{
							msg += "\n" + fName;
							oFORM[f].className += rq;
						}
						if(v && !v.match(/^[\s-]*[\(]*[\s-]*(\d{3})[\s-]*[\)]*[\s-]*(\d{3})[\s-]*(\d{2})[\s-]*(\d{2})[\s-]*$/i))
						{
							msg += "\n" + '"' + fName + '" is not a valid phone number';
							oFORM[f].className += rq;
						}else{
							if(v)
							{
								oFORM[f].value = v.replace(/^[\s-]*[\(]*[\s-]*(\d{3})[\s-]*[\)]*[\s-]*(\d{3})[\s-]*(\d{2})[\s-]*(\d{2})[\s-]*$/g, "($1) $2-$3$4");
							}
						}
						break;

					case 'int':
						try {
							v = T(oFORM[f].value);
						}catch(e){
							nf += "\n" + fName;
						}

						v = v*1;
						if(v==0)
						{
							msg += "\n" + fName;
							oFORM[f].className += rq;
						}
						break;
				}


				if(oFORM && oFORM[f] && __FORMS[formName][f][2])
				{
					if(oFORM[f].value.replace(/\s*/g,'') == '')
					{
						oFORM[f].value = __FORMS[formName][f][2];
					}
				}
			}


	}catch(e){
		alert('Error happened: ' + (e.description ? e.description : e));
		return false;
	}


	if(msg || nf)
	{
		alert(rf+msg+"\n\n"+(nf?rn+nf:''));
		return false;
	}
	return true;
}






function Form_Field_OnFocus()
{
	var fn = this.getAttribute('_f'), n = this.name, f = document.forms[fn][n];

	if(__FORMS[fn][n][2])
	{
		if(f.value == __FORMS[fn][n][2])
		{
			f.value = '';
		}
	}
	f.className += ' focus';
}


function Form_Field_OnBlur()
{
	var fn = this.getAttribute('_f'), n = this.name, f = document.forms[fn][n];

	if(__FORMS[fn][n][2])
	{
		if(f.value.replace(/\s*/g,'') == '')
		{
			f.value = __FORMS[fn][n][2];
		}
	}
	f.className = f.className.replace(/\s*focus/ig,'');
}





function init_forms()
{
	for(var i=0; i<__FORMS.length; i++)
	{
		var fn = __FORMS[i];
		if(document.forms[fn])
		{
			document.forms[fn].onsubmit = function (){return ValidateForm(this);};

			var ae = document.forms[fn].elements;
			for(var j=0; j<ae.length; j++)
			{
				var f = ae[j], n = ae[j].name;

				if(__FORMS[fn][n])
				{
					f.onfocus = Form_Field_OnFocus;
					f.onblur = Form_Field_OnBlur;

					f.setAttribute('_f', fn);

					if(__FORMS[fn][n][2])
					{
						f.value = __FORMS[fn][n][2];
					}
				}
			}
		}
	}
}
_S.H('Window_OnLoad','init_forms');






function r_set(){
  var d=document.images; if(d){var i,a=r_set.arguments;for(i=0;i<a.length;i+=2){if(d[a[i]]){d[a[i]].h=new Image();d[a[i]].h.src=a[i+1];d[a[i]].osrc=d[a[i]].src;}}}
}
function r_on(){
 var d=document.images,a=r_on.arguments; if(d){for(i=0;i<(a.length);i++){if(d[a[i]]){if(d[a[i]].h){d[a[i]].src=d[a[i]].h.src;}}}}
}
function r_off(){
 var d=document.images,a=r_off.arguments; if(d){for(i=0;i<(a.length);i++){if(d[a[i]]){if(d[a[i]].osrc){d[a[i]].src=d[a[i]].osrc;}}}}
}



function _top(oIn)
{
	var w=0,o=oIn;
	while(o.tagName.toUpperCase() != 'BODY')
	{
		w += o.offsetTop;
		o = o.parentNode;
	}
	return w;
}


function _left(oIn)
{
	var w=0,o=oIn;
	while(o.tagName.toUpperCase() != 'BODY')
	{
		w += o.offsetLeft;
		o = o.parentNode;
	}
	return w;
}






var _ssv_o = null, _ssv_l = 190;
var _ssv_tm = null;
var _ssv_hidden = true;
var _ssv_x = 0;
var _ssv_y = 0;
var _ssv_q = '';


function ssv(e,n)
{
  var s, q='';

	var x = (window.event ? window.event.clientX: (e ? (e.pageX ? e.pageX : 0) : 0));
	var y = (window.event ? window.event.clientY+document.body.scrollTop: (e ? (e.pageY ? e.pageY : 0) : 0));


	if(subNav[n])
	{
		for(s in subNav[n])
		{
			if(s)
			{
				q += '<li><a href="?c='+s+'"><u>'+subNav[n][s]+"</u></a></li>\n";
			}
		}
	}
	_ssv_q = q ? '<div id="subnav"><ul>'+q+'</ul></div>' : '';

	if(_ssv_o)
	{
		_ssv_o.setAttribute('over', '1');
	}

	_ssv_x = x;
	_ssv_y = y;


	if(_ssv_tm)
	{
		clearTimeout(_ssv_tm);
	}
	_ssv_tm = setTimeout('ssv_show_delay()', 10);
}


function ssv_delay()
{
	if(_ssv_o)
	{
		if(_ssv_o.getAttribute('over') == '0')
		{
			_S.LH(_ssv_o);
//			_ssv_hidden = true;
		}
	}
}



function ssv_show_delay()
{
	var f = (_ssv_o ? false : true), b = _ssv_o ? (_ssv_o.getAttribute('over') == '1' ? true : false) : true;
	if(b)
	{
		var os = _G('nav0'), l = _left(os);

		//_S.LS = function(o, x, y, w, h, c, s)
		_ssv_o = _S.LS(_ssv_o, l + _ssv_l, 100, 180, 0, _ssv_q, '');

		if(f)
		{
			_ssv_o.onmouseover = function(){
				_ssv_o.setAttribute('over', '1');
//				setTimeout('ssv_show_delay()', 100);
			}

			_ssv_o.onmouseout = function(){
				_ssv_o.setAttribute('over', '0');
				if(_ssv_tm)
				{
					clearTimeout(_ssv_tm);
				}
				_ssv_tm = setTimeout('ssv_delay()', 100);
			}
		}

		var y1 = (_ssv_y - (_ssv_o.clientHeight/2));

		if(_ssv_q)
		{
			_S.LS(_ssv_o, l+_ssv_l, y1, 180, 0, _ssv_q, '');
		}else{
			_S.LH(_ssv_o);
		}
//		_ssv_hidden = false;
	}
}



function ssv_h(e)
{
	var os = _G('nav0'), l = _left(os);

	var x = (window.event ? window.event.clientX: (e ? (e.pageX ? e.pageX : 0) : 0));

	if(x < (l + _ssv_l) || x > (l + _ssv_l + 180))
	{
		_S.LH(_ssv_o);
	}
}


/*
r_on(\'ni_'.$i.'\');ssv(arguments[0],\''.$k.'\')
r_off(\'ni_'.$i.'\');ssv_h(arguments[0])
*/
var nav2_tm = null;
var nav_ev = null;
var nav_k = '';


function nav_on(id,e,k)
{
	r_on(id);
	ssv(e, k);
//	_ssv_o.setAttribute('over', '1');
//	setTimeout('ssv_show_delay()', 100);
}

function nav_off(id,e)
{
	r_off(id);
//	ssv_h(e);
	if(_ssv_o)
	{
		_ssv_o.setAttribute('over', '0');
	}
	if(_ssv_tm)
	{
		clearTimeout(_ssv_tm);
	}
	_ssv_tm = setTimeout('ssv_delay()', 100);
}




function validate_cart()
{
	var b = true;

	try {
		if(document.forms.cart.question.value == '0')
		{
			if(T(document.forms.cart.question2.value) == '')
			{
				b = false;
			}
		}
	}catch(e){};

	if(!b)
	{
		alert('Please specify how did you find us');
	}

	return b;
}



function switch_cart_q()
{
	if(document.forms.cart)
	{
		try {
			if(document.forms.cart.question.value+'' == '0')
			{
					document.forms.cart.question2.style.visibility = '';
			}else{
					document.forms.cart.question2.value = '';
					document.forms.cart.question2.style.visibility = 'hidden';
			}
		}catch(e){};
	}
}
_S.H('Window_OnLoad','switch_cart_q');





function add_agent_code()
{
	_S.PD('?c=cart-agent-code', 400, 300);
}



function remove_group_member(id)
{
	if(confirm('Are you sure you want to remove that member ?'))
	{
		window.location = '?c=auth-purchases-group&id=27&action=remove-user&user=' + id;
	}
}