var jsDOM0 = (document.all);
var jsDOM1 = (document.getElementById);
var jsDOM = jsDOM0 || jsDOM1;
var jsDebug = 0;

function getObj (name) {
    if (typeof name == "object") return name;
    if (jsDOM1) return document.getElementById(name);
    if (jsDOM0) return eval('document.all.'+name);
    else return null;
}

function KontrolaNewUser() 
{ 
    if (window.RegExp) 
    { 
		//oNewNazov = getObj ('new_nazov');
		oNewUsername_a = getObj ('new_username_a');
		//alert(oNewUsername_a);
		oNewUsername_b = getObj ('new_username_b');
		//oNewPass_a = getObj ('new_password_a');
		//oNewPass_b = getObj ('new_password_b');
		oNewEmail = getObj ('new_email');
		
		//znaky_1 = new RegExp('^[^\\\^\$\[\|\(\)\?\*\+\{\}&#!~]{1,30}$'); //nazov
		znaky_2 = new RegExp('^[0-9a-zA-Z?]{6,20}$');		//username a heslo
		//znaky_2 = new RegExp('^[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ??????????????????????????????????????????????????????????????????\-_]{6,20}$');		//username a heslo
        znaky_3 = new RegExp('^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$'); //email
		
		
		/*if (!znaky_1.test(oNewNazov.value))   // zapni aj v user_preferences_save.php!!!
		{
            window.alert("Názov má nevyhovujúcu dĺžku, alebo obsahuje nedovolené znaky."); 
            oNewNazov.focus(); 
            return false;
		}
		else if (!znaky_2.test(oNewPass_a.value))
		{
		 	window.alert("Heslo má nevyhovujúcu dĺžku, alebo obsahuje nedovolené znaky."); 
            oNewPass_a.focus(); 
            return false;
		}
		else if (oNewPass_a.value != oNewPass_b.value)
		{
		 	window.alert("Kontrolne heslo nezodpoveda zadanemu heslu."); 
            oNewPass_b.focus(); 
            return false;
		}
		else */
		if (!znaky_2.test(oNewUsername_a.value))
		{
		 	window.alert(lang[52]); // Prihlasovacie meno má nevyhovujúcu dĺžku, alebo obsahuje nedovolené znaky.
            oNewUsername_a.focus(); 
            return false;
		}
		else if (oNewUsername_a.value != oNewUsername_b.value)
		{
		 	window.alert(lang[53]); //Kontrolne prihlasovacie meno nezodpoveda zadanemu prihlasovaciemu menu.
            oNewUsername_b.focus(); 
            return false;
		}
		else if(!znaky_3.test(oNewEmail.value))
		{
			window.alert(lang[54]); //Neplatny format emailu!
	        oNewEmail.focus(); 
            return false;
		}	
		else
		{
			return true;
		}
    } 
}

