function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		if (xmlHttp.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //xmlHttp.overrideMimeType('text/xml');
            xmlHttp.overrideMimeType('text/html');
         }
	}
	catch (e){
    	// Internet Explorer
	    try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
    }
	return xmlHttp;
}

function opendate(i){
	if(xmlHttpCalendarDate==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpCalendarDate.readyState == 4 || xmlHttpCalendarDate.readyState == 0) {
		url = "calendar_helper.php?expandDate="+i;
		document.getElementById('expandDateBox').style.visibility = "visible";
		xmlHttpCalendarDate.open("GET", url, true);	
		xmlHttpCalendarDate.onreadystatechange=handleDisplayCalDate;
		xmlHttpCalendarDate.send(null);
	}
}
function handleDisplayCalDate(){
	if (xmlHttpCalendarDate.readyState == 4) {
		openbox();
	}
}
function openbox(){
	var h = document.getElementById('expandDateBox').style.height.substr(0, document.getElementById('expandDateBox').style.height.length-2);
	if(boxOpen==0){
		h = h*1 + 10;
		document.getElementById('expandDateBox').style.height = h+"px";
		checkopen();
	}
}
function checkopen(){
	var h = document.getElementById('expandDateBox').style.height.substr(0, document.getElementById('expandDateBox').style.height.length-2);
	if(h < 200){
		setTimeout( 'openbox();', 1);
	} else {
		boxOpen = 1;
		document.getElementById('expandDateBox').style.height = "200px";
		document.getElementById('expandDateBox').innerHTML = xmlHttpCalendarDate.responseText;
	}
}

function closebox(){
	if(boxOpen==1){
		document.getElementById('expandDateBox').innerHTML = "";
		var h = document.getElementById('expandDateBox').style.height.substr(0, document.getElementById('expandDateBox').style.height.length-2);
		h = h*1 - 10;
		if(h<0){ h=0; }
		document.getElementById('expandDateBox').style.height = h+"px";
		checkclose();
	}
}
function checkclose(){
	var h = document.getElementById('expandDateBox').style.height.substr(0, document.getElementById('expandDateBox').style.height.length-2);
	if(h > 1){
		setTimeout( 'closebox();', 1);
		
	} else {
		boxOpen = 0;
		document.getElementById('expandDateBox').style.height = "0px";
		document.getElementById('expandDateBox').style.visibility = "hidden";
	}
}
function showCalendar(day, month, year){
	thisIsTheDay = day;
	thisIsTheMonth = month;
	thisIsTheYear = year;
	
	if(xmlHttpCalendar==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpCalendar.readyState == 4 || xmlHttpCalendar.readyState == 0) {
		url = "calendar_helper.php?day="+day+"&month="+month+"&year="+year+"&mynetworks="+escape(mynetworks2)+"&mylocations="+escape(mylocations2)+"&mytimes="+escape(mytimes2);
		
		document.getElementById('CalendarBox').innerHTML = '<br/><br/><br/><br/><br/><img src=\''+site+'/images/calendar/ajax-loader.gif\' border=\'0\' alt=\'loading\'>';
		xmlHttpCalendar.open("GET", url, true);
		xmlHttpCalendar.onreadystatechange=handleDisplayCal;
		xmlHttpCalendar.send(null);
	}
}
function handleDisplayCal(){
	if (xmlHttpCalendar.readyState == 4) {
		document.getElementById('CalendarBox').innerHTML = xmlHttpCalendar.responseText;
	}
}


