﻿function CEIP_ChangeCalendar(frame) {

	// Build querystring.
	var pmTitle="showTitle=0&";  		//Inhibit title display
	var pmCal="showCalendars=0&";  	//Inhibit other calendars
	var pmMode="mode=WEEK&";  			//Start with week view
	var pmHeight="height=440&";
	var pmWkst="wkst=2&";						//Week starts Monday
	var pmLang="hl=es&";						//Default language ES
	var pmBg="bgcolor=%23e8f1ce";		//Background color
	var qstring = "";
	var ndx = 0;
	for( ndx = 0; ndx <= CEIP_calendar.length - 1; ndx++ ) {
	/* If we are processing the main infant or primary calendar we will cycle through variables for both - only process variables for the calendar in question
     If infant or primary and infant but not an infant checkbox id or primary but not a primary id - break out the loop */
		if ((frame=='calInfFrame' || frame=='calPrimFrame') && ((frame=='calInfFrame' && CEIP_calendar[ndx][0].indexOf("INF")==-1)||(frame=='calPrimFrame' && CEIP_calendar[ndx][0].indexOf("PRIM")==-1))) {
			continue;
		}
		if( document.getElementById( CEIP_calendar[ndx][0] ).checked && CEIP_calendar[ndx][1] !== "" ) {
			qstring += 'src=' + CEIP_calendar[ndx][1] + '&';
		}
	}
	if( qstring === "" ) {
		alert( "Ningun calendario selecionado.");
	}
	else {
		qstring = "http://www.google.com/calendar/embed?" + qstring + pmTitle + pmCal + pmMode + pmHeight + pmWkst + pmLang + pmBg; 
// Refresh calendar.
		frames[frame].location.href = qstring;
	}
	return(0);
}