function Kontrola() 
{  
    if (window.RegExp) 
    { 
		//alert('fry');
		oMeno = getObj ('meno');
		oHeslo_a = getObj ('heslo_a');
		oHeslo_b = getObj ('heslo_b');
		oEmail = getObj ('email');
		oNotifikacia = getObj ('notify');
		
		znaky_1 = new RegExp('^[^\\\^\$\[\|\(\)\?\*\+\{\}&!~]{0,30}$'); //login
		znaky_2 = new RegExp('^[0-9a-zA-Z]{6,20}$');		//heslo
        znaky_3 = new RegExp('^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$'); //email
		
		// pre duplicitu:
		duplicit = false;
		for(i=0; i<userCount; i++)
		{
			//nekontroluje same so sebou:
			if((i!=sysWhatTable)&&((oHeslo_a.value) == oPwd[i])) {duplicit = true; break;}
		}
		
		if (!znaky_1.test(oMeno.value))
		{
            window.alert(lang[86]); 
            oMeno.focus(); 
            return false;
		}
		else if ((0 == sysWhatTable)&&(!znaky_2.test(oHeslo_a.value))) //ak je to heslo admina
		{
		 	window.alert(lang[87]); 
            oHeslo_a.focus(); 
            return false;
		}
		else if(duplicit && (0==sysWhatTable)) //duplicitne heslo admina
		{
			window.alert(lang[92]);
	        oHeslo_a.focus(); 
            return false;
		}
		else if ((0 < sysWhatTable)&&(''!=oHeslo_a.value)&&(!znaky_2.test(oHeslo_a.value))) //ak je to neadmin
		{ 
            window.alert(lang[87]); 
            oHeslo_a.focus(); 
            return false; 
        } 
		else if(duplicit && (0!=sysWhatTable) && (''!=oHeslo_a.value)) //duplicitne heslo neadmina
		{
			window.alert(lang[92]);
	        oHeslo_a.focus(); 
            return false;
		}
        else if (oHeslo_a.value != oHeslo_b.value) 
        { 
            window.alert(lang[88]); 
            oHeslo_b.focus(); 
            return false; 
        }  
		else if((0 == sysWhatTable) && ('' == oEmail.value)) //nevyplneny email admin konta
		{
			window.alert(lang[89]);
	        oEmail.focus(); 
            return false;
		}	
		else if(('' != oEmail.value) && (!znaky_3.test(oEmail.value))) //zle vyplneny email
		{
			window.alert(lang[54]);
	        oEmail.focus(); 
            return false;
		}
		/*else if(('' == oEmail.value) && (oNotifikacia.checked)) //notifikacia bez mailu
		{
			window.alert(lang[118]);
	        oEmail.focus(); 
            return false;
		}
		*/else
		{
			return true;
		}
    } 
} 

function KontrolaTabNames() 
{
	//alert('TU');
	kontrola = true;
	for (i=0; i<projCount; i++)
	{
		oInput = getObj ('pTab_name_'+i);
		if (window.RegExp)
	    {
			znaky = new RegExp('^[^\\\^\$\[\|\(\)\?\*\+\{\}&!~]{0,30}$'); //nazov uloh, povoleny znak '#'
			//alert('oI-'+oInput.value);
			if (!znaky.test(oInput.value))
			{
				kontrola = false; 
	            oInput.focus();
	    		window.alert(lang[29]+" "+(i+1)+" "+lang[114]);
				break;
			}
	    } 
	}
	if(kontrola)
	{
		//window.alert('OK');
		return true;
	}
	else
	{
		//window.alert('NO');
		return false;
	}
}

function KontrolaPwd(name) 
{  
    if (window.RegExp) 
    { 
		oHeslo_2 = getObj (name+'2');
		oHeslo_3 = getObj (name+'3');
		//alert(oHeslo_2+oHeslo_3);
		
		znaky = new RegExp('^[0-9a-zA-Z]{6,20}$'); //heslo
		
		if (!znaky.test(oHeslo_2.value))
		{
		 	window.alert(lang[157]); 
            oHeslo_2.focus(); 
            return false;
		}
		else if(oHeslo_2.value != oHeslo_3.value) 
		{
			window.alert(lang[158]);
	        oHeslo_3.focus(); 
            return false;
		}
		else
		{
			return true;
		}
    } 
}

function KontrolaEmail(obj)
{
    if (window.RegExp)
    {
		oEmail = getObj (obj);
        znaky = new RegExp('^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$'); //email

		if(!znaky.test(oEmail.value))
		{
			window.alert(lang[54]); //Neplatny format emailu!
	        oEmail.focus();
            return false;
		}
		else
		{
			return true;
		}
    }
}

