/* SVN FILE: $Id: visitnc.js 1953 2009-08-01 14:44:00Z michaelklauss $ */
var sec = {'now':new Date().valueOf(),'hour':3600,'day':86400,'week':604800,'month':2629743,'year':31556926};
var jar = new CookieJar();
var ccache = {};
var defaultSearchMsg = 'search north carolina';
		
function suggest(keyword) {
	if(keyword.length>2 && keyword!=defaultSearchMsg) {
		url = '/searches/suggest/'+keyword;
		new Ajax.Updater('searchsuggest', url, {
			evalScripts:true,
			parameters: { searchinput: keyword }
		});
	}
	else if($('searchinput').getValue()=='')
	{
		$('searchsuggest').update('');
	}
}
function chksubmit(){
	$('searchsuggest').update('');
	var keyword = $('searchinput').getValue();
	if(keyword==defaultSearchMsg || keyword=='') {
		alert('Please enter a search phrase.');
		return false;
	}
}
function adjust_pin( url ){
	window.location = url+"?r="+escape(window.location);
}

/* -- comments -- */
function submit_comment(formEle) {
	formEle = Element.extend(formEle);
	formEle.request({
		evalScripts:true,
		onComplete: function(transport, json) { 
			if(transport.responseText) {
				$('comment_form_body').update(transport.responseText);
			} 
		},
		onFailure: function() { 
			alert('Sorry. Something bad happened. Your request cannot be completed.');
		}
	});
	return false; // because we submit by Ajax
}

/* -- rateit -- */
function rateit(ele,url) {
	ele = Element.extend(ele);
	url = new String(url);
	var uid  = url.split('/').pop();
	var vote = jar.get('vote');
	if(!vote){vote={uid:(sec.now-sec.year)};}
	if(vote[uid]+sec.month > sec.now){
		alert('Thank you for your previous vote!');
	} else {
		vote[uid]=sec.now;
		jar.put('vote',vote);
		var caction = function(transport) {
			var r = transport.headerJSON;
			this.select('p')[0].update('('+r.clicks+')');
		}
		new Ajax.Request(url,{onSuccess:caction.bind(ele.up())});
	}
	return false;	
}
function emailit(ref){  
	var ref = (ref!=null)? ref : window.location;
	var url = '/sendlinks/modal/?l='+escape(ref);
	new Ajax.Request(url, {
		evalScripts:true,
		onComplete: function(transport) { 
			displaymodal(transport.responseText);
  		}
	});
}
function saveit(event){ return false; }
function toggleSnippet(ele) {
	ele = Element.extend(ele);
	ele.toggleClassName('collapse');
	ele.toggleClassName('expand');
	ele.next().toggleClassName('hidden');
}
function displaymodal(response) {
	hidemodal();
	var div = new Element('div', {'id':'modalbox'});
	var wrapper = $('wrapper');
	wrapper.appendChild(div);
	div.setStyle({'position':'absolute','zIndex':'5000','display':'none'});
	div.update(response);
	// position relative to an element
	if(displaymodal.arguments.length>1) 
	{
		var rele    = displaymodal.arguments[1];
		var offsetx = displaymodal.arguments[2];
		var offsety = displaymodal.arguments[3];
		var wpos    = wrapper.cumulativeOffset();
		var pos     = rele.cumulativeOffset();
		var left    = (pos.left-wpos.left) - ((div.getWidth()-rele.getWidth())/2);
		var top     = pos.top-wpos.top;
	} 
	else // center in viewport
	{
		var vph  = document.viewport.getHeight();
		var vpo  = document.viewport.getScrollOffsets();
		var w    = wrapper.getDimensions();
		var e    = div.getDimensions();
		var left = (w.width-e.width)/2;
		if(vph > e.height) {
			var offset = ((vph-e.height)/2)-30;
		} else {
			var offset = 0;
		}
		var top = (vpo.top + offset);
	}
	div.setStyle({'left':left+'px','top':top+'px'});
	var intv = (Prototype.Browser.IE)? 0 : .25 ;
	div.appear({duration:intv,from:0,to:1});
	Element.observe('modalbox','blur',function(){if($('modalbox')){$('modalbox').remove()}});
}
function hidemodal() {
	var mb = $('modalbox');
	if(mb){ mb.remove(); }
}
function rollout_modal(evt,ele) {
	if(isMouseLeaveOrEnter(evt,ele)) {
		hidemodal();
	}
}
function submitmodal(f) {
	f.request({
		evalScripts:true,
		onComplete: function(transport, json) { 
			if(transport.responseText) {
				$('modalbox').update(transport.responseText);
			} 
		},
		onFailure: function() { 
			alert('Sorry. Something bad happened. Your request cannot be completed.');
		}
	});
	return false; // because we submit by Ajax
}
function doCloud(ele) {
	var i=1;
	while( $('cmag'+i)!=undefined ) {
		$('cmag'+i).setStyle({'display':'none'});
		i++;
	}
	if( ele !=undefined ) {
		ele = Element.extend(ele);
		var cele = 'c'+ele.id;
		var ed = ele.getDimensions();
		var cd = $(cele).getDimensions();
		var ol = parseInt(ele.getStyle('left'))-(cd.width/2);
		var ot = parseInt(ele.getStyle('top'))-(cd.height/2);
		ol = ol+(ed.width/2);
		ot = ot+(ed.height/2);
		$(cele).setStyle({'position':'absolute','left':ol+'px','top':ot+'px'});
		var intv = (Prototype.Browser.IE)? 0 : .5 ;
		$(cele).appear({duration:intv,from:0,to:1});
	}
}

