﻿// JScript File

var wait_msg = 'Loading, please wait...';
var strProgram='Please Select a Program';
var pid=1; // promotion id, increment this every time you promote this file to handle caching problem in IE 

function EvtProgram(sponsor){ //When Program area List clicked 
	var programs = GetSelectedOptionsList('disciplines'); //selected Program list
	//alert(programs);
	//ClearList('locations',strProgram); 
	if (programs!=''){ 
		ClearList('locations',wait_msg); 
		// Create Ajax object 
		var obj_Ajax=new PcomAjax();  
		obj_Ajax.load('ajaxxmldata.asp?sponsor='+sponsor+'&reqtype=getlocation&pgm='+  programs.substring(0,(programs.length-1)) + '&pid='+pid, LoadLocations);
	}
}


function LoadLocations(xmldoc){ //Loads Degrees list with given xml doc 
    //alert("load locations");
   ClearList("locations");
	var locationList = document.getElementById('locations');
	var dNodes = xmldoc.getElementsByTagName('Data');
	FillList(locationList,dNodes);
	if(dNodes.length>0) 	
	DegreeListXml = xmldoc;
}

function SelectedProgramsCount(discipline)
{
var count = 0;
    for (i=0; i < discipline.length;i++)
   {
        if (discipline[i].selected)
        {
            count++;
        }
        
   }  
   if (count>20)
   {   
//alert("test on change")
        palert('Please limit your selection to 20 programs or less.',1);
        discipline.focus();
        return null;
   }
   else
   {
        palert('');
   }
   
   return true;
}

function palert(a,id){
	var i='';
	if (typeof(id) != 'undefined') i=id;
	var err=document.getElementById('errmsg'+i);
	for (var j=1; j<2; j++) document.getElementById('errmsg'+j).style.display='none';
		//alert ("test");
	if (a!='') {
		err.innerHTML=a;
		err.style.display='block';
	}
}