function KontrolaNewTask() 
{ 	
	oTerm = getObj ('termined_bool');	
	//alert(oTerm.checked);	
	
	oDfrom = getObj ('den_from');
	oMfrom = getObj ('mesiac_from');
	oYfrom = getObj ('rok_from');
	stamp_from = Date.UTC(oYfrom.value,oMfrom.value,oDfrom.value);
	oDto = getObj ('den_to');
	oMto = getObj ('mesiac_to');
	oYto = getObj ('rok_to');
	stamp_to = Date.UTC(oYto.value,oMto.value,oDto.value);
	stamp_now = Date.UTC(dnesR,dnesM,dnesD);	
	
	//alert(stamp_from - stamp_now);
	if ((stamp_from - stamp_now) < 0) //spatna platnost
	{
   		window.alert(lang[61]);
		return false;
	}
	if (((stamp_to - stamp_from) < 0) && oTerm.checked) //krizenie datumov, len pri terminovanej
	{
   		window.alert(lang[62]);
		return false;
	}
	//alert(stamp_to - stamp_from);
	//alert(stamp_to);
	oInput = getObj ('title');
	if (window.RegExp)
    {
		znaky = new RegExp('^[^\\\^\$\[\|\?\*\{\}~]{1,70}$'); //nazov uloh, povoleny znak '#+!&()'
		if (!znaky.test(oInput.value))
		{ 
            oInput.focus();
    		window.alert(lang[94]);
			return false;
		}
    }
	var chb = 0;
		//alert(chb);
	for (i=0; i<projCount; i++)
	{
		oChb = getObj('real_'+i);
		//alert(oChb.checked);
		if(oChb.checked) {chb += 1;}
		//alert(chb);
	}
	if(chb == 0)
	{
		window.alert(lang[119]+"!"); 
        return false;
	}	
}


function KontrolaEditTask() 
{ 	
	oInput = getObj ('title');
	oTerm = getObj ('termined_bool');	
	
	oDfrom = getObj ('den_from');
	oMfrom = getObj ('mesiac_from');
	oYfrom = getObj ('rok_from');
	stamp_from = Date.UTC(oYfrom.value,oMfrom.value,oDfrom.value);
	
	oDto = getObj ('den_to');
	oMto = getObj ('mesiac_to');
	oYto = getObj ('rok_to');
	stamp_to = Date.UTC(oYto.value,oMto.value,oDto.value);
	
	/*
	stamp_now = Date.UTC(dnesR,dnesM,dnesD);	
	*/
	/*
	if (((stamp_from - stamp_now) < 0) && oTerm.checked) //spatna platnost, len pri terminovanej
	{
   		window.alert(lang[61]);
		return false;
	}
	*/
	if (((stamp_to - stamp_from) < 0) && oTerm.checked) //krizenie datumov, len pri terminovanej
	{
   		window.alert(lang[62]);
		return false;
	}
		
	if (window.RegExp)
    {
		znaky = new RegExp('^[^\\\^\$\[\|\?\*\{\}~]{1,70}$'); //nazov uloh, povoleny znak '#+!&()'
		if (!znaky.test(oInput.value))
		{ 
            oInput.focus();
    		window.alert(lang[94]);
			return false;
		}
    }
	
	var chb = 0;
		//alert(chb);
	for (i=0; i<projCount; i++)
	{
		oChb = getObj('real_'+i);
		//alert(oChb.checked);
		if(oChb.checked) {chb += 1;}
		//alert(chb);
	}
	if(chb == 0)
	{
		window.alert(lang[119]+"!"); 
        return false;
	}	
	
}

function KontrolaTell() 
{  
    if (window.RegExp) 
    { 
		//alert('fry');
		oMeno = getObj ('name');
		oEmail_1 = getObj ('email_1');
		oEmail_2 = getObj ('email_2');
		
		znaky_1 = new RegExp('^[^\\\^\$\[\|\(\)\?\*\+\{\}&#!~]{1,30}$'); //meno
        znaky_2 = new RegExp('^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$'); //email
		
		if (!znaky_1.test(oMeno.value))
		{
            window.alert(lang[121]); 
            oMeno.focus(); 
            return false;
		}
		else if(!znaky_2.test(oEmail_1.value)) //zle vyplneny email
		{
			window.alert(lang[54]+' 1');
	        oEmail_1.focus(); 
            return false;
		}
		else if(!znaky_2.test(oEmail_2.value)) //zle vyplneny email
		{
			window.alert(lang[54]+' 2');
	        oEmail_2.focus(); 
            return false;
		}
		/*else if(('' == oEmail.value) && (oNotifikacia.checked)) //notifikacia bez mailu
		{
			window.alert(lang[118]);
	        oEmail.focus(); 
            return false;
		}
		*/else
		{
			return true;
		}
    } 
}

