//<![CDATA[

var newwindow = '';

function openNewWin(url, winName, features)
{
	if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = url;
	}
	else
	{
		newwindow=window.open(url,winName,features);
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}

function isRadioChecked(obj) {
	ischecked = false;
	
	for (i=0;i<obj.length;i++)
	{
		if (obj[i].checked)
			ischecked = true;
	}

	return ischecked;
}

function date_change(obj) {	//updated 2007-01-27
	//first we check that the date is valid, ie a month with less than 31 days doesnt have 31 days selected 
	month = obj[0].value;
	day = obj[1].value;

	if(month==2 && day>29)		//check february
	{
		//alert('Date not valid.');
		//obj[1].focus();
		obj[1].value = 28;
	}
	
	mcheck = Array(4,6,9,11);	//months with 30 days

	for(m=0;m<mcheck.length;m++){
		if(month==mcheck[m] && day==31)	//check other months
		{
			//alert('Date not valid.');
			//obj[1].focus();
			obj[1].value = 30;
		}
	}
		
	//now we put the values in the hidden field
	if(obj[2].value!='' && obj[1].value!='' && obj[0].value!='')
		obj[3].value = obj[2].value+'-'+obj[0].value+'-'+obj[1].value;
	
	if(obj[2].value=='' || obj[1].value=='' || obj[0].value=='')
		obj[3].value = '';
}

function datetime_change(obj) {	//created 2008-06-11
	//first we check that the date is valid, ie a month with less than 31 days doesnt have 31 days selected
	month = obj[0].value;
	day = obj[1].value;

	if(month==2 && day>29)		//check february
		obj[1].value = 28;
	
	mcheck = Array(4,6,9,11);	//months with 30 days

	for(m=0;m<mcheck.length;m++){
		if(month==mcheck[m] && day==31)	//check other months
			obj[1].value = 30;
	}

	//now check PM hours and convert to 24hr format
	hour = obj[3].value;
	ampm = obj[5].value;
	hr24 = hour;

	if(ampm=='am' && hour==12)
		hr24 = 0;
	if(ampm=='pm' && hour<12)
		hr24 = hour*1+12;
	if(hr24<10)
		hr24 = '0'+hr24;
		
	//now we put the values in the hidden field
	if(obj[2].value!='' && obj[1].value!='' && obj[0].value!='')
		obj[6].value = obj[2].value+'-'+obj[0].value+'-'+obj[1].value+' '+hr24+':'+obj[4].value+':00';
}

function checkUncheckAll(theElement) {
	var theForm = theElement.form;
	
	for(i = 0; i < theForm.length; i++) {
		
		if (theForm[i].type == 'checkbox' && !theForm[i].disabled)
			theForm[i].checked = theElement.checked;

	}
}

function showImageViewer(path, dwidth, dheight){
	ivobj = document.getElementById("pic_viewer");

	//ivobj.style.width = dwidth;
	//ivobj.style.height = dheight;
	
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		winW = document.body.offsetWidth;
		winH = document.body.offsetHeight;
	}
	else {
		winW = window.innerWidth;
		winH = window.innerHeight;
	}

	ivobj.style.left = ((winW-dwidth-20)/2)+'px';
	ivobj.style.top = ((winH-dheight-20)/2)+'px';

	ivobj.innerHTML = '<img src="'+path+'" border="0" /><div style="padding-top:5px" align="right"><a href="javascript:hideImageViewer()">Close</a></div>';

	ivobj.style.display = 'block';
}

function hideImageViewer(){
	ivobj = document.getElementById("pic_viewer");

	ivobj.innerHTML = '';
	
	ivobj.style.display = 'none';
}

// cross browser functions
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}

function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

//]]>