function addEvent(){
	if(xmlHttpAddCalEvent==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}

	var eventTitle = encodeURIComponent(document.eventform.title.value);
	var eventDescription = encodeURIComponent(document.eventform.description.value);
	var eventStartDay = document.eventform.startday.options[document.eventform.startday.selectedIndex].text;
	var eventStartMonth = document.eventform.startmonth.options[document.eventform.startmonth.selectedIndex].text;
	var eventStartYear = document.eventform.startyear.options[document.eventform.startyear.selectedIndex].text;
	var eventStartTime = document.eventform.starttime.options[document.eventform.starttime.selectedIndex].text;
	var eventEndDay = document.eventform.endday.options[document.eventform.endday.selectedIndex].text;
	var eventEndMonth = document.eventform.endmonth.options[document.eventform.endmonth.selectedIndex].text;
	var eventEndYear = document.eventform.endyear.options[document.eventform.endyear.selectedIndex].text;
	var eventEndTime = document.eventform.endtime.options[document.eventform.endtime.selectedIndex].text;
	var eventAbilityLevel = document.eventform.abilityLevel.options[document.eventform.abilityLevel.selectedIndex].value;
	var eventGuestsAllowed = document.eventform.guestsAllowed.checked;
	var eventCommentsAllowed = true;
	var eventPublicEvent = document.eventform.publicEvent.checked;
	//networkQuery = "";
	//for (ndx = 0; ndx < document.eventform.networks.length; ndx++) {  
	//	networkQuery = networkQuery + "&net" +ndx +"="+document.eventform["networks[]"][ndx].value; 
	//} 
	//locationQuery = "";
	//for (ndx = 0; ndx < document.eventform.locations.length; ndx++) {  
	//	locationQuery = locationQuery + "&loc" +ndx +"="+document.eventform["locations[]"][ndx].value; 
	//} 
	var locationQuery = "&loc0="+document.eventform.locations.options[document.eventform.locations.selectedIndex].value;
	var networkQuery = "&net0="+document.eventform.networks.options[document.eventform.networks.selectedIndex].value;

	//alert(locationQuery);
	//alert(networkQuery);

	var eventCompanyId = document.eventform.companyId.value;
	if(eventStartDay.length==1){
		eventStartDay = "0"+eventStartDay;	
	}
	if(eventStartMonth.length==1){
		eventStartMonth = "0"+eventStartMonth;	
	}
	if(eventEndDay.length==1){
		eventEndDay = "0"+eventEndDay;	
	}
	if(eventEndMonth.length==1){
		eventEndMonth = "0"+eventEndMonth;	
	}
	
	var eventStartDate = eventStartDay+"-"+eventStartMonth+"-"+eventStartYear;
	var eventEndDate = eventEndDay+"-"+eventEndMonth+"-"+eventEndYear;
	
	if(eventTitle=="" || eventDescription==""){
		alert("The title and description are mandatory fields.");
	} else {
		if(eventEndYear+""+eventEndMonth+""+eventEndDay+""+eventEndTime < eventStartYear+""+eventStartMonth+""+eventStartDay+""+eventStartTime ){
			alert("The end date of your event may not be before the start date.");
		} else {
			if (xmlHttpAddCalEvent.readyState == 4 || xmlHttpAddCalEvent.readyState == 0) {
				url = "calendar_helper.php?title="+eventTitle+"&description="+eventDescription+"&startDate="+eventStartDate+"&startTime="+eventStartTime+"&EndDate="+eventEndDate+"&EndTime="+eventEndTime+"&abilityLevel="+eventAbilityLevel+"&guestsAllowed="+eventGuestsAllowed+"&companyId="+eventCompanyId+"&commentsAllowed="+eventCommentsAllowed+"&publicEvent="+eventPublicEvent+locationQuery+networkQuery;
				document.getElementById('expandDateBox').innerHTML = '<br/><br/><br/><br/><br/><img src=\''+site+'/images/calendar/ajax-loaderbw.gif\' border=\'0\' alt=\'loading\'>';
				xmlHttpAddCalEvent.open("GET", url, true);
				xmlHttpAddCalEvent.onreadystatechange=handleaddEvent;
				xmlHttpAddCalEvent.send(null);
			}
		}
	}
}
function handleaddEvent(){
	if (xmlHttpAddCalEvent.readyState == 4) {
		document.getElementById('expandDateBox').innerHTML = xmlHttpAddCalEvent.responseText;
		//alert(xmlHttpAddCalEvent.responseText.length);
		if(xmlHttpAddCalEvent.responseText.substr(0, 2) != "XX"){
			var day = xmlHttpAddCalEvent.responseText.substr(0, 2);
			var month = xmlHttpAddCalEvent.responseText.substr(2, 2);
			var year = xmlHttpAddCalEvent.responseText.substr(4, 4);
			alert ("Your event has been added successfully");
			//closebox();
			window.location = window.location;
			//alert (xmlHttpAddCalEvent.responseText)	;
			showCalendar(day, month, year);
		} else {
			alert (xmlHttpAddCalEvent.responseText)	;
		}
	}
}


