$(document).ready(function() {
	if (typeof(_sessionTimeout) != 'undefined') {
		var sessionTimer = setInterval(function() {
			$.ajax({type:'get', url:window.location.pathname + '?a=website.renewSession', async:false});
		}, ((_sessionTimeout-5)*60*1000));
	}

	/* RESIZE IMAGES */
	$('div.custom img').each(function(){
		img = $(this);
		try {
			if (img.attr('src').substring(0, 7).toLowerCase() == '/custom') {
				imgAry = img.attr('src').split('/');
				imgSize = img.attr('width') + 'x' + img.attr('height');
				imgName = imgAry[imgAry.length-1];
				imgSrc = '/common/imageThumbs/?image=' + imgName + '&size=' + imgSize + '&site=' + _websiteIdent;
				img.attr('src', imgSrc);
				/* CREATE A POPUP FOR THE LARGE VIEW
				img.click(function(e){
					imgWin = window.open('/common/imageThumbs/popup.html?imgURL=' + imgSrc, 'imgWindow', 'width=200,height=200,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
				}); */
			}
		} catch(err) {};
	});
});

var newwindow = ''
function popitup(url) {
if (newwindow.location && !newwindow.closed) {
    newwindow.location.href = url;
    newwindow.focus(); }
else {
    newwindow=window.open(url,'htmlname','width=404,height=316,resizable=1');}
}

function toProperCase(s) {
	return s.toLowerCase().replace(/^(.)|\s(.)/g, function($1) { return $1.toUpperCase(); });
}

function parseURL(url) {
	var params = {};
	var query = '';
	if (url) {
		query = url.substring((url.indexOf('?')) + 1);
		/* REMOVE HASH */
		if (query.indexOf('#') >= 0 ) { query = query.substring(0, query.indexOf('#')); }
	}

	if (query.length < 1) { return params; }
	var pairs = query.split(/[;&]/);
	for (var i = 0; i < pairs.length; i++) {
		var key_value = pairs[i].split('=');
		if (!key_value || key_value.length != 2) { continue; }
		var key = unescape(key_value[0].toLowerCase());
		var value = unescape(key_value[1]);
		value = value.replace(/\+/g, ' ');
		params[key] = value;
	}
	return params;	
}