/* -- product detail -- */
var showp = function (ele,url) {
	if(ele) {
		ele = Element.extend(ele);
		if(ccache[url]) {
			displaymodal(ccache[url],ele);
		} else {
			new Ajax.Request(url, {
				evalScripts:true,
				onComplete: function(transport) { 
					ccache[url] = transport.responseText
					displaymodal(transport.responseText,ele);
				}
			});
		}
	}
	return false;
}
/* -- offer detail -- */
var showoffer = function (url) {
	if(ccache[url]) {
		displaymodal(ccache[url]);
	} else {
		new Ajax.Request(url, {
			evalScripts:true,
			onComplete: function(transport) { 
				ccache[url] = transport.responseText
				displaymodal(transport.responseText);
			}
		});
	}
	return false;
}

/* -- inline video -- */
var showurl = function (url) {
	if(ccache[url]) {
		displaymodal(ccache[url]);
	} else {
		new Ajax.Request(url, {
			evalScripts:true,
			onComplete: function(transport) { 
				ccache[url] = transport.responseText;
				displaymodal(transport.responseText);
			}
		});
	}
	return false;
}
var showthanks = function(url) {
	new Ajax.Request(url, {
		evalScripts:true,
		onComplete: function(transport) { 
			displaymodal(transport.responseText);
		}
	});
}
function setmodalpos(ele)
{
	var vph  = document.viewport.getHeight();
	var vpo  = document.viewport.getScrollOffsets();	
	var w    = $('wrapper').getDimensions();
	var e    = ele.getDimensions();
	var left = (w.width-e.width)/2;
	if(vph > e.height) {
		var offset = (vph-e.height)/2;
	} else {
		var offset = 0;
	}
	var top = vpo.top + offset;
	ele.setStyle({'left':left+'px','top':top+'px'});
}

/* -- paging -- */
function movepage(n) {
	var input = $('page');
	input.value = n;
	input.form.submit();
}

/* -- Captcha -- */
function renderCaptcha(ele) {
	var element = $(ele);
	Recaptcha.create("6LdjrgQAAAAAAM9QH10R4_iLapYbupVzZMUxZHFC", element, {
        theme: 'white',
        tabindex: 0,
        callback: Recaptcha.focus_response_field
	});
}

