			djConfig = {parseOnLoad:false};  			

			function setHolidayLanguages()
			{
				var dropdownIndex = document.getElementById('holidayXY_category').selectedIndex;
				var option=document.getElementById('holidayXY_category').options[dropdownIndex].value;
				document.getElementById('holidayXY_language').options.length=0;
				
				var x=document.getElementById('holidayXY_language_'+option).options;
				
				for(i=0;i<x.length;i++)
				{
					name=x[i].text;
					value=x[i].value;
					document.getElementById('holidayXY_language').options[document.getElementById('holidayXY_language').options.length]=new Option(name,value, false, false);
				}
							
			}
			
			var selectedHolidays=new Array();
			
			function loadOldHolidays()
			{
				var oldHolidays=document.getElementById('selected_holidayXYs').value;
				
				var x=oldHolidays.split(",");
				selectedHolidays.length=0;
				for(i=0;i<x.length;i++)
				{
					
					if(x[i].indexOf("_")>0) selectedHolidays[selectedHolidays.length]=x[i];
				}
				
			}
			
			function setSelectedHolidays()
			{
				var dropdownIndex = document.getElementById('holidayXY_category').selectedIndex;
				var selectedHoliday=document.getElementById('holidayXY_category').options[dropdownIndex].value;

				var dropdownIndex2 = document.getElementById('holidayXY_language').selectedIndex;
				var selectedLanguage=document.getElementById('holidayXY_language').options[dropdownIndex2].value;
				
				
				selectedHolidays[selectedHolidays.length]=selectedHoliday+"_"+selectedLanguage;
				
				displaySelectedHolidays();				
			}
			
			function displaySelectedHolidays()
			{
				var text="";
				var svalue="";
				
				for(k=0;k<selectedHolidays.length;k++)
				{
					var x=document.getElementById('holidayXY_categories').options;
				
					for(i=0;i<x.length;i++)
					{
						name=x[i].text;
						value=x[i].value;
						if(value==selectedHolidays[k]) {
							text=text+name+"&nbsp;&nbsp;<a style='cursor:pointer;' onclick='deleteHoliday(\""+value+"\")'>Remove</a>"+" <br/>";
							svalue=svalue+value+",";
						}
					}
					
				}
				
				document.getElementById('selected_holidayXYs_div').innerHTML=text;
				document.getElementById('selected_holidayXYs').value=svalue;
			
			}
			
			function deleteHoliday(value)
			{
				loadOldHolidays();
				for(i=0;i<selectedHolidays.length;i++)
				{
					if(selectedHolidays[i]==value){
						selectedHolidays.splice(i,1);
					}
				}
				displaySelectedHolidays();
			}
	
			
			
			var calendarParams=new Array();

			var counters=new Array();
		
			function headersearch(sp)
			{
				var x=document.getElementById('headersearch');
				if(x.value==sp) x.value="";
				
			}

			var holidayDisplayShown=null;
			
			function display(id)
			{
				if(holidayDisplayShown!=null)
				{
					var y=document.getElementById(holidayDisplayShown);
					y.style.display='none';
					document.getElementById(holidayDisplayShown+"_x").style.backgroundColor="#ffffff";
				}
				var x=document.getElementById(id);
				x.style.display='block';
				document.getElementById(id+"_x").style.backgroundColor="#c4c4c4";
				holidayDisplayShown=id;
				
			}
			
			function headerTestEnter(e)
			{
				if(window.event && window.event.keyCode == 13) document.location='search.jsp?keyword='+document.getElementById('headersearch').value;
				else if(e.which) // Netscape/Firefox/Opera
  				{
  					
  					var keynum = e.which;
  					if(keynum==13) document.location='search.jsp?keyword='+document.getElementById('headersearch').value;
  				}
				
				return true;
			}
			
			
			function show(id)
			{
				if(counters[id]== undefined) counters[id]=0;
				
				counters[id]=counters[id]+1;
				var count=counters[id];
				
				
				setTimeout('showIt("'+id+'","'+count+'")',100);
			}
			
			function hide(id)
			{
				if(counters[id]== undefined) counters[id]=0;

				counters[id]=counters[id]+1;
				var count=counters[id];

				setTimeout('hideIt("'+id+'","'+count+'")',250);
			}
			
			function showIt(id,count)
			{
				if(counters[id]!=count) return;
				document.getElementById(id).style.display='block';
			}
			
			function hideIt(id,count)
			{
				if(counters[id]!=count) return;
				document.getElementById(id).style.display='none';
			}
			
			
			function form_enable(id)
			{
				document.getElementById(id+"_add").style.display="none";
				document.getElementById(id+"_field").style.display="block";
				
			}
			
			function isEmpty(id)
			{
				var value=document.getElementById(id).value;
				if(value.length==0) return true;
				return false;
				
			}
	
			
			function setCalendarContent(id)
			{
				var today=calendarParams[id];
				document.getElementById(id+"Month").innerHTML=monthNames[today.getMonth()]+" "+today.getFullYear();
				
				
				var startMonth=new Date(today.getFullYear(),today.getMonth(),1);
				
				
				var week=0;
				var first=true;
				var month=startMonth.getMonth();
				
				for(var x=0;x<6;x++){
					for(var y=0;y<7;y++) {
						document.getElementById(id+x+"_"+y).innerHTML="";
						document.getElementById(id+x+"_"+y).style.display="none";
						document.getElementById(id+x+"_"+y).style.backgroundColor="#ffffff";
					}
				}
				
				
				for(var x=0;month==startMonth.getMonth();x++)
				{
					if(startMonth.getDay()==1 && !first)
					{
						week=week+1;
					}
				
					var day=startMonth.getDay();
					day=day-1;
					if(day<0) day=6;
					document.getElementById(id+week+"_"+day).innerHTML=startMonth.getDate();
					document.getElementById(id+week+"_"+day).style.display="block";
					document.getElementById(id+week+"_"+day).onclick=Function("setDateValue('"+id+"','"+startMonth.getFullYear()+"','"+startMonth.getMonth()+"','"+startMonth.getDate()+"')");

					if(calendarParams[id+"today"].getDate()==startMonth.getDate() &&
					   calendarParams[id+"today"].getMonth()==startMonth.getMonth() &&
					   calendarParams[id+"today"].getFullYear()==startMonth.getFullYear()) document.getElementById(id+week+"_"+day).style.backgroundColor="#ffcccc";

					first=false;
				
					startMonth.setDate(startMonth.getDate()+1);
					//alert(startMonth.getMonth());
				
				}
				
				
			}
			
			var calendarFormIds=new Array();
			
			function hasFormId(id)
			{
				for(var i=0;i<calendarFormIds.length;i=i+1)
				{
					if(calendarFormIds[i]==id) return true;
					
				}
				return false;
				
			}
			
			function setDateValue(id,year,month,date)
			{
				
				if(!hasFormId(id)) {
				
					calendarFormIds[calendarFormIds.length]=id;
				}
				document.getElementById(id).value=""+year+"/"+month+"/"+date;
				var d=new Date(year,month,date);
				document.getElementById(id+"Disp").value=""+d.getDate()+" "+monthNames[d.getMonth()]+" "+d.getFullYear();
				//initCalendar(id);
				document.getElementById(id+"Container").style.display='none';
			}
		
			function initCalendar(id)
			{
				var x=document.getElementById(id+"Container");
				if(x.style.display=='none')
				{
					var value=document.getElementById(id).value;
					var calYear=value.substring(0,value.indexOf('/'));
					var calMonth=value.substring(value.indexOf('/')+1,value.lastIndexOf('/'));
					var calDay=value.substring(value.lastIndexOf('/')+1,value.length);
					
					var today=new Date(calYear,calMonth,calDay);
					calendarParams[id]=today;
					calendarParams[id+"today"]=today;
					setCalendarContent(id);
				
				
					x.style.display='block';
					var activeNow=false;
					for(var i=0;i<calendarFormIds.length;i++)
					{
						
						if(id!=calendarFormIds[i] && activeNow==true) document.getElementById("wrapper_"+calendarFormIds[i]).style.visibility='hidden';
						if(id==calendarFormIds[i]) activeNow=true;
						
					}
					
					
				}
				else
				{
					x.style.display='none';
					for(var i=0;i<calendarFormIds.length;i++)
					{
						
						 document.getElementById("wrapper_"+calendarFormIds[i]).style.visibility='visible';
					}

				}				
			}

			function subMonth(id)
			{
				var date=calendarParams[id];
				var month=date.getMonth();
				var year=date.getFullYear();
				month=month-1;
				if(month<0){
					month=11;
					year=year-1;
				}
				date=new Date(year,month,date.getDate());
				//date.setFullYear(year);
				calendarParams[id]=date;
				setCalendarContent(id);
			
			}

			
			
			function addMonth(id)
			{
				var date=calendarParams[id];
				var month=date.getMonth();
				var year=date.getFullYear();
				month=month+1;
				if(month>11){
					month=0;
					year=year+1;
				}
				date=new Date(year,month,date.getDate());
				//date.setFullYear(year);
				calendarParams[id]=date;
				setCalendarContent(id);
			
			}

			function loadExistingCalendarEntry(language,id)
			{
				
				dojo.xhrGet({
				    url: "calendar_entryview.jsp?id="+id+"&language="+language,
				    load: function(response, ioArgs){
				      dojo.byId("entryView").innerHTML = response;
				      //dojo.byId("calendar_entry").style.display="block";
				      //setDateValue('fromDate',year,month,date);
				      //setDateValue('toDate',year,month,date);
				      //Dojo recommends that you always return(response); to propagate 
				      //the response to other callback handlers. Otherwise, the error 
				      //callbacks may be called in the success case.
				      return response;
				    },
				    error: function(response, ioArgs){
				      dojo.byId("entryView").innerHTML = 
				        " " + response;
				    //  dojo.byId("calendar_entry").style.display="block";
				      
				      return response;
				    },
				    handleAs: "text"
				  });
				}
			
			