function ChangeTaskType() // pouziva ju add_task aj edit_task!
{
	h_2 = getObj('header_2');
	h_3 = getObj('header_3');
	//h_4 = getObj('header_4');
	//chLast_1 = getObj('last_1');
	//chLast_2 = getObj('last_2');
	//t_1 = getObj('text_1');
	//t_2 = getObj('text_2');
	inpTo = getObj('strTo');
	oCalIco = getObj ('tcalico_1');
	rep = getObj('repeat');
	fForm = getObj('addform'); //treba referencovat form, nie priamo radio
	                            //rovnaky nazov v add_form aj task_form

	if(fForm.task_type[0].checked)
	{
        h_2.style.color = '#000000';
		h_3.style.color = '#bbbbbb';
		//h_4.style.color = '#bbbbbb';
		//t_1.style.color = '#bbbbbb';
		//t_2.style.color = '#bbbbbb';
		inpTo.disabled = false;
		oCalIco.style.visibility = 'visible';
		rep.disabled = true;
		//chLast_1.disabled = true;
		//chLast_2.disabled = true;
	}
	else if(fForm.task_type[1].checked)
	{
        h_2.style.color = '#000000';
		h_3.style.color = '#000000';
		//h_4.style.color = '#000000';
		//t_1.style.color = '#000000';
		//t_2.style.color = '#000000';
		inpTo.disabled = false;
		oCalIco.style.visibility = 'visible';
		rep.disabled = false;
		//chLast_1.disabled = false;
		//chLast_2.disabled = false;
	}
	else
	{
        h_2.style.color = '#bbbbbb';
		h_3.style.color = '#bbbbbb';
		//h_4.style.color = '#bbbbbb';
		//t_1.style.color = '#bbbbbb';
		//t_2.style.color = '#bbbbbb';
		inpTo.disabled = true;
		oCalIco.style.visibility = 'hidden';
		rep.disabled = true;
		//chLast_1.disabled = true;
		//chLast_2.disabled = true;
	}
	//ShowLast();
}
/*
function enableDisable_0()
{
	h_2 = getObj('header_2');
	h_3 = getObj('header_3');
	h_4 = getObj('header_4');
	inpTo = getObj('strTo');
	oCalIco = getObj ('tcalico_1');
	rep = getObj('repeat');
	fForm = getObj('addform'); //treba referencovat form, nie priamo radio
	//dPres = getObj('den_preset');
	
	h_2.style.color = '#000000';
	h_3.style.color = '#bbbbbb';
	h_4.style.color = '#bbbbbb';
	inpTo.disabled = false;
	oCalIco.style.visibility = 'visible';
	rep.disabled = true;
	//dPres.disabled = true;

	alert(fForm.task_type[0].checked+' '+fForm.task_type[1].checked+' '+fForm.task_type[2].checked);
}

function enableDisable_1()
{
	h_2 = getObj('header_2');
	h_3 = getObj('header_3');
	h_4 = getObj('header_4');
	inpTo = getObj('strTo');
	oCalIco = getObj ('tcalico_1');
	rep = getObj('repeat');
	fForm = getObj('addform'); //treba referencovat form, nie priamo radio
	//dPres = getObj('den_preset');

	h_2.style.color = '#000000';
	h_3.style.color = '#000000';
	h_4.style.color = '#000000';
	inpTo.disabled = false;
	oCalIco.style.visibility = 'visible';
	rep.disabled = false;
	//dPres.disabled = false;
	//alert(h_4);

	alert(fForm.task_type[0].checked+' '+fForm.task_type[1].checked+' '+fForm.task_type[2].checked);
}

function enableDisable_2()
{
	h_2 = getObj('header_2');
	h_3 = getObj('header_3');
	h_4 = getObj('header_4');
	inpTo = getObj('strTo');
	oCalIco = getObj ('tcalico_1');
	rep = getObj('repeat');
	fForm = getObj('addform'); //treba referencovat form, nie priamo radio
	//dPres = getObj('den_preset');

	h_2.style.color = '#bbbbbb';
	h_3.style.color = '#bbbbbb';
	h_4.style.color = '#bbbbbb';
	inpTo.disabled = true;
	oCalIco.style.visibility = 'hidden';
	rep.disabled = true;
	//dPres.disabled = true;

	alert(fForm.task_type[0].checked+' '+fForm.task_type[1].checked+' '+fForm.task_type[2].checked);
}
*/