/* -- home tabs -- */
var Hometabs = {
	tabIds : ['exp_tab_map','exp_tab_photo','exp_tab_highlight'],
	tabEle : [],
	tabCache : {},
	tabDown : null,
	init: function() {
		for(i=0;i<this.tabIds.length;i++) {
			if($(this.tabIds[i])) { 
				this.tabEle.push($(this.tabIds[i]));
				if($(this.tabIds[i]).hasClassName('selected')) {
					this.tabDown = this.tabIds[i];
				}
			}
		}
		for(i=0;i<this.tabEle.length;i++) {
			var action = function(evt){
				Event.stop(evt);
				var ele = evt.element();
				this.toggle(ele);
			}
			this.tabEle[i].observe('click',action.bindAsEventListener(this));
		}
	},
	toggle: function(ele) {
		this.tabCache[this.tabDown] = $('explorebox').innerHTML;
		if(ele.hasClassName('selected')) {return false;}
		for(i=0;i<this.tabEle.length;i++) {
			this.tabEle[i].removeClassName('selected');
		}
		ele.addClassName('selected');
		this.tabDown = ele.id;
		this.load(ele);
	},
	load: function(ele) {
		var url = ele.readAttribute('href');
		new Ajax.Updater('explorebox',url,{
						evalScripts:true,
						onFailure: function() { 
							alert('Sorry. Your request cannot be completed.');
						}
					});
	}
};

/* -- multimedia tabs -- */
var Mediatabs = {
	lat: null,
	lon: null,
	zoom: null,
	mdata: null,
	gMap: false,
	init: function(lat,lon,zoom,data) {
		if($('mmtab_view')) {
			this.lat  = lat;
			this.lon  = lon;
			this.zoom = zoom;
			this.mdata = data;
			var action = function(evt) {
				Event.stop(evt);
				var ele = evt.element();
				this.view();
			}
			$('mmtab_view').observe('click',action.bindAsEventListener(this));	
			var action = function(evt) {
				Event.stop(evt);
				var ele = evt.element();
				this.map();
			}
			$('mmtab_map').observe('click',action.bindAsEventListener(this));
			this.view();
		}
	},
	map: function() {
		$('mmtab_map').addClassName('selected');
		$('mmtab_view').removeClassName('selected');
		$('themedia').hide();
		$('themap').show();
		if(!this.gMap){
			this.gMap = new ncGMap('themap',this.lat,this.lon,this.zoom);
			this.gMap.add(this.mdata);
			this.gMap.click(0);
		}
	},
	view: function() {
		$('mmtab_view').addClassName('selected');
		$('mmtab_map').removeClassName('selected');
		$('themedia').show();
		$('themap').hide();
	}
};