function loadNewCalendarEntry(language,id,date,month,year)
{
	//alert("here1");
	var dt=new Date();
	if(dt.getTime()<lastFormRun+2000) return;
	lastFormRun=dt.getTime();
	
	dojo.xhrGet({
	    url: "calendar_entry.jsp?id="+id+"&language="+language+"&"+params,
	    load: function(response, ioArgs){
			//alert(response);
	      dojo.byId("popUpDiv").innerHTML = response;
	      popup('popUpDiv');
	      setDateValue('fromDate',year,month,date);
	      setDateValue('toDate',year,month,date);
	      //Dojo recommends that you always return(response); to propagate 
	      //the response to other callback handlers. Otherwise, the error 
	      //callbacks may be called in the success case.
	      return response;
	    },
	    error: function(response, ioArgs){
	      dojo.byId("popUpDiv").innerHTML = 
	        " " + response;
	      //dojo.byId("popup_div").style.display="block";
	      popup('popUpDiv');
	      return response;
	    },
	    handleAs: "text"
	  });
	}

function loadOldCalendarEntry(language,id,fromdate,frommonth,fromyear,todate,tomonth,toyear)
{
	dojo.xhrGet({
	    url: "calendar_edit_entry.jsp?id="+id+"&language="+language+"&calendar_id="+calendarId+"&"+params,
	    load: function(response, ioArgs){
	      dojo.byId("calendar_entry").innerHTML = response;
	      dojo.byId("calendar_entry").style.display="block";
	      setDateValue('fromDate',fromyear,frommonth,fromdate);
	      setDateValue('toDate',toyear,tomonth,todate);
	      //Dojo recommends that you always return(response); to propagate 
	      //the response to other callback handlers. Otherwise, the error 
	      //callbacks may be called in the success case.
	      return response;
	    },
	    error: function(response, ioArgs){
	      dojo.byId("calendar_entry").innerHTML = 
	        " " + response;
	      dojo.byId("calendar_entry").style.display="block";
	      
	      return response;
	    },
	    handleAs: "text"
	  });
	}