function deleteEvent(i,date){
	if(xmlHttpDeleteEvent==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpDeleteEvent.readyState == 4 || xmlHttpDeleteEvent.readyState == 0) {
		j = confirm("Are you sure you wish to remove this event?");
		if(j){
			url = "calendar_helper.php?deleteEvent="+i+"&date="+date;
			xmlHttpDeleteEvent.open("GET", url, true);	
			xmlHttpDeleteEvent.onreadystatechange=handleDeleteEvent;
			xmlHttpDeleteEvent.send(null);
		}
	}
}
function handleDeleteEvent(){
	if (xmlHttpDeleteEvent.readyState == 4) {
		if(xmlHttpDeleteEvent.responseText.length>12){
			alert(xmlHttpDeleteEvent.responseText);
		} else {
			var day = xmlHttpDeleteEvent.responseText.substr(0, 2);
			var month = xmlHttpDeleteEvent.responseText.substr(3, 2);
			var year = xmlHttpDeleteEvent.responseText.substr(6, 4);
			showCalendar(day, month, year);
			opendate(xmlHttpDeleteEvent.responseText);
		}
	}
}

function editEvent(i, date){
	if(xmlHttpEditEvent==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpEditEvent.readyState == 4 || xmlHttpEditEvent.readyState == 0) {
		url = "calendar_helper.php?editEvent="+i+"&date="+date;
		xmlHttpEditEvent.open("GET", url, true);	
		xmlHttpEditEvent.onreadystatechange=handleEditEvent;
		xmlHttpEditEvent.send(null);
	}
}
function handleEditEvent(){
	if (xmlHttpEditEvent.readyState == 4) {
		document.getElementById('expandDateBox').innerHTML = xmlHttpEditEvent.responseText;
	}
}