/* -- calendar widget -- */
var calendarWidget = function(id) {
	this.button_back = 'cal_back';
	this.button_next = 'cal_next';
	this.calendar    = 'cal';
	this.calendar_div   = 'cal_div';
	this.calendar_title = 'cal_title';
	this.calendar_div   = 'cal_element';
	this.bind_start_fld = null;
	this.bind_end_fld   = null;
	this.selecteddates  = {start:null,end:null};
	this.months        = ['January','February','March','April','May','June','July','August','September','October','November','December'];
	this.monthlen      = [31,0,31,30,31,30,31,31,30,31,30,31];
	this.days          = ['S','M','T','W','T','F','S'];
	this.today         = new Date();
	this.current_year  = this.today.getFullYear();
	this.current_month = this.today.getMonth();
	this.current_month = this.today.getMonth();
	this.lastClick     = new Date().valueOf();
	this.timeoutid     = null;
	this.callback      = null;
}
calendarWidget.prototype.init = function(start,end){
	this.today.setHours(0);
	this.today.setMinutes(0);
	this.today.setSeconds(0);
	this.today.setMilliseconds(0);
	var s = new Date(start);
	if(!s.getDate()) {
		var s = new Date();
	}
	s.setHours(0);
	s.setMinutes(0);
	s.setSeconds(0);
	s.setMilliseconds(0);
	this.current_month = s.getMonth()+1;
	this.current_year  = s.getFullYear();
	this.selecteddates.start = s;
	var e = new Date(end);
	if(e.getDate()) {
		e.setHours(0);
		e.setMinutes(0);
		e.setSeconds(0);
		e.setMilliseconds(0);
		this.selecteddates.end = e;
	} else {
		this.selecteddates.end = s;
	}
	if($(this.button_back)) {
		var action = function(){this.move(-1)}
		$(this.button_back).observe('click',action.bindAsEventListener(this));
	}	
	if($(this.button_next)) {
		var action = function(){this.move(1)}
		$(this.button_next).observe('click',action.bindAsEventListener(this));
	}
	this.render(this.current_month,this.current_year);
}
calendarWidget.prototype.clickDate = function(d){
	window.clearTimeout(this.timeoutid);
	this.timeoutid = setTimeout(this.selectDate.bind(this,d),350);
}
calendarWidget.prototype.dblclickDate = function(d){
	if(this.timeoutid) {
		window.clearTimeout(this.timeoutid);
	}
	this.timeoutid = setTimeout(this.resetDate.bind(this,d),350);
}
calendarWidget.prototype.bind_start = function(eleId){
	this.bind_start_fld = eleId;
}
calendarWidget.prototype.bind_end = function(eleId){
	this.bind_end_fld = eleId;
}
calendarWidget.prototype.bindfld = function(){
	var s = new Date(this.selecteddates.start);
	var e = new Date(this.selecteddates.end);
	if($(this.bind_start_fld)){
		$(this.bind_start_fld).value = s.format("Y-n-d");
	}
	if($(this.bind_end_fld)){
		$(this.bind_end_fld).value = e.format("Y-n-d")
	}
}
calendarWidget.prototype.doCallback = function(){
	if(this.callback!=null){
		var s = new Date(this.selecteddates.start);
		var e = new Date(this.selecteddates.end);
		this.callback(s.format("Y-n-d"),e.format("Y-n-d"));
	}
}
calendarWidget.prototype.move = function(n){
	var m = this.current_month + n;
	var y = this.current_year;
	if(m==13){m=1;y++}
	if(m==0){m=12;y--}
	this.current_year  = y;
	this.current_month = m;
	this.render(m,y);
}
calendarWidget.prototype.selectDate = function(d){
	var clk = new Date().valueOf();
	if( (clk-this.lastClick) < 1000) { // dblclick
		this.lastClick = clk;
		this.resetDate(d);
		return;
	}
	this.lastClick = clk;
	var sV = this.selecteddates.start.valueOf()
	var eV = this.selecteddates.end.valueOf()
	var dV = d.valueOf()
	var sd = Math.abs(dV-sV); // difference between newdate & start
	var ed = Math.abs(dV-eV); // difference between newdate & end
	if(sV==eV) {
		if(dV < sV )
			this.selecteddates.start = d;
		else
			this.selecteddates.end = d;
	} else {
		if(sd < ed )
			this.selecteddates.start = d;
		else
			this.selecteddates.end = d;
	}
	this.bindfld();
	this.render(this.current_month,this.current_year);
	this.doCallback();
}
calendarWidget.prototype.resetDate = function(d){
	this.selecteddates.start = d;
	this.selecteddates.end = d;
	this.bindfld();
	this.render(this.current_month,this.current_year);
	this.doCallback();
}
calendarWidget.prototype.render = function(month, year) {
	$(this.calendar_title).update(this.months[month-1]+' '+year);
	var cal = $(this.calendar);
	var nodes = cal.descendants();
	nodes.each(function(node){node.remove()});
	var monthStart = new Date(year,month-1,1);    // first day of the month
	monthStart.firstDay = monthStart.getDay()+1;  // day of week that our month starts
	// find Feb leap year
	this.monthlen[1] = (((monthStart.getFullYear()%100!=0)&&(monthStart.getFullYear()%4==0))||(monthStart.getFullYear()%400==0))? 29 : 28 ;
	// css class for start & end of week
	var cls = ['nol','','','','','','nor'];
	// build table & header
	var tbody = new Element('tbody');
	var tr  = new Element('tr');
	for(i=0; i<7; i++) { 
		var th = new Element('th',{'class':cls[i]});
		th.update(this.days[i]);
		tr.insert(th);
	}
	tbody.insert(tr);
	// how many rows of days in this cal?
	var rows = Math.ceil(((monthStart.firstDay-1) + this.monthlen[month-1])/7 );
	var ii = 1;
	for(j=0;j<rows;j++)
	{
		var tr = new Element('tr');
		for(i=0;i<=6;i++)
		{
			var day = ((ii-monthStart.firstDay>=0) && (ii-monthStart.firstDay<this.monthlen[month-1]) )? ii-monthStart.firstDay+1 : null ;
			var td  = new Element('td');
			td.writeAttribute({'title':'Click to select date. Double Click to reset date.'});
			td.thisdate = (day==null)? null : new Date(year,month-1,day);
			td.addClassName(cls[(ii-1)%7]); // set class for first && last day of week
			if(j==(rows-1)){td.addClassName('nob');} // last row gets last row class
			if(td.thisdate!=null)
			{
				// if day == select.start && select.end
				if(td.thisdate.valueOf()==this.selecteddates.start.valueOf() &&
					td.thisdate.valueOf()==this.selecteddates.end.valueOf()){td.addClassName('sel');}
				// if day == select.start
				else if(td.thisdate.valueOf()==this.selecteddates.start.valueOf()){td.addClassName('start');}
				// if day > select.start && day < select.end
				else if(td.thisdate.valueOf()>this.selecteddates.start.valueOf() && 
					td.thisdate.valueOf()<this.selecteddates.end.valueOf() ){td.addClassName('sel');}
				// if day == select.end
				else if(td.thisdate.valueOf()==this.selecteddates.end.valueOf()){td.addClassName('end');}
				if(this.today.valueOf() == td.thisdate.valueOf()) {td.addClassName('today');}
				td.update(day);
				var action = function(evt) {
					var ele = evt.element();
					this.clickDate(ele.thisdate);
				}
				td.observe('click',action.bindAsEventListener(this));
				var action = function(evt) {
					var ele = evt.element();
					this.dblclickDate(ele.thisdate);
				}
				td.observe('dblclick',action.bindAsEventListener(this));
			}
			else
			{
				td.update(day);
			}
			tr.insert(td);
			ii++;
		}
		tbody.insert(tr);
	}
	cal.insert(tbody);
	
	// display selected range
	var s = new Date(this.selecteddates.start).format("M d, y");
	var e = new Date(this.selecteddates.end).format("M d, y");
	var str = (s!=e)?  s +'<span> to </span>'+ e : s ;
	$('cal_element_dates').update(str);
}

