var NAVIGATION = new Array("CURR", "PREV", "NEXT", "REFRESH");
var days = new Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat","Sun");
var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var months_MMM =['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var delay = "500";
var hasFreeSchedules = false;
var isDragging = false;
var calStartDate = null;
var calEndDate = null;
var appRequest = null;
var appStartDate = null;
var appEndDate = null;
var contactId = null;
var verify = null;
var freeTime ;
var arColor = "#9F6A46";//Appointment request selection
var fsColor = "#CC9966";//Free schedule
var parColor = "#D5A401";//Pending appointment request
var aarColor = "#84A901";//Accepted appointment request
var rarColor = "#AAAAAA";//Rejected apointment request
var cal_name = "0000-00-00";
var fsColor1="#FCFDDD"; //free schdule color weekdays
var fsColor2="#D7D7D7";	//free schdule color weekends Sat and Sun
var f_name=null;
var l_name=null;
var email_id=null;
var type=null;
var timecode_value=null;
var phone_number = null;
function showNotice()
{
	//document.getElementById('notice').style.display="block";
	if (msgTimer)
		{
			clearTimeout(msgTimer);
		}
	$('notice').style.display = "none";
	Effect.Appear("notice");
	msgTimer = setTimeout('Effect.Fade("notice")',10000);
	Element.hide('busy');

}
function iPolipoAnonyOL(){
	addLoadEvent(function(){
	//	setCalProfileLink(showMyProfile);
	//var t_zoneinfo = country_list()
              // alert(t_zoneinfo);
          //time_len = t_zoneinfo.split("$");
              // alert(time_len[0]);
              // alert(time_len[1]);
	 daylight_savings();
		//var gid=document.getElementById('check').value;
		//new Ajax.Request('/anotimezone', {method:'post', postBody:'tZone='+time_len[0]+'&tCode='+time_len[1]+'&f_name='+a_user_name+'&l_name='+l_user_name+'&gid='+gid,asynchronous:true,evalScripts:true,onComplete:function(request){change_zone(gid);anotimezone(request,contactId)}});
		
		
	});
}
iPolipoAnonyOL();

function anotimezone(request,cid)
{
//alert(request.responseText);
xmlDoc = getXMLDocumentObject(request);
var timezone = xmlDoc.getElementsByTagName('timezone');
var timezonecode = xmlDoc.getElementsByTagName('timezonecode');
var timecodeval = xmlDoc.getElementsByTagName('timecodeval');
var fir_name = xmlDoc.getElementsByTagName('first_name');

var email_insert = xmlDoc.getElementsByTagName('email_id');

var type_id = xmlDoc.getElementsByTagName('type');
var p_number = xmlDoc.getElementsByTagName('phone_number');

phone_number=p_number[0].childNodes[0].nodeValue;
 if (phone_number == "null")
	{
	
	 phone_number =""
	}
 else
	{
	 phone_number = phone_number
	}

email_id=email_insert[0].childNodes[0].nodeValue;
//alert(email_id);
type = type_id[0].childNodes[0].nodeValue;

//alert(type);
var timezone_value=timezone[0].childNodes[0].nodeValue;
var timezonecode_value=timezonecode[0].childNodes[0].nodeValue;
timecode_value=timecodeval[0].childNodes[0].nodeValue;
f_name=fir_name[0].childNodes[0].nodeValue;
setWeeklyView(NAVIGATION[0],timezone_value,timezonecode_value);
drawCalendarView();
getContactCal(timezone_value,timezonecode_value,timecode_value);
disableSelect();	
}

function getXMLDocumentObject(request){
	if(window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XmlDom");
		xmlDoc.async=false;
		xmlDoc.load(request.responseXML);
	}	
	else
	{
		xmlDoc = request.responseXML;	
	}
	return xmlDoc;
}

//function removeAllChild(node){
	//while (node.hasChildNodes())
	//{
	//	node.removeChild(node.firstChild);
	//}
//}


function getTimeCells(startTime, endTime){
	timeCells = new Array();
	startTimeArr = startTime.split(" ");
	endTimeArr = endTime.split(" ");
	day = startTimeArr[0];
	h1 = parseInt(startTimeArr[1], 10);
	h2 = parseInt(endTimeArr[1], 10);
	m1 = parseInt(startTimeArr[2], 10);
	m2 = parseInt(endTimeArr[2], 10);
	
	stcId = day + h1 + ((m1 < 30)? "h1" : "h2");
	timeCells.push(stcId);
	if(m2 > 0)
	{
		etcId = day + h2 + ((m2 <= 30)? "h1" : "h2");
		if(stcId != etcId)
		{
			timeCells.push(etcId);
		}	
	}

	if(h1 < h2)
	{
		if(m1 < 30)
		{
			timeCells.push(day + h1 + "h2");
		}
		if(m2 > 30)
		{
			timeCells.push(day + h2 + "h1");
		}	
		start = h1 + 1;
		end = h2 - 1;
		for(tc = start; tc <= end; tc++)
		{
			cellId1 = day + tc + "h1";
			timeCells.push(cellId1);
			cellId2 = day + tc + "h2";
			timeCells.push(cellId2);		
		}			
	}	

	return timeCells;
}
function getContactCal(timevalue,timezonevalue,timecodeval){
	//contactId = cId;
	//alert(timezonevalue);
	verify = 1;
	startDate = new Date(timevalue);
	//startDate.setDate(startDate.getDate()+1 - startDate.getDay());
	if (startDate.getDay() == 0)
		{
		startDate.setDate(startDate.getDate()+1 - 7);
		}
		else
		{
		startDate.setDate(startDate.getDate()+1 - startDate.getDay());
		}
	sdQP = startDate.getFullYear() + "-" + months_MMM[startDate.getMonth()] + "-" + startDate.getDate();
	var val = 1;
	var guid_inv = $('new_val').value;

	new Ajax.Request("/showPublicCal", {method:'post', postBody:'sdate='+sdQP+'&val='+val+'&guid='+guid_inv+'&timecode='+timecodeval, asynchronous:true, evalScripts:true,onLoading:function(){showBusy();}, onComplete:function(request){showContactCalResponse(request, NAVIGATION[0],timevalue,timezonevalue);hideBusy();} });	
}

function refreshContactCal(){
	var val = 1;
	sdQP = calStartDate.getFullYear() + "-" + months_MMM[calStartDate.getMonth()] + "-" + calStartDate.getDate();	
	var guid_inv = $('new_val').value;
	email_id = $('email_insert').value ;
	f_name = $('name_insert').value;
	phone_number = $('phone').value;
	new Ajax.Request("/showPublicCal", {method:'post', postBody:'sdate='+sdQP+'&val='+val+'&guid='+guid_inv+'&email_id='+email_id+'&timecode='+timecode_value+'&name='+f_name+'&timezone='+time_len[0], asynchronous:true, evalScripts:true, onComplete:function(request){showContactCalResponse(request, NAVIGATION[3],calStartDate,tCode)} });	
}

function showContactCalResponse(request, navType,timevalue,timezonevalue){
//alert(request.responseText);	
	if(check_selected == 2)
	{
		email_id="";
		f_name="";
		phone_number="";
	}
	if(navType == "PREV")
	{
	$('busy1').style.display="none";
	//Element.Fade('busy1');
	//alert(request.responseText);
	}
	
	if(navType == "NEXT")
	{
	$('busy1').style.display="none";
	//Element.Fade('busy1');
	
	}
	//alert(request.responseText);
	xmlDoc = getXMLDocumentObject(request);	
	$('message').style.display = "none";
	var errorMsg = xmlDoc.getElementsByTagName('errorMsg');	
	
	if( errorMsg.length > 0) {
		//Display the error message
		//$('app_load').style.display = "none";
		$('message').style.display = "block";
		Effect.Appear("message");
		$('message').innerHTML = errorMsg[0].childNodes[0].nodeValue;
		msgTimer = setTimeout('Effect.Fade("message")',10000);
		//showNotice();
	}
	else
	{
		setWeeklyView(navType,timevalue,timezonevalue);
		drawCalendarView();
		setCalNavLinks(contactCalPrevWeek, contactCalNextWeek);
	
		//setCalProfileLink(showMyProfile);
		
		//Display the contact's name in the calendar
		//usrName = xmlDoc.getElementsByTagName('contact')[0].getElementsByTagName('userName');
		//$('calusr').innerHTML = usrName[0].childNodes[0].nodeValue + "'s Calendar";
		//Display contact free schedules		
		displayContactFreeSchedules(xmlDoc);
		//Display appointment requests to contact 
		displayContactAppRequests(xmlDoc);
	}
}
function displayContactAppRequests(xmlDoc){
	//alert("app reuest");
	appRequests = xmlDoc.getElementsByTagName('appointmentRequests')[0].getElementsByTagName('appointmentRequest');
	for(m = 0; m < appRequests.length; m++)
	{
		startTime = appRequests[m].getElementsByTagName('startTime');
		startTime = startTime[0].childNodes[0].nodeValue;
		endTime = appRequests[m].getElementsByTagName('endTime');
		endTime = endTime[0].childNodes[0].nodeValue;
		pending = appRequests[m].getElementsByTagName('pending');
		pending = pending[0].childNodes[0].nodeValue;	
		accepted = appRequests[m].getElementsByTagName('accepted');
		accepted = accepted[0].childNodes[0].nodeValue;
		timeCells = getTimeCells(startTime, endTime);
		
		if(pending.toUpperCase() == "Y"){
			arsColor = parColor;
		}
		else if(accepted.toUpperCase() == "Y"){
			arsColor = aarColor;
		}
		else //To display rejected appointment requests
		{	
			//arsColor = fsColor;
			arsColor="#FCFDDD";
			
		}
			
		for(j = 0; j < timeCells.length; j++)
		{	//Set the free cell background based on day
			//if(timeCells[j].substring(0,3) == "Sat" || timeCells[j].substring(0,3) == "Sun")
			//{
			//	arsColor = "#D7D7D7";	
			//}
			//else
			//{
			//	arsColor = "#FCFDDD";	
			//}
			$(timeCells[j]).style.backgroundColor = arsColor;
			$(timeCells[j]).align="middle";
			$(timeCells[j]).className="freecellstyle";
			if(arsColor == parColor)   //pending stage
			{
			$(timeCells[j]).innerHTML = "Pending";
			}
			else if(arsColor == aarColor)   //Accepted stage
			{
			$(timeCells[j]).innerHTML = "Accepted";
			}
			else
			{$(timeCells[j]).innerHTML = "Available";
			}
		}
	}
}

function displayContactFreeSchedules(xmlDoc){
	//alert("ContactFreeSchedules");
	freeSchedules = xmlDoc.getElementsByTagName('freeSchedules')[0].getElementsByTagName('freeSchedule');
	
	
	//alert(caption);
	//alert(tooltip);
	hasFreeSchedules = (freeSchedules.length > 0) ? true : false;
	for(m = 0; m < freeSchedules.length; m++)
	{
		
		startTime = freeSchedules[m].getElementsByTagName('startTime');
		startTime = startTime[0].childNodes[0].nodeValue;
		endTime = freeSchedules[m].getElementsByTagName('endTime');
		endTime = endTime[0].childNodes[0].nodeValue;
		var caption =freeSchedules[m].getElementsByTagName('caption');
		var tooltip = freeSchedules[m].getElementsByTagName('tooltip');
		caption = caption[0].childNodes[0].nodeValue;
		tooltip = tooltip[0].childNodes[0].nodeValue;
		timeCells = getTimeCells(startTime, endTime);
		
		for(j = 0; j < timeCells.length; j++)
		{	//$(timeCells[j]).style.backgroundColor = fsColor;
			//if(timeCells[j].substring(0,3) == "Sat" || timeCells[j].substring(0,3) == "Sun")
			//{
			//	$(timeCells[j]).style.backgroundColor = "#D7D7D7";
				
			//}
			//else
			//{
			//	$(timeCells[j]).style.backgroundColor = "#FCFDDD";
				
			//}
			$(timeCells[j]).style.backgroundColor = "#FCFDDD";
			$(timeCells[j]).className="freecellstyle";
			$(timeCells[j]).align="middle";
            
            /*This block is to convert the quotes into their corresponding HTML entries*/
                new_quote = tooltip.split('&quot;');
                var modified_string = "";
                for(i=0;i<new_quote.length;i++)
                {
                    modified_string += new_quote[i]+"\"";
                }
                
                str_length = modified_string.length;
                modified_string = modified_string.substring(0,str_length-1);
            /*Till Here ...*/
	           
			$(timeCells[j]).title = modified_string;
			$(timeCells[j]).innerHTML = caption;
		}
	}	
}

function contactCalNextWeek(){
	
	startDate = new Date(calStartDate.getTime());
	startDate.setDate(startDate.getDate() + 7);
	sdQP = startDate.getFullYear() + "-" + months_MMM[startDate.getMonth()] + "-" + startDate.getDate();
	var val =1;
	var guid_inv = $('new_val').value;

	new Ajax.Request("/showPublicCal", {method:'post', postBody:'sdate='+sdQP+'&val='+val+'&guid='+guid_inv+'&email_id='+email_id+'&timecode='+timecode_value+'&name='+f_name+'&timezone='+time_len[0], asynchronous:true, evalScripts:true,onLoading:function(){replace_navigation_arrow('calnwk','disabled_calnwk');showBusy1();}, onComplete:function(request){replace_navigation_arrow('disabled_calnwk','calnwk');showContactCalResponse(request, NAVIGATION[2],calStartDate,tCode);} });	
}

function contactCalPrevWeek(){
	
	startDate = new Date(calStartDate.getTime());
	startDate.setDate(startDate.getDate() - 7);
	sdQP = startDate.getFullYear() + "-" + months_MMM[startDate.getMonth()] + "-" + startDate.getDate();	
	var val = 1;
	var guid_inv = $('new_val').value;

	new Ajax.Request("/showPublicCal", {method:'post', postBody:'sdate='+sdQP+'&val='+val+'&guid='+guid_inv+'&email_id='+email_id+'&timecode='+timecode_value+'&name='+f_name+'&timezone='+time_len[0], asynchronous:true, evalScripts:true,onLoading:function(){replace_navigation_arrow('calpwk','disabled_calpwk');showBusy1();}, onComplete:function(request){replace_navigation_arrow('disabled_calpwk','calpwk');showContactCalResponse(request, NAVIGATION[1],calStartDate,tCode);} });	
//	new Ajax.Request("/showContactCal", {method:'post', postBody:'sdate='+sdQP+'&cId='+contactId+'&val='+val, asynchronous:true, evalScripts:true,onLoading:function(){replace_navigation_arrow('calpwk','disabled_calpwk');showload();}, onComplete:function(request){replace_navigation_arrow('disabled_calpwk','calpwk');contactCalPrevWeek_check(request);hideload();} });	
}

	function showBusy1() { 
		//Element.show('busy');
		$('message').style.display="none";
		$('busy2').style.display="none";
		$('busy1').style.display="block";
		Element.Appear('busy1');
	}
	
	function hideBusy1() { 
		//Element.hide('busy');
		$('busy1').style.display="none";
		//Element.Fade('busy1');
	}	

/*
*   This function allows to disable and enable the navigation buttons of the calendar when loading.
*/
function replace_navigation_arrow(to_be_replaced_id,replacing_id)
{
    $(to_be_replaced_id).style.display="none";
    $(replacing_id).style.display="inline";
}



function myCalNextWeek(){
	startDate = new Date(calStartDate.getTime());
	startDate.setDate(startDate.getDate() + 7);
	sdQP = startDate.getFullYear() + "-" + months_MMM[startDate.getMonth()] + "-" + startDate.getDate();
	new Ajax.Request('/freeTime', {method:'post', postBody:'start='+sdQP, asynchronous:true, evalScripts:true,onLoading:function(){showBusy();}, onComplete:function(request){freeTimesResponse(request, NAVIGATION[2],calStartDate,tCode);hideBusy();}});
}

function myCalPrevWeek(){
	
	startDate = new Date(calStartDate.getTime());
	startDate.setDate(startDate.getDate() - 7);
	sdQP = startDate.getFullYear() + "-" + months_MMM[startDate.getMonth()] + "-" + startDate.getDate();	
	new Ajax.Request('/freeTime', {method:'post', postBody:'start='+sdQP, asynchronous:true, evalScripts:true,onLoading:function(){showBusy();}, onComplete:function(request){freeTimesResponse(request, NAVIGATION[1],calStartDate,tCode);hideBusy();}});
}

function displayFreeTimes(timezone,timezonecode)
{
	startDate = new Date(timezone);
	tmzoneCode = timezonecode;
	//startDate.setDate(startDate.getDate() - startDate.getDay());
	if (startDate.getDay() == 0)
		{
		startDate.setDate(startDate.getDate()+1 - 7);
		}
		else
		{
		startDate.setDate(startDate.getDate()+1 - startDate.getDay());
		}
	sdQP = startDate.getFullYear() + "-" + months_MMM[startDate.getMonth()] + "-" + startDate.getDate();
	new Ajax.Request('/freeTime', {method:'post', postBody:'start='+sdQP, asynchronous:true, evalScripts:true, onComplete:function(request){freeTimesResponse(request, NAVIGATION[0],timezone);}});
}


function freeTimesResponse(request, navType,timezone)
{	
	xmlDoc = getXMLDocumentObject(request);
	var errorMsg = xmlDoc.getElementsByTagName('errorMsg');	
	if( errorMsg.length > 0) {
		//Display the error message
		$('message').innerHTML = errorMsg[0].childNodes[0].nodeValue;
		showNotice();
	}
	else
	{
		
		setWeeklyView(navType,timezone,tmzoneCode);
		drawCalendarView();
		//Read from the XML file 
		freeTimes = xmlDoc.getElementsByTagName('free_time');
		for(i=0;i<freeTimes.length;i++)
		{
			ids = freeTimes[i].getElementsByTagName('id');
			id = ids[0].childNodes[0].nodeValue;
			
			startTimes = freeTimes[i].getElementsByTagName('start_time');
			startTime = startTimes[0].childNodes[0].nodeValue;
			endTimes = freeTimes[i].getElementsByTagName('end_time');
			endTime = endTimes[0].childNodes[0].nodeValue;
			timeCells = getTimeCells(startTime, endTime);
			
			
			freeTimeGroups = freeTimes[i].getElementsByTagName('group');
			for(k = 0; k < timeCells.length; k++)
			{
				content = '';	
				content+="<table id='ftfgroups' cellspacing='0' align='middle' border='0' onMouseOver='free_groups(this,event);' onMouseOut='close_groups();' class='cal'><tr>";
				
				for(j = 0;j < freeTimeGroups.length; j++)
				{	
					colorCode = freeTimeGroups[j].getElementsByTagName('color_code')[0].childNodes[0].nodeValue;						
					markMultipleGroups(timeCells[k],freeTimeGroups.length,j);
				}	
				content+="</tr></table>";	
				//alert(content);
				
				if (freeTimeGroups.length > 0)
				{   
					cal_name = $(timeCells[k]).name;
					//$(timeCells[k]).onmouseover = setTimeout(function(evt){$('free_times_for_groups').innerHTML="";return freeTimesGroupPopup(evt);},1000);
					//$(timeCells[k]).onmouseout = close_groups();
				}
			}
			//alert($("ftfgroups").offsetHeight);
			//alert($("ftfgroups").offsetWidth);
			//alert($("dot_id").offsetHeight);
		}
	}
}


function markMultipleGroups(start, end,j)
{	if(j<3)
	{content+="<td  align='middle'>";
	content+="<table border='1' id='testing'cellspacing='0' align='middle' bordercolor='black' bgcolor="+colorCode+"><tr><td></td></tr></table></td>";
	$(start).align="center";
	}	
	//$(start).onmouseover = function(){displayMultipleGroups(event)}
	if (end > 3)
	{   if(j==2)
		{ content+="<td align='middle'><table cellspacing='0' cellpadding='0' align='middle' border='0' id='morethan3' ><tr><td id='dot_id' height='16' align='middle'>..</td></tr></table></td>"
		}
	}
	$(start).innerHTML = content;
}

function redirect_zone(time_zone,gid)
{

$('cscrd').focus();
var time_zone=document.getElementById('time_zone').value;
var gid=document.getElementById('check').value;

time_len=time_zone.split('$');
code=time_len[1];
zone_info=time_len[0];
//new Ajax.Request("invitation/show_inviter_calendar", {method:'post', postBody:'time_zone='+time_zone,asynchronous:true,evalScripts:true,onComplete:function(request){}});
//new Ajax.Updater('restricted', '/restricted_timezone/restricted_calendar?gid='+gid+'&time_zone='+time_zone, {asynchronous:true, evalScripts:true,onComplete:function(request){new Ajax.Request('/anotimezone', {method:'post', postBody:'tZone='+zone+'&tCode='+code+'&f_name='+a_user_name+'&l_name='+l_user_name,asynchronous:true,evalScripts:true,onComplete:function(request){anotimezone(request,contactId)}});}});return false;
new Ajax.Request('/publictimezone', {method:'post', postBody:'tZone='+zone_info+'&tCode='+code+'&gid='+gid,asynchronous:true,evalScripts:true,onComplete:function(request){anotimezone(request,contactId)}});
//change_zone(gid);

}
function change_zone(gid,time_zone_val)
{
//alert("higid");
new Ajax.Updater('zone', '/anony_invite/get_time_zone?gid='+gid+'&tcode='+time_zone_val, {asynchronous:true, evalScripts:true,onComplete:function(request){}});return false;
}
function daylight_savings()
{

new Ajax.Request('/daylight_savings', {method:'post',asynchronous:true,evalScripts:true,onComplete:function(request){daylight_result(request);}});	

}
function daylight_result(req)
{
	
	xmlDoc = getXMLDocumentObject(req);
	
	var daylight = xmlDoc.getElementsByTagName('daylight');
	var daylight_value=daylight[0].childNodes[0].nodeValue;
	
	t_zoneinfo = country_list(daylight_value);
 	time_len = t_zoneinfo.split("$");
               //alert(time_len[0]);
               //alert(time_len[1]);
	
		var gid=document.getElementById('check').value;
		//alert(gid);
		new Ajax.Request('/publictimezone', {method:'post', postBody:'tZone='+time_len[0]+'&tCode='+time_len[1]+'&gid='+gid,asynchronous:true,evalScripts:true,onComplete:function(request){change_zone(gid,time_len[0]);anotimezone(request,contactId)}});
		
}
function country_list(daylight_value)
{
var time = new Date();
timezoneoffset = time.getTimezoneOffset();
//alert(timezoneoffset);
//alert(daylight_value);
if (timezoneoffset == '720')
{
return "Etc/GMT+12$IDLE"
}
else if (timezoneoffset == '660')
{
return "Pacific/Midway$SST"
}
else if (timezoneoffset == '600')
{
return "US/Hawaii$HST"
}
else if ((timezoneoffset == '540') && (daylight_value == '0'))
{
return "US/Alaska$AKST"
}
else if ((timezoneoffset == '480') && (daylight_value == '0'))
{
return "America/Los_Angeles$PST"
}
else if ((timezoneoffset == '420') && (daylight_value == '0'))
{
return "US/Arizona$MST"
}
else if ((timezoneoffset == '360') && (daylight_value == '0'))
{
return "America/Chicago$CST"
}
else if ((timezoneoffset == '300') && (daylight_value == '0'))
{
return "America/New_York$EST"
}
else if ((timezoneoffset == '240') && (daylight_value == '0'))
{
return "Canada/Atlantic$AST"
}
else if ((timezoneoffset == '210') && (daylight_value == '0'))
{
return "Canada/Newfoundland$NST"
}
else if ((timezoneoffset == '180') && (daylight_value == '0'))
{
return "America/Buenos_Aires$ART"
}
else if ((timezoneoffset == '480') && (daylight_value == '1'))
{
return "US/Alaska$AKST"
}
else if ((timezoneoffset == '420') && (daylight_value == '1'))
{
	timeArr = time.toString().split(" ");
    if (timeArr[4] == "MST")
	{
		return "US/Arizona$MST"
	}

	else
	{
		return "America/Los_Angeles$PST"
	}	

}
else if ((timezoneoffset == '360') && (daylight_value == '1'))
{
return "America/Denver$MST"
}
else if ((timezoneoffset == '300') && (daylight_value == '1'))
{
return "America/Chicago$CST"
}
else if ((timezoneoffset == '240') && (daylight_value == '1'))
{

return "America/New_York$EST"
}
else if ((timezoneoffset == '180') && (daylight_value == '1'))
{
return "Canada/Atlantic$AST"
}
else if ((timezoneoffset == '150') && (daylight_value == '1'))
{
return "Canada/Newfoundland$NST"
}
else if (timezoneoffset == '120')
{
return "Etc/GMT+2$AST"
}
else if (timezoneoffset == '60')
{
if (daylight_value == '0')
{
	return "Atlantic/Azores$AT"
}
else
{
	return "Etc/GMT+2$AST"
}
}
else if (timezoneoffset == '0')
{
if (daylight_value == '0')
{
	return "Europe/London$GMT"
}
else
{
	return "Atlantic/Azores$AT"
}
}
else if (timezoneoffset == '-60')
{
if (daylight_value == '0')
{
	return "Europe/Rome$EMT"
}
else
{
	return "Europe/London$GMT"
}
}
else if (timezoneoffset == '-120')
{
if (daylight_value == '0')
{
	return "Europe/Athens$FST"
}
else
{
	return "Europe/Rome$EMT"
}
}
else if (timezoneoffset == '-180')
{
timeArr = time.toString().split(" ");
	
if (daylight_value == '0')
{
	return "Asia/Baghdad$BAT"
}
else
{
	if (timeArr[4] == "UTC+0300")
	{
		return "Asia/Baghdad$BAT"
	}

	else
	{
		return "Europe/Athens$FST"
	}		
}
}
else if (timezoneoffset == '-210')
{
return "Asia/Tehran$IT"
}
else if (timezoneoffset == '-240')
{
return "Asia/Muscat$GST"
}
else if (timezoneoffset == '-270')
{
return "Asia/Kabul$AFT"
}
else if (timezoneoffset == '-300')
{
return "Asia/Karachi$PST"
}
else if (timezoneoffset == '-330')
{
return "Asia/Calcutta$IST"
}
else if (timezoneoffset == '-345')
{
return "Asia/Calcutta$IST"
}
else if (timezoneoffset == '-360')
{
return "Asia/Almaty$NOVT"
}
else if (timezoneoffset == '-390')
{
return "Asia/Rangoon$MMT"
}
else if (timezoneoffset == '-420')
{
return "Asia/Jakarta$GAVT"
}
else if (timezoneoffset == '-480')
{
return "Asia/Hong_Kong$CST"
}
else if (timezoneoffset == '-540')
{
return "Asia/Tokyo$JST"
}
else if (timezoneoffset == '-570')
{
return "Australia/Adelaide$ACST"
}
else if (timezoneoffset == '-630')
{
return "Australia/Adelaide$ACST"
}
else if (timezoneoffset == '-600')
{
return "Australia/Brisbane$LIGT"
}
else if (timezoneoffset == '-660')
{
return "Etc/GMT-11$MAGT"
}
else if (timezoneoffset == '-780')
{
return "Pacific/Auckland$NZST"
}
}


