function openplanner()
{
  	planner=window.open("http://planner.iastate.edu","csp","alwaysRaised=yes,hotkeys=yes,scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=yes,status=no,width=850,height=720");
  	planner.focus();
}

function passDept(str)
{
  	document.basicform.dept.value = str;
}

function setPartialDate(pt)
{
	var smonth = document.basicform.smonth;
	var sday = document.basicform.sday;
	var emonth = document.basicform.emonth;
	var eday = document.basicform.eday;
	var sdate = pt.substring(0,10);
	var edate = pt.substring(10);
	var sm = sdate.substring(5,7);
	var sd = sdate.substring(8,10);
	var em = edate.substring(5,7);
	var ed = edate.substring(8,10);

	if(sm.substring(0,1) == "0")
	{
		sm = parseInt(sm.substring(1));
	}
	else
	{
		sm = parseInt(sm);
	}
	if(sd.substring(0,1) == "0")
	{
		sd = parseInt(sd.substring(1));
	}
	else
	{
		sd = parseInt(sd);
	}
	if(em.substring(0,1) == "0")
	{
		em = parseInt(em.substring(1));
	}
	else
	{
		em = parseInt(em);
	}
	if(ed.substring(0,1) == "0")
	{
		ed = parseInt(ed.substring(1));
	}
	else
	{
		ed = parseInt(ed);
	}

	smonth.selectedIndex = sm-1;
	sday.selectedIndex = sd-1;
	emonth.selectedIndex = em-1;
	eday.selectedIndex = ed-1;
}

function dateCheckS()
{
	var m = document.basicform.smonth;
	var d = document.basicform.sday;
	var month = m[m.selectedIndex].value;
	var day = d[d.selectedIndex].value;
	
	if(month=="02" && (day=="29" || day=="30" || day=="31"))
	{
		alert("Please enter a valid start date");
		m.selectedIndex = 0;
		d.selectedIndex = 0;
	}
	if((month=="04" || month=="06" || month=="09" || month=="11") && day=="31")
	{
		alert("Please enter a valid start date");
		m.selectedIndex = 0;
		d.selectedIndex = 0;
	}
}

function dateCheckE()
{
	var m = document.basicform.emonth;
	var d = document.basicform.eday;
	var month = m[m.selectedIndex].value;
	var day = d[d.selectedIndex].value;
	if(month=="02" && (day=="29" || day=="30" || day=="31"))
	{
		alert("Please enter a valid end date");
		m.selectedIndex = 11;
		d.selectedIndex = 30;
	}
	if((month=="04" || month=="06" || month=="09" || month=="11") && day=="31")
	{
		alert("Please enter a valid end date");
		m.selectedIndex = 11;
		d.selectedIndex = 30;
	}
}

function timeCheck()
{
	var sh = document.basicform.shour;
	var sa = document.basicform.sampm;
	var shour = sh[sh.selectedIndex].value;
	var sampm = sa[sa.selectedIndex].value;
	var eh = document.basicform.ehour;
	var ea = document.basicform.eampm;
	var ehour = eh[eh.selectedIndex].value;
	var eampm = ea[ea.selectedIndex].value;

        if(shour=="12")
        {
                sa.selectedIndex = 1;
                ea.selectedIndex = 1;
        }
        if(shour=="11" || shour=="10")
        {
                sa.selectedIndex = 0;
        }
        if(ehour=="12")
        {
                ea.selectedIndex = 1;
        }
        if(ehour=="11")
        {
                ea.selectedIndex = 0;
        }
	if((shour=="05" || shour=="04" || shour=="03" || shour=="02"
		|| shour=="01"))
	{
		sa.selectedIndex = 1;
	}
	if((ehour=="05" || ehour=="04" || ehour=="03" || ehour=="02"
		|| ehour=="01" || ehour=="6"))
	{
		ea.selectedIndex = 1;
	}
	if(sampm=="pm")
	{
                ea.selectedIndex = 1
        }
}

function openLink(url)
{
        popupWindow = window.open(url,'popUpWindow','height=700,width=800,left=400,top=200,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}