function confirmEditEvent(){
	if(xmlHttpconfirmEditEvent==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	var i = document.eventform.id.value
	var date = document.eventform.datet.value
	var eventTitle = document.eventform.title.value
	var eventDescription = document.eventform.description.value
	var eventStartDay = document.eventform.startday.options[document.eventform.startday.selectedIndex].text
	var eventStartMonth = document.eventform.startmonth.options[document.eventform.startmonth.selectedIndex].text
	var eventStartYear = document.eventform.startyear.options[document.eventform.startyear.selectedIndex].text
	var eventStartTime = document.eventform.starttime.options[document.eventform.starttime.selectedIndex].text
	var eventEndDay = document.eventform.endday.options[document.eventform.endday.selectedIndex].text
	var eventEndMonth = document.eventform.endmonth.options[document.eventform.endmonth.selectedIndex].text
	var eventEndYear = document.eventform.endyear.options[document.eventform.endyear.selectedIndex].text
	var eventEndTime = document.eventform.endtime.options[document.eventform.endtime.selectedIndex].text
	if(eventStartDay.length==1){
		eventStartDay = "0"+eventStartDay;	
	}
	if(eventStartMonth.length==1){
		eventStartMonth = "0"+eventStartMonth;	
	}
	if(eventEndDay.length==1){
		eventEndDay = "0"+eventEndDay;	
	}
	if(eventEndMonth.length==1){
		eventEndMonth = "0"+eventEndMonth;	
	}
	var eventStartDate = eventStartDay+"-"+eventStartMonth+"-"+eventStartYear;
	var eventEndDate = eventEndDay+"-"+eventEndMonth+"-"+eventEndYear;
	if(eventTitle=="" || eventDescription==""){
		alert("The title and description are mandatory fields.");
	} else {
		if(eventEndYear+""+eventEndMonth+""+eventEndDay+""+eventEndTime < eventStartYear+""+eventStartMonth+""+eventStartDay+""+eventStartTime ){
			alert("The end date of your event may not be before the start date.");
		} else {
			if (xmlHttpconfirmEditEvent.readyState == 4 || xmlHttpconfirmEditEvent.readyState == 0) {
				url = "calendar_helper.php?id="+i+"&ititle="+eventTitle+"&description="+eventDescription+"&startDate="+eventStartDate+"&startTime="+eventStartTime+"&EndDate="+eventEndDate+"&EndTime="+eventEndTime;
				xmlHttpconfirmEditEvent.open("GET", url, true);	
				xmlHttpconfirmEditEvent.onreadystatechange=handleconfirmEditEvent;
				xmlHttpconfirmEditEvent.send(null);
			}
		}
	}
}
function handleconfirmEditEvent(){
	if (xmlHttpconfirmEditEvent.readyState == 4) {
	document.getElementById('expandDateBox').innerHTML = xmlHttpconfirmEditEvent.responseText;
		if(xmlHttpconfirmEditEvent.responseText.length<=8){
			
			var day = xmlHttpconfirmEditEvent.responseText.substr(0, 2);
			var month = xmlHttpconfirmEditEvent.responseText.substr(2, 2);
			var year = xmlHttpconfirmEditEvent.responseText.substr(4, 4);
			alert ("Your event has been editted successfully");
			closebox();
			//alert (xmlHttpconfirmEditEvent.responseText)	;
			showCalendar(day, month, year);
		} else {
			alert ("ERROR \n\n "+xmlHttpconfirmEditEvent.responseText)	;
		}
	}
}

//function changeNetworkView(networks){
//	mynetworks = array(networks);
//}
function filter_start(valueN, valueL){
	filter_network(valueN,'1');
	filter_location(valueL,'1');
	document.getElementById('networksLabel1').style.fontWeight = '900';
	document.getElementById('locationsLabel1').style.fontWeight = '900';
}

function filter_network(value, sp){
	var sp = (sp == null) ? 0 : sp;

	document.getElementById("networksLabel1").style.fontWeight = '100';
	document.getElementById("networksLabel2").style.fontWeight = '100';
	day = thisIsTheDay;
	month = thisIsTheMonth;
	year = thisIsTheYear;
	if(value!=""){
		mynetworks2 = value.split(", ");
	} else {
		mynetworks2 = mynetworks;
	}
	if(sp=='0'){
		showCalendar(day, month, year);
		show_network_items();
	}

}
function filter_location(value){
	document.getElementById("locationsLabel1").style.fontWeight = '100';
	document.getElementById("locationsLabel2").style.fontWeight = '100';
	day = thisIsTheDay;
	month = thisIsTheMonth;
	year = thisIsTheYear;
	if(value!=""){
		mylocations2 = new Array(value);
	} else {
		mylocations2 = mylocations;
	}
	showCalendar(day, month, year);
	show_location_items();
}
function filter_times(value){
	document.getElementById("timesLabel1").style.fontWeight = '100';
	day = thisIsTheDay;
	month = thisIsTheMonth;
	year = thisIsTheYear;
	if(value!=""){
		mytimes2 = new Array(value);
	} else {
		mytimes2 = mytimes;
	}
	showCalendar(day, month, year);
	show_times_items();
}

function show_network_items(){
	if(xmlHttpCalendar_g1==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpCalendar_g1.readyState == 4 || xmlHttpCalendar_g1.readyState == 0) {
		url = "calendar_helper.php?get_network_items="+mynetworks2;
		//document.getElementById('network_items').innerHTML = '<img src=\''+site+'/images/calendar/ajax-loader.gif\' border=\'0\' alt=\'loading\' />';
		xmlHttpCalendar_g1.open("GET", url, true);
		xmlHttpCalendar_g1.onreadystatechange=HANDLEshow_network_items;
		xmlHttpCalendar_g1.send(null);
	}
}
function HANDLEshow_network_items(){
	if (xmlHttpCalendar_g1.readyState == 4) {
		document.getElementById('network_items').innerHTML = xmlHttpCalendar_g1.responseText;
	}
}

function show_location_items(){
	if(xmlHttpCalendar_g2==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpCalendar_g2.readyState == 4 || xmlHttpCalendar_g2.readyState == 0) {
		url = "calendar_helper.php?get_location_items="+mylocations2;
		//document.getElementById('location_items').innerHTML = '<img src=\''+site+'/images/calendar/ajax-loader.gif\' border=\'0\' alt=\'loading\' />';
		xmlHttpCalendar_g2.open("GET", url, true);
		xmlHttpCalendar_g2.onreadystatechange=HANDLEshow_location_items;
		xmlHttpCalendar_g2.send(null);
	}
}
function HANDLEshow_location_items(){
	if (xmlHttpCalendar_g2.readyState == 4) {
//		alert(xmlHttpCalendar_g2.responseText);
		document.getElementById('location_items').innerHTML = xmlHttpCalendar_g2.responseText;
	}
}

function show_times_items(){
	if(xmlHttpCalendar_g3==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	mytimes2.sort();
	if (xmlHttpCalendar_g3.readyState == 4 || xmlHttpCalendar_g3.readyState == 0) {
		url = "calendar_helper.php?get_times_items="+mytimes2;
		//document.getElementById('times_items').innerHTML = '<img src=\''+site+'/images/calendar/ajax-loader.gif\' border=\'0\' alt=\'loading\' />';
		xmlHttpCalendar_g3.open("GET", url, true);
		xmlHttpCalendar_g3.onreadystatechange=HANDLEshow_times_items;
		xmlHttpCalendar_g3.send(null);
	}
}
function HANDLEshow_times_items(){
	if (xmlHttpCalendar_g3.readyState == 4) {
		document.getElementById('times_items').innerHTML = xmlHttpCalendar_g3.responseText;
	}
}
function reg_move_to_stage_one(){
	document.getElementById('first_name').value = "";
	document.getElementById('last_name').value = "";
	document.getElementById('theiremail').value = "";
	document.getElementById('first_name').readOnly = false;
	document.getElementById('last_name').readOnly = false;
	document.getElementById('theiremail').readOnly = false;
	document.getElementById('find_company').style.display = 'inline'
	document.getElementById('start_over').style.display = 'none';
	document.getElementById('office_locations').style.display = 'none';
	document.getElementById('stage_one_helper').style.display = 'inline';
	document.getElementById('stage_two_helper').style.display = 'none';
	document.getElementById('stage_two').style.display = 'none';

}
function reg_move_to_stage_two() {
	first_name = document.getElementById('first_name').value;
	last_name = document.getElementById('last_name').value;
	theiremail = document.getElementById('theiremail').value;

	if(first_name.length>=2 && last_name.length>=2 && theiremail.length>=5 && theiremail.indexOf("@")!=-1 && theiremail.indexOf(".")!=-1){
		find_company(theiremail);
	} else {
		alert("Please provide a valid first and last name as well as a valid e-mail address...");
	}
}
function find_company(theiremail){
	if(xmlHttpreg1==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpreg1.readyState == 4 || xmlHttpreg1.readyState == 0) {
		url = "assist.php?reg_find_company="+escape(theiremail);
		//alert("here: " + site + "/assist.php?reg_find_company="+escape(theiremail));
		xmlHttpreg1.open("GET", url, true);
		xmlHttpreg1.onreadystatechange=HANDLEfind_company;
		xmlHttpreg1.send(null);
	}
}
function HANDLEfind_company(){
	if (xmlHttpreg1.readyState == 4) {
		//alert(xmlHttpreg1.responseText);
		
		if(xmlHttpreg1.responseText.substring(0,1)=="2"){
			for_pass = confirm("That email address is already registered here - have you forgotten your password?");
			if(for_pass===true){
				window.location = 'index.php?area=forgottenpass';
			}
		} else {
			upto = xmlHttpreg1.responseText.indexOf("[[[");
			company_id= xmlHttpreg1.responseText.split("[[[");
			locations = xmlHttpreg1.responseText.split("--SEP--");
			numLocations = locations.length;
			officeOptions = "";
			for(p=1; p<numLocations; p++){
				if(locations[p]!=""){
					q=p+1;
					officeOptions += "<option value='"+locations[q]+"'";
					if(p==1){
						officeOptions += " selected";
					}
					officeOptions += ">"+locations[p]+"</option>";
					p++;
				}
			}
			if(upto<0){
				upto = xmlHttpreg1.responseText.length;
			}
			document.getElementById('myOfficeLocations').innerHTML = "<input type='hidden' name='company_id' value='"+company_id[1]+"'/><span style='font-size:13px;'>Use the Ctrl button to select more than one location</span><br/><select style='width:190px; height:70px; float:left; margin-left:90px;' size='4' class='textbox' name='reg_office_locations[]' id='reg_office_locations' multiple>"+officeOptions+"<option value='-1'>I'll Choose later</option></select>";
			document.getElementById('stage_one_helper').style.display = 'none';
			document.getElementById('stage_two_helper').style.display = 'inline';
			document.getElementById('stage_two').style.display = 'inline';
			
			document.getElementById('first_name').readOnly = true;
			document.getElementById('last_name').readOnly = true;
			document.getElementById('theiremail').readOnly = true;
			document.getElementById('find_company').style.display = 'none'
			document.getElementById('start_over').style.display = 'inline';
			
			if(xmlHttpreg1.responseText.substring(0, 1)=="1"){
				showBalloon("office", 320, 720, 179, 81);
				document.getElementById('company_name').value = xmlHttpreg1.responseText.substring(1, upto);
				document.getElementById('office_locations').style.display = 'inline';
				document.getElementById('reg_company_text').innerHTML = "<input type=\'submit\' value=\'Sign up!\' name=\'sign_up\' class=\'submit_button\' style='margin-left:10px; margin-top:50px;' onclick=\'javascript:register_me();\'/><div class=\'disclaimer\' style='clear:both;'>Please take the time to read our <a href=\'index.php?area=terms\'>terms and conditions</a>. By clicking \"Sign Up!\" you are indicating that you have read the <a href=\'index.php?area=terms\'>terms and conditions</a> and agree to adhere to them at all times.</div>";
				document.getElementById('got_company').value="1";
			} else {
				document.getElementById('company_name').readOnly = false;
				document.getElementById('office_locations').style.display = 'none';
				document.getElementById('reg_company_text').innerHTML = "<p>Please type your company name in the box above to finish sign up.</p><input type=\'submit\' value=\'Sign up!\' name=\'sign_up\' class=\'submit_button\' onclick=\'javascript:register_me();\'/><div class=\'disclaimer\' style='clear:both;'>Please take the time to read our <a href=\'index.php?area=terms\'>terms and conditions</a>. By clicking \"Sign Up!\" you are indicating that you have read the <a href=\'index.php?area=terms\'>terms and conditions</a> and agree to adhere to them at all times.</div>";
				document.getElementById('got_company').value="0";
			}
		}
	}
}
function return_false(){
	return false;
}
function register_me(){
	document.registration_form.submit();
}

function toggleEmailBox(id){
	if(document.getElementById('email-'+id+'').disabled===true){
		document.getElementById('email-'+id+'').disabled = false;
		document.getElementById('email-'+id+'').checked = true;
	} else {
		document.getElementById('email-'+id+'').disabled = true;
		document.getElementById('email-'+id+'').checked = false;
	}
}

function toggle(id, min, max){
	if(document.getElementById(id).style.height.substring(0, document.getElementById(id).style.height.indexOf("px")) < max*1 || document.getElementById(id).style.height == ""){
		increaseHeight(id, max);
	} else {
		decreaseHeight(id, min);
	}
}

function increaseHeight(id, max){
	currentHeight = document.getElementById(id).style.height.substring(0, document.getElementById(id).style.height.indexOf("px"));
	if(currentHeight*1 < max*1){
		document.getElementById(id).style.height = (currentHeight*1+25)+"px";
		setTimeout("increaseHeight(\""+id+"\", \""+max*1+"\")", 20);
	} else {
		document.getElementById(id).style.height = max+"px";
	}
}

function decreaseHeight(id, min){
	currentHeight = document.getElementById(id).style.height.substring(0, document.getElementById(id).style.height.indexOf("px"));
	if(currentHeight*1>min*1){
		newVal = Math.max(0, currentHeight*1-25);
		document.getElementById(id).style.height = newVal+"px";
		setTimeout("decreaseHeight(\""+id+"\", \""+min*1+"\")", 20);
	} else {
		document.getElementById(id).style.height = min+"px";
	}
}

function showBalloon(file, top, left, width, height){
	document.getElementById("balloon").style.top = top+'px';
	document.getElementById("balloon").style.left = left+'px';
	document.getElementById("balloon").style.display = 'block';
	document.getElementById("balloon").style.backgroundImage = 'url('+site+'/images/balloon_'+file+'.png)';
	document.getElementById("balloon").style.width = width+'px';
	document.getElementById("balloon").style.height = height+'px';
}

function hideBalloon(file){
	document.getElementById("balloon").style.display = 'none';
	document.getElementById("balloon").style.backgroundImage = '';
	document.getElementById("balloon").style.width = '0px';
	document.getElementById("balloon").style.height = '0px';
}

function editAbout(id){
	if(xmlHttpEditAbout==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpEditAbout.readyState == 4 || xmlHttpEditAbout.readyState == 0) {
		url = "assist.php?editAbout="+id;
		//alert("here: " + site + "/assist.php?reg_find_company="+escape(theiremail));
		xmlHttpEditAbout.open("GET", url, true);
		xmlHttpEditAbout.onreadystatechange=function (){
			HANDLEeditAbout(id);
		}
		xmlHttpEditAbout.send(null);
	}
}
function HANDLEeditAbout(id){
	if (xmlHttpEditAbout.readyState == 4) {
		document.getElementById("aboutText").innerHTML = "<form action='' method='post' ><textarea class='claTxtBox' style='width:200px; height:100px;' name='aboutText'>"+xmlHttpEditAbout.responseText+"</textarea><br/><input type='hidden' value='"+id+"' name='eventId' /><input type='submit' value='Save' name='updateAbout' class=''/></form>";
	}
}

function closeEventDialog(){
	document.getElementById('expandDateBox').style.visibility = "hidden";
}

function toggleEndDate(){
	if(document.getElementById('endTimings').style.visibility=="visible"){
		document.getElementById('endTimings').style.visibility="hidden";
		document.getElementById('endTimings').style.height="0px";
	} else {
		document.getElementById('endTimings').style.visibility="visible";
		document.getElementById('endTimings').style.height="100px";
	}
}

function setEndDay(){
	var eventStartDay = document.eventform.startday.options[document.eventform.startday.selectedIndex].text
	document.eventform.endday.options[document.eventform.endday.selectedIndex].text = eventStartDay;
}
function setEndMonth(){
	var eventStartMonth = document.eventform.startmonth.options[document.eventform.startmonth.selectedIndex].text
	document.eventform.endmonth.options[document.eventform.endmonth.selectedIndex].text = eventStartMonth;
}
function setEndYear(){
	var eventStartYear = document.eventform.startyear.options[document.eventform.startyear.selectedIndex].text
	document.eventform.endyear.options[document.eventform.endyear.selectedIndex].text = eventStartYear;
}
function setEndTime(){
	var eventStartYear = document.eventform.starttime.options[document.eventform.starttime.selectedIndex].text
	document.eventform.endtime.options[document.eventform.endtime.selectedIndex].text = eventStartYear;
}

function blockSubmit(){
	
	dothis = confirm("Are you sure you want transfer your account?");
	if(!dothis){
		return false;
	}
}

function makeThisBoldN(id, value){
	filter_network(value);
	document.getElementById(id).style.fontWeight = '900';
}
function makeThisBoldL(id, value){
	filter_location(value);
	document.getElementById(id).style.fontWeight = '900';
}
function makeThisBoldT(id, value){
	filter_times(value);
	document.getElementById(id).style.fontWeight = '900';
}

function updateContactList(eventId){
	if(!eventId) {
		var eventId = "";
	}

	document.getElementById("peopleListFix").innerHTML = "<option>----- SEARCHING -----<option>";
	if(xmlHttpEditAbout==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpEditAbout.readyState == 4 || xmlHttpEditAbout.readyState == 0) {
		var name = escape(document.contactForm.searchName.value);
		var loc = escape(document.contactForm.searchLocation.options[document.contactForm.searchLocation.selectedIndex].value);
		var net = escape(document.contactForm.searchNetwork.options[document.contactForm.searchNetwork.selectedIndex].value);
		url = "assist.php?updateContactList=true&name="+name+"&loc="+loc+"&net="+net+"&eid="+eventId;
		xmlHttpEditAbout.open("GET", url, true);
		xmlHttpEditAbout.onreadystatechange=function (){
			handleUpdateContactList();
		}
		xmlHttpEditAbout.send(null);
	}
}
function handleUpdateContactList(){
	if (xmlHttpEditAbout.readyState == 4) {
		document.getElementById("peopleListFix").innerHTML = "<select size='10' name='peopleList[]' multiple  id='peopleList'  class='formEltWidthMedium' onchange = 'showContactChoice();'>"+xmlHttpEditAbout.responseText+"</select>";
	}
}
function showContactChoice(){
	var pick = document.contactForm.peopleList.value;
	showMiniProfile(pick);
}
function showMiniProfile(id){
	document.getElementById("miniProfile").innerHTML = "Loading profile..";
	if(xmlHttpreg1==(null)){
		alert("Your browser does not support AJAX!");
		return;
	}
	if (xmlHttpreg1.readyState == 4 || xmlHttpreg1.readyState == 0) {
		url = "assist.php?miniProfile="+id;
		xmlHttpreg1.open("GET", url, true);
		xmlHttpreg1.onreadystatechange=function (){
			handleshowMiniProfile();
		}
		xmlHttpreg1.send(null);
	}
}
function handleshowMiniProfile(){
	if (xmlHttpreg1.readyState == 4) {
		document.getElementById("miniProfile").innerHTML = xmlHttpreg1.responseText;
	}
}

var genericAutocomplete = {
	off : function(srcInputID) {
		var tag = document.getElementById(srcInputID)
		if (tag) {
			tag.value = '';
		}
	} //end of turnOff
} //end of genericAutocomplete