function searchCity(language,month, year)
{
	var keyword=document.getElementById('searchfield').value;
	dojo.xhrGet({
	    url: "sun_moon_calendar_city_search.jsp?keyword="+keyword+"&language="+language+"&month="+month+"&year="+year,
	    load: function(response, ioArgs){
	      dojo.byId("popUpDiv").innerHTML = response;
	      popup("popUpDiv");
	      //setDateValue('fromDate',year,month,date);
	      //setDateValue('toDate',year,month,date);
	      //Dojo recommends that you always return(response); to propagate 
	      //the response to other callback handlers. Otherwise, the error 
	      //callbacks may be called in the success case.
	      return response;
	    },
	    error: function(response, ioArgs){
	      dojo.byId("popup_div").innerHTML = 
	        " " + response;
	    //  dojo.byId("calendar_entry").style.display="block";
	      
	      return response;
	    },
	    handleAs: "text"
	  });
	}

function sunMoonDetail(language,year,month,day,city)
{
	dojo.xhrGet({
	    url: "sun_moon_calendar_detail.jsp?language="+language+"&year="+year+"&month="+month+"&day="+day+"&city_id="+city,
	    load: function(response, ioArgs){
	      dojo.byId("calendar_entry").innerHTML = response;
	      dojo.byId("calendar_entry").style.display="block";
	      //setDateValue('fromDate',year,month,date);
	      //setDateValue('toDate',year,month,date);
	      //Dojo recommends that you always return(response); to propagate 
	      //the response to other callback handlers. Otherwise, the error 
	      //callbacks may be called in the success case.
	      return response;
	    },
	    error: function(response, ioArgs){
	      dojo.byId("entryView").innerHTML = 
	        " " + response;
	    //  dojo.byId("calendar_entry").style.display="block";
	      
	      return response;
	    },
	    handleAs: "text"
	  });
	}

