//<![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;

	}
}

pdiv_offset = 5;

function show_msg(event, content){
	popupdiv = document.getElementById('popupmsg');

	switch(content){
		case 'addneed2ag':
			msg = 'This button enables you to choose the amount you would like your Action Group to pledge towards this specific need.';
			break;

		case 'startag':
			msg = 'An Action Group is a group of Allies that work together to raise money for specific needs. We believe that more will be achieved when we work together!';
			break;

		case 'becomeally':
			msg = 'When you become an Ally you will receive a profile page and have the ability to start or join Action Groups. 100% of the money you donate goes directly to the need!';
			break;
	}
	
	popupdiv.innerHTML = msg;

	x = event.clientX ? event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft : event.pageX;
	y = event.clientY ? event.clientY + document.body.scrollTop + document.documentElement.scrollTop : event.pageY;
	
	x += pdiv_offset;
	y += 10;

	popupdiv.style.left = x+'px';
	popupdiv.style.top = y+'px';
	popupdiv.style.display = '';

	return false;
}

function hide_msg(){
	popupdiv = document.getElementById('popupmsg');
	
	popupdiv.style.display = 'none';
}
//]]>