/*
function enableDisable()
{
	//h_1 = getObj('header_1');
	h_2 = getObj('header_2');
	//dFrom = getObj('den_from');
	//mFrom = getObj('mesiac_from');
	//rFrom = getObj('rok_from');
	dTo = getObj('den_to');
	mTo = getObj('mesiac_to');
	rTo = getObj('rok_to');
	if(dTo.disabled)
	{
		//h_1.style.color = '#000000';
		h_2.style.color = '#000000';
		//dFrom.disabled = false;
		//mFrom.disabled = false;
		//rFrom.disabled = false;
		dTo.disabled = false;
		mTo.disabled = false;
		rTo.disabled = false;
	}
	else
	{
		//h_1.style.color = '#bbbbbb';
		h_2.style.color = '#bbbbbb';
		//dFrom.disabled = true;
		//mFrom.disabled = true;
		//rFrom.disabled = true;
		dTo.disabled = true;
		mTo.disabled = true;
		rTo.disabled = true;
	}
}
*/

function ColorChanger(square,index,color)
{
	sqr = getObj('color_square_' + square);
	sqr.style.backgroundColor = '#' + color;
	inp = getObj('clr_' + square);
	inp.value = index;
	for (i=0; i<36; i++)
	{
		pal = getObj('palette_' + square + '_' + i);
		pal.style.border = '0px';
	}
	pal = getObj('palette_' + square + '_' + index);
	if(index > 32)
	{
		pal.style.border = '2px solid white';
	}
	else
	{
		pal.style.border = '2px solid black';
	}	
}

function EnableDisable(index) //premenovat!!!
{
	real = getObj('real_' + index);
	box = getObj('notif_' + index);
	//alert(real.checked);
	
	if(notify[index])
	{
		if(real.checked)
		{
			box.disabled = false;
			box.checked = true;
		}
		else
		{
			box.checked = false;
			box.disabled = true;
		}
	}		
}

function ShowHideList()
{
	box = getObj('list');
	if(box.style.display == 'block')
	{
		box.style.display = 'none';
	}
	else
	{
		box.style.display = 'block';
	}
}