/* -- journey widget -- */
var journeyWidget = function() {
	this.item_selector = 'div';
	this.button_back = 'journeyback';
	this.button_next = 'journeynext';
	this.slider      = 'slider';
	this.slider_ele  = null;
	this.step_val    = 1;
	this.stops       = [];
	this.stop_idx    = 0;
	this.stop_last   = null;
	this.view_block  = null;
	this.cookie      = 'jwidx';
}
journeyWidget.prototype.init = function(month,year){
	this.slider_ele = $(this.slider);
	if($(this.button_back)) {
		var action = function(){this.back()}
		$(this.button_back).observe('click',action.bindAsEventListener(this));
	}	
	if($(this.button_next)) {
		var action = function(){this.next()}
		$(this.button_next).observe('click',action.bindAsEventListener(this));
	}
	var panes = $(this.slider).select(this.item_selector);
	var totalWidth = 0;
	for(i=0;i<panes.length;i++)
	{
		this.stops.push(-(totalWidth));
		var d = panes[i].getWidth();
		totalWidth += d;
		var ml = parseFloat(Element.getStyle(panes[i],'margin-left'));
		var mr = parseFloat(Element.getStyle(panes[i],'margin-right'));
		totalWidth += ml;
		totalWidth += mr;
	}
	
	this.stop_last = this.stops.length;
	if(this.view_block!=null) {
		this.stop_last += -(this.view_block);
	}

	$(this.slider).setStyle({'position':'absolute','display':'block','top':0,'left':0,'width':(totalWidth+500)+'px'});	
	var n = jar.get(this.cookie);
	if(!isNaN(n)){
		n = new Number(n)
		if(n<=this.stops.length && n>=0) {
			this.stop_idx=n;
		}
	}
}
journeyWidget.prototype.last = function(){
	this.step(0);
}
journeyWidget.prototype.back = function(){
	this.step(-(this.step_val));
}
journeyWidget.prototype.next = function(){
	this.step(this.step_val);
}
journeyWidget.prototype.step = function(n){
	if(n>=1) {
		if( this.stop_idx == this.stop_last ) {
			// this.stop_idx = 0;
			return;
		} else if ( (this.stop_idx+this.step_val) > this.stop_last) {
			this.stop_idx = this.stop_last;
		} else {
			this.stop_idx += this.step_val;
		}
	} else if(n<=-1) {
		if( this.stop_idx == 0 ) {
			// this.stop_idx = this.stop_last;
			return;
		} else if ( (this.stop_idx-this.step_val) < 0) {
			this.stop_idx = 0;
		} else {
			this.stop_idx += -(this.step_val);
		}
	}
	jar.remove(this.cookie);
	jar.put(this.cookie,this.stop_idx);
	var pos = this.stops[this.stop_idx];
	new Effect.Move(this.slider_ele, {
	   x: pos, 
	   transition: Effect.Transitions.sinoidal,
	   mode: 'absolute'
	});
}