function newCategory(language)
{
	dojo.xhrGet({
	    url: "photocategory_new.jsp?language="+language,
	    load: function(response, ioArgs){
			
	      dojo.byId("gallery_entry").innerHTML = response;
	      
	      dojo.byId("gallery_entry").style.display="block";
	      return response;
	    },
	    error: function(response, ioArgs){
	      dojo.byId("gallery").innerHTML = 
	        " " + response;
	      
	      return response;
	    },
	    handleAs: "text"
	  });
	}

function invite_offline(language)
{
	dojo.xhrGet({
	    url: "contacts_offline.jsp?language="+language,
	    load: function(response, ioArgs){
			
	      dojo.byId("contacts_entry").innerHTML = response;
	      
	      dojo.byId("contacts_entry").style.display="block";
	      return response;
	    },
	    error: function(response, ioArgs){
	      dojo.byId("contacts_entry").innerHTML = 
	        " " + response;
	      
	      return response;
	    },
	    handleAs: "text"
	  });
	}

function editCategory(language,id)
{
	dojo.xhrGet({
	    url: "photocategory_edit.jsp?language="+language+"&id="+id,
	    load: function(response, ioArgs){
			
	      dojo.byId("gallery_entry").innerHTML = response;
	      
	      dojo.byId("gallery_entry").style.display="block";
	      return response;
	    },
	    error: function(response, ioArgs){
	      dojo.byId("gallery").innerHTML = 
	        " " + response;
	      
	      return response;
	    },
	    handleAs: "text"
	  });
	}

var lastFormRun=0;

function loadForm(div_id,theurl)
{
	div_id='popUpDiv';
	var dt=new Date();
	if(dt.getTime()<lastFormRun+2000) return;
	lastFormRun=dt.getTime();
	
	dojo.xhrGet({
	    url: theurl,
	    load: function(response, ioArgs){
	      dojo.byId(div_id).innerHTML = response;
	      popup(div_id);
	      return response;
	    },
	    error: function(response, ioArgs){
	      dojo.byId(div_id).innerHTML = 
	        " " + response;
	      
	      return response;
	    },
	    handleAs: "text"
	  });
	}

function replaceForm(div_id,theurl)
{
	div_id='popUpDiv';
	var dt=new Date();
	if(dt.getTime()<lastFormRun+2000) return;
	lastFormRun=dt.getTime();
	
	dojo.xhrGet({
	    url: theurl,
	    load: function(response, ioArgs){
	      dojo.byId(div_id).innerHTML = response;
	      return response;
	    },
	    error: function(response, ioArgs){
	      dojo.byId(div_id).innerHTML = 
	        " " + response;
	      
	      return response;
	    },
	    handleAs: "text"
	  });
	}


function loadGroupCalendarForm(div_id,theurl)
{
	dojo.xhrGet({
	    url: theurl,
	    load: function(response, ioArgs){
	      dojo.byId(div_id).innerHTML = response;
	      dojo.byId(div_id).style.display="block";
	      showCols();
	      return response;
	    },
	    error: function(response, ioArgs){
	      dojo.byId(div_id).innerHTML = 
	        " " + response;
	      
	      return response;
	    },
	    handleAs: "text"
	  });
	}


