//Additional JavaScripts

function clearonfocus(element) {
	document.getElementById(element).value="";
}


function showhide(idelement, anchortxt)
{
	var itemState = document.getElementById(idelement);
	var state = itemState.style.display;
	if (state=="block" || state=="") {
		document.getElementById(idelement).style.display="none";
		document.getElementById(anchortxt).innerHTML="show list";
	} else if (state=="none") {
		document.getElementById(idelement).style.display="block";
		document.getElementById(anchortxt).innerHTML="hide list";
	}
}

function showCalendar()
{
document.getElementById("calendar").style.display="block";
}
function hideCalendar()
{
document.getElementById("calendar").style.display="none";
}

function swapBMItabs(show, hide, tabbg)
{
document.getElementById(show).style.display="block";
document.getElementById(hide).style.display="none";
	if (tabbg == "imperial_tab"){
		document.getElementById("imperial_tab").style.backgroundImage="url("+$abs+"_graphics/tab_top-eating_healthily.png)";
		document.getElementById("itab").style.color="#FFFFFF";
		document.getElementById("metric_tab").style.backgroundImage="url("+$abs+"_graphics/tab_top-grey.png)";
		document.getElementById("mtab").style.color="#666666";
	} else if (tabbg == "metric_tab"){
		document.getElementById("metric_tab").style.backgroundImage="url("+$abs+"_graphics/tab_top-eating_healthily.png)";
		document.getElementById("mtab").style.color="#FFFFFF";
		document.getElementById("imperial_tab").style.backgroundImage="url("+$abs+"_graphics/tab_top-grey.png)";
		document.getElementById("itab").style.color="#666666";
	}
}

function swapADtabs(show, hide, tabbg)
{
//document.getElementById(show).style.display="block";
//document.getElementById(hide).style.display="none";
	if (tabbg == "men_tab"){
		document.getElementById("men_tab").style.backgroundImage="url("+$abs+"_graphics/tab_top-drinking_sensibly.png)";
		document.getElementById("mtab").style.color="#FFFFFF";
		document.getElementById("women_tab").style.backgroundImage="url("+$abs+"_graphics/tab_top-grey.png)";
		document.getElementById("wtab").style.color="#666666";
		document.getElementById("hidden_sex").value="men";
	} else if (tabbg == "women_tab"){
		document.getElementById("women_tab").style.backgroundImage="url("+$abs+"_graphics/tab_top-drinking_sensibly.png)";
		document.getElementById("wtab").style.color="#FFFFFF";
		document.getElementById("men_tab").style.backgroundImage="url("+$abs+"_graphics/tab_top-grey.png)";
		document.getElementById("mtab").style.color="#666666";
		document.getElementById("hidden_sex").value="women";
	}
}

var pledge_tab_url = "_graphics/tab_top-eating_healthily.png";
function swapPledgetabs(show, hide, tabbg)
{
        document.getElementById(show).style.display="block";
        document.getElementById(hide).style.display="none";
	if (tabbg == "pledge_list_tab"){
		document.getElementById("pledge_list_tab").style.backgroundImage="url("+pledge_tab_url+")";
		document.getElementById("plist").style.color="#FFFFFF";
		document.getElementById("pledge_writeown_tab").style.backgroundImage="url("+$abs+"_graphics/tab_top-grey.png)";
		document.getElementById("pown").style.color="#666666";
	} else if (tabbg == "pledge_writeown_tab"){
		document.getElementById("pledge_writeown_tab").style.backgroundImage="url("+pledge_tab_url+")";
		document.getElementById("pown").style.color="#FFFFFF";
		document.getElementById("pledge_list_tab").style.backgroundImage="url("+$abs+"_graphics/tab_top-grey.png)";
		document.getElementById("plist").style.color="#666666";
	}
}

var ADCurrRow = 5;
function addNewDrinkselect()
{
    var row = $('#my_id').clone().removeAttr("id").css('display', 'block');
	
    $("a", row).click(removeDrinkselect);
	$("label.adqtylbl", row).attr('for', "quantitym" + ADCurrRow);
	$("#quantitym1", row).attr("id", "quantitym" + ADCurrRow);
	$('#ad_container').append(row);
	
	ADCurrRow++;
}

function removeDrinkselect()
{
    if(this == window) return;
    $($(this).parents().get(2)).remove();
}

function addNewActivitySelect()
{
	var row = $('#my_id').clone().removeAttr("id").css('display', 'block');
	
    $("a", row).click(removeActivitySelect);
	$("label.duration1a", row).attr('for', "duration1a" + ADCurrRow);
	$("#duration1", row).attr("id", "duration1" + ADCurrRow);
	$('#ad_container').append(row);
	
	ADCurrRow++;
}

function removeActivitySelect()
{
	if(this == window) return;
    $($(this).parents().get(2)).remove();
}


$(document).ready(function(){
	$("#date_inputm").datepicker({dateFormat: "dd/mm/yy", firstDay: 1});
});

eos_showDesc = function( p_elm){
    eos_hideAll()
    $("#"+p_elm).css("display", "");
    $(".effectbox").css("display", "");
}

eos_hideAll = function() {
    $(".effectbox div").css('display', 'none');
    $(".effectbox").css("display", "none");
}

unsubscribe = function() {
    $("#newsletter_signup").attr("action", 'newsletter/unsubscribe').submit();
}