// Event helper
function isMouseLeaveOrEnter(e, ele) {		
	ele = Element.extend(ele);
	if (e.type != 'mouseout' && e.type != 'mouseover') return false;
	var reltg = e.relatedTarget ? e.relatedTarget :
	e.type == 'mouseout' ? e.toElement : e.fromElement;
	while (reltg && reltg != ele) reltg = reltg.parentNode;
	return (reltg != ele);
}

// Simulates PHP's date function
Date.prototype.format = function(format) {
	var returnStr = '';
	var replace = Date.replaceChars;
	for (var i = 0; i < format.length; i++) {
		var curChar = format.charAt(i);
		if (replace[curChar]) {
			returnStr += replace[curChar].call(this);
		} else {
			returnStr += curChar;
		}
	}
	return returnStr;
};
Date.replaceChars = {
	shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
	longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
	shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
	longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
	
	// Day
	d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); },
	D: function() { return Date.replaceChars.shortDays[this.getDay()]; },
	j: function() { return this.getDate(); },
	l: function() { return Date.replaceChars.longDays[this.getDay()]; },
	N: function() { return this.getDay() + 1; },
	S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); },
	w: function() { return this.getDay(); },
	z: function() { return "Not Yet Supported"; },
	// Week
	W: function() { return "Not Yet Supported"; },
	// Month
	F: function() { return Date.replaceChars.longMonths[this.getMonth()]; },
	m: function() { return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); },
	M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; },
	n: function() { return this.getMonth() + 1; },
	t: function() { return "Not Yet Supported"; },
	// Year
	L: function() { return "Not Yet Supported"; },
	o: function() { return "Not Supported"; },
	Y: function() { return this.getFullYear(); },
	y: function() { return ('' + this.getFullYear()).substr(2); },
	// Time
	a: function() { return this.getHours() < 12 ? 'am' : 'pm'; },
	A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; },
	B: function() { return "Not Yet Supported"; },
	g: function() { return this.getHours() % 12 || 12; },
	G: function() { return this.getHours(); },
	h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); },
	H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); },
	i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); },
	s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); },
	// Timezone
	e: function() { return "Not Yet Supported"; },
	I: function() { return "Not Supported"; },
	O: function() { return (this.getTimezoneOffset() < 0 ? '-' : '+') + (this.getTimezoneOffset() / 60 < 10 ? '0' : '') + (this.getTimezoneOffset() / 60) + '00'; },
	T: function() { return "Not Yet Supported"; },
	Z: function() { return this.getTimezoneOffset() * 60; },
	// Full Date/Time
	c: function() { return "Not Yet Supported"; },
	r: function() { return this.toString(); },
	U: function() { return this.getTime() / 1000; }
};

function popWin( url, name, width, height, scroller ) {
	var outStr = 'height=' + height + ',width=' + width;
	if (scroller != 'true') {
	outStr = outStr + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no';
	}
	else {
	outStr = outStr + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no';
	}
	msgWindow=window.open(url, name, outStr);
}