function IsLastDay(timestring) // posledny den v mesiaci kratsom ako 31
{
	//alert(timestring);
    aDate = timestring.split('-');
	myDate_1 = new Date(aDate[2],aDate[1]-1,aDate[0]); // mesiac v JS zacina "0"
	stmp_1 = myDate_1.getTime();
	stmp_2 = stmp_1 + 86400000;
	myDate_2 = new Date(stmp_2);
	//alert(aDate[0]);
	if((myDate_1.getMonth() < myDate_2.getMonth()) && (aDate[0] < 31))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function ShowLast()
{
	iFrom = getObj('strFrom');
	iTo = getObj('strTo');
	//pRepeat = getObj('repeat');
	fForm = getObj('addform'); //treba referencovat form, nie priamo radio
	chLast_1 = getObj('last_1');
	chLast_2 = getObj('last_2');
	t_1 = getObj('text_1');
	t_2 = getObj('text_2');
	pdRepeat = getObj('repeat');
	sFrom = iFrom.value;
	sTo = iTo.value;
	//alert(pdRepeat.value);
	if((IsLastDay(sFrom)) && (fForm.task_type[1].checked) && (pdRepeat.value > 6))
	{
		chLast_1.disabled = false;
		t_1.style.color = '#000000';
	}
	else
	{
        chLast_1.disabled = true;
		t_1.style.color = '#bbbbbb';
	}
	if((IsLastDay(sTo)) && (fForm.task_type[1].checked) && (pdRepeat.value > 6))
	{
		chLast_2.disabled = false;
		t_2.style.color = '#000000';
	}
	else
	{
        chLast_2.disabled = true;
		t_2.style.color = '#bbbbbb';
	}
	//alert(aFrom[0]);
	//alert(fForm.task_type[1].checked);
	/*
	tType = 0;
	for (i=0; i<fForm.task_type.length; i++)
	{
		if (fForm.task_type[i].checked)
		{
			tType = i;
		}
 	}
	
	if(rRepeat.value == 1)
	{
		alert(iFrom+pRepeat+rType);
	}
	*/
	//dayCount = 32 - new Date(iYear, iMonth, 32).getDate();
	//N.B.: iMonth is zero based, so 0 represents January, 1 represents February, 2 represents March and 11 represents December. iYear is not zero based, this is the actual calendar year number. (2006 is actually 2006)

}

function CheckDateFrom()
{
	inpFrom = getObj('strFrom');
	f_tcalParseDate(inpFrom.value);
	//ShowLast();
}

//******************** BOOKMARK **************************

function CreateBookmarkLink(elem) 
{ 
	title = "TaskMan"; 
	url = "http://www.taskman.info";  
	if (window.sidebar)  // Mozilla Firefox Bookmark
	{		
		window.sidebar.addPanel(title, url,"");	
	} 
	else if( window.external ) // IE Favorite 
	{		
		window.external.AddFavorite( url, title); 
	}	
	/* srat na Operu, nefunguje
	else if(window.opera && window.print) // Opera Hotlist 
	{		
		var elem = document.createElement('a');   
        elem.setAttribute('href',url);   
        elem.setAttribute('title',title);   
        elem.setAttribute('rel','sidebar'); // required to work in opera 7+   
        elem.click();        
	} 
	*/
} 

function WriteBookmarkLink(text)
{
	if (window.external) 
	{  
		document.write('<a href = "javascript:CreateBookmarkLink(this)");">'+text+'</a>');   
	} 
	else  if (window.sidebar) 
	{  
		document.write('<a href = "javascript:CreateBookmarkLink(this)");">'+text+'</a>');  
	} 
	/*
	else if (window.opera && window.print) 
	{	   
		document.write('<a href = "javascript:CreateBookmarkLink(this)");">'+text+'</a>'); 
	} 
	*/
}

function getTimezoneName() 
{
	tmSummer = new Date(Date.UTC(2005, 6, 30, 0, 0, 0, 0));
	so = -1 * tmSummer.getTimezoneOffset();
	tmWinter = new Date(Date.UTC(2005, 12, 30, 0, 0, 0, 0));
	wo = -1 * tmWinter.getTimezoneOffset();

	if (-660 == so && -660 == wo) return 'Pacific/Midway';
	if (-600 == so && -600 == wo) return 'Pacific/Tahiti';
	if (-570 == so && -570 == wo) return 'Pacific/Marquesas';
	if (-540 == so && -600 == wo) return 'America/Adak';
	if (-540 == so && -540 == wo) return 'Pacific/Gambier';
	if (-480 == so && -540 == wo) return 'US/Alaska';
	if (-480 == so && -480 == wo) return 'Pacific/Pitcairn';
	if (-420 == so && -480 == wo) return 'US/Pacific';
	if (-420 == so && -420 == wo) return 'US/Arizona';
	if (-360 == so && -420 == wo) return 'US/Mountain';
	if (-360 == so && -360 == wo) return 'America/Guatemala';
	if (-360 == so && -300 == wo) return 'Pacific/Easter';
	if (-300 == so && -360 == wo) return 'US/Central';
	if (-300 == so && -300 == wo) return 'America/Bogota';
	if (-240 == so && -300 == wo) return 'US/Eastern';
	if (-240 == so && -240 == wo) return 'America/Caracas';
	if (-240 == so && -180 == wo) return 'America/Santiago';
	if (-180 == so && -240 == wo) return 'Canada/Atlantic';
	if (-180 == so && -180 == wo) return 'America/Montevideo';
	if (-180 == so && -120 == wo) return 'America/Sao_Paulo';
	if (-150 == so && -210 == wo) return 'America/St_Johns';
	if (-120 == so && -180 == wo) return 'America/Godthab';
	if (-120 == so && -120 == wo) return 'America/Noronha';
	if (-60 == so && -60 == wo) return 'Atlantic/Cape_Verde';
	if (0 == so && -60 == wo) return 'Atlantic/Azores';
	if (0 == so && 0 == wo) return 'Africa/Casablanca';
	if (60 == so && 0 == wo) return 'Europe/London';
	if (60 == so && 60 == wo) return 'Africa/Algiers';
	if (60 == so && 120 == wo) return 'Africa/Windhoek';
	if (120 == so && 60 == wo) return 'Europe/Amsterdam';
	if (120 == so && 120 == wo) return 'Africa/Harare';
	if (180 == so && 120 == wo) return 'Europe/Athens';
	if (180 == so && 180 == wo) return 'Africa/Nairobi';
	if (240 == so && 180 == wo) return 'Europe/Moscow';
	if (240 == so && 240 == wo) return 'Asia/Dubai';
	if (270 == so && 210 == wo) return 'Asia/Tehran';
	if (270 == so && 270 == wo) return 'Asia/Kabul';
	if (300 == so && 240 == wo) return 'Asia/Baku';
	if (300 == so && 300 == wo) return 'Asia/Karachi';
	if (330 == so && 330 == wo) return 'Asia/Calcutta';
	if (345 == so && 345 == wo) return 'Asia/Katmandu';
	if (360 == so && 300 == wo) return 'Asia/Yekaterinburg';
	if (360 == so && 360 == wo) return 'Asia/Colombo';
	if (390 == so && 390 == wo) return 'Asia/Rangoon';
	if (420 == so && 360 == wo) return 'Asia/Almaty';
	if (420 == so && 420 == wo) return 'Asia/Bangkok';
	if (480 == so && 420 == wo) return 'Asia/Krasnoyarsk';
	if (480 == so && 480 == wo) return 'Australia/Perth';
	if (540 == so && 480 == wo) return 'Asia/Irkutsk';
	if (540 == so && 540 == wo) return 'Asia/Tokyo';
	if (570 == so && 570 == wo) return 'Australia/Darwin';
	if (570 == so && 630 == wo) return 'Australia/Adelaide';
	if (600 == so && 540 == wo) return 'Asia/Yakutsk';
	if (600 == so && 600 == wo) return 'Australia/Brisbane';
	if (600 == so && 660 == wo) return 'Australia/Sydney';
	if (630 == so && 660 == wo) return 'Australia/Lord_Howe';
	if (660 == so && 600 == wo) return 'Asia/Vladivostok';
	if (660 == so && 660 == wo) return 'Pacific/Guadalcanal';
	if (690 == so && 690 == wo) return 'Pacific/Norfolk';
	if (720 == so && 660 == wo) return 'Asia/Magadan';
	if (720 == so && 720 == wo) return 'Pacific/Fiji';
	if (720 == so && 780 == wo) return 'Pacific/Auckland';
	if (765 == so && 825 == wo) return 'Pacific/Chatham';
	if (780 == so && 780 == wo) return 'Pacific/Enderbury'
	if (840 == so && 840 == wo) return 'Pacific/Kiritimati';
	return 'US/Pacific';
}

function secToHM(sec) {
    h = Math.floor(sec/3600);
    hm = h+':';
    s = Math.floor((sec - (h*3600))/60);
    if(s < 10) {
        hm += '0'+s;
    } else {
        hm += s;
    }
    return hm;
}