function changeaccessid(pre)
{
	var dropdownIndex = document.getElementById(pre+'noid').selectedIndex;
	var option=document.getElementById(pre+'noid').options[dropdownIndex];
	var length=document.getElementById(pre+'id').options.length;
	var optionnew=new Option(option.text,option.value,false,false);
	document.getElementById(pre+'id').options[length]=optionnew;	
	var option=document.getElementById(pre+'noid').options[dropdownIndex]=null;
	
	var optionsArray=document.getElementById(pre+'id');
	
	var values="";
	for(var i=0;i<optionsArray.length;i++)
	{
		if(i>0) values=values+";";
		values=values+optionsArray[i].value;
		
	}
	document.getElementById(pre+'ids').value=values;
	
	
	
}

function changeaccessnoid(pre)
{
	var dropdownIndex = document.getElementById(pre+'id').selectedIndex;
	var option=document.getElementById(pre+'id').options[dropdownIndex];
	var length=document.getElementById(pre+'noid').options.length;
	var optionnew=new Option(option.text,option.value,false,false);
	document.getElementById(pre+'noid').options[length]=optionnew;	
	var option=document.getElementById(pre+'id').options[dropdownIndex]=null;

	var optionsArray=document.getElementById(pre+'id');				
	var values="";
	for(var i=0;i<optionsArray.length;i++)
	{
		if(i>0) values=values+";";
		values=values+optionsArray[i].value;
		
	}
	document.getElementById(pre+'ids').value=values;
	
}

function access_display(pre)
{
	if(document.getElementById(pre+'updated')!=null)
	{
		document.getElementById(pre+'updated').value="true";
	}
	
	var dropdownIndex = document.getElementById(pre+'access').selectedIndex;
	var value=document.getElementById(pre+'access')[dropdownIndex].value;
	if(value==3){
		document.getElementById(pre+"contacts").style.display="block";
		
		
	}
	else
	{
		document.getElementById(pre+"contacts").style.display="none";
	}

}

function displayUs()
{
	var dropdownIndex = document.getElementById('country_id').selectedIndex;
	var dropdownValue = document.getElementById('country_id')[dropdownIndex].value;	
	
	if(dropdownValue=='229')
	{
		document.getElementById("statediv").style.display='block';
	}
	else
	{
		document.getElementById("statediv").style.display='none';
	}
	
}

function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}

function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
	viewportheight = window.innerHeight;
	} else {
	viewportheight = document.documentElement.clientHeight;
	}

	if(document.body.scrollTop > 0){
	// For IE 5.5
	bdy_ref = document.body;
	}else{
	bdy_ref = document.body.parentNode;
	}

	if ((viewportheight > bdy_ref.scrollHeight) && (viewportheight > bdy_ref.clientHeight)) {
	blanket_height = viewportheight;
	} else {
	if (bdy_ref.clientHeight > bdy_ref.scrollHeight) {
	blanket_height = bdy_ref.clientHeight;
	} else {
	blanket_height = bdy_ref.scrollHeight;
	}
	}
	var blanket = document.getElementById('popup_div');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height = screen.availHeight/2-350;//350 is the popup’s height
	popUpDiv.style.top = (popUpDiv_height + bdy_ref.scrollTop) + 'px';
	//alert(popUpDiv.style.top);
	}


function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-300;//300 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	//alert('here');
	blanket_size(windowname);
	window_pos(windowname);
	toggle('popup_div');
	toggle(windowname);		
}

function closePopup()
{
	document.getElementById('popup_div').style.display='none';
	document.getElementById('popUpDiv').style.display='none';
}

function showHide(idShow, idHide)
{
	document.getElementById(idShow).style.display='block';
	document.getElementById(idHide).style.display='none';
	
}

function displayPasswordOrNot(pre)
{
	var dropdownIndex = document.getElementById(pre+'type').selectedIndex;
	var value=document.getElementById(pre+'type')[dropdownIndex].value;
	if(value=='password'){
		
		document.getElementById(pre+'passworddiv').style.display='block';
		
	}
	else
	{
		document.getElementById(pre+'passworddiv').style.display='none';
	}
}


