function prettyDate(curTime, time){
	
	var curDate = new Date((curTime || "").replace(/-/g,"/"));
	var date = new Date((time || "").replace(/-/g,"/")),
		diff = ((curDate.getTime() - date.getTime()) / 1000),
		day_diff = Math.floor(diff / 86400);
					//console.log(day_diff);

	if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
		return;
			
	return day_diff == 0 && (
			diff < 60 && "just now" ||
			diff < 120 && "1 minute ago" ||
			diff < 3600 && Math.floor( diff / 60 ) + " minutes ago" ||
			diff < 7200 && "1 hour ago" ||
			diff < 86400 && Math.floor( diff / 3600 ) + " hours ago") ||
		day_diff == 1 && "Yesterday" ||
		day_diff < 7 && day_diff + " days ago" ||
		day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks ago";
		//46800
}

// If jQuery is included in the page, adds a jQuery plugin to handle it as well
if ( typeof jQuery != "undefined" )
	jQuery.fn.prettyDate = function(){
		return this.each(function(){
			var date = prettyDate(this.title);
			if ( date )
				jQuery(this).text( date );
		});
	};
	
function popit(url,h,w)
	{
		if(!h){h='300';}
		if(!w){w='300';}
		window.open (url, 'newwindow', config='height='+h+',width='+w+', toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, directories=no, status=no');
	}
function popitOptions(url,h,w,t,m,sb,r,l,d,s)
	{	
		var options=null;
		if(h){options=options+'height='+h+',';}
		if(w){options=options+'width='+w+',';}
		if(t){options=options+'toolbar='+t+',';}
		if(m){options=options+'menubar='+m+',';}
		if(sb){options=options+'scrollbars='+sb+',';}
		if(r){options=options+'resize='+r+',';}
		if(l){options=options+'location='+l+',';}
		if(d){options=options+'directories='+d+',';}
		if(s){options=options+'status='+s+',';}
		
		if(options){
			options = options.slice(0, -1)
			window.open (url, 'newwindow', config=options);
		}else{
			window.open (url, 'newwindow');
		}
	}
	
function reloadIframe(i) {
	var f = document.getElementById(i);
	f.src = f.src;
}
$(function(){ 
	$('#searchText[title!=""]').hint();
});

