var strPathToRoot = '/';

function navClick(id) {
	document.getElementById('ucNav_lnkNav' + id).click();	
}

function navOn(id) {
	document.getElementById('divNav' + id).style.backgroundColor = '#262425';	
	document.getElementById('divNavArrow' + id).className = 'nav_arrow_on';
	document.getElementById('ucNav_lnkNav' + id).style.color = '#FFFFFF';
	if (id == 'WhatsOn')
		document.getElementById('divSubNavWhatsOn').style.display = 'block';
	else {
		document.getElementById('divSubNavWhatsOn').style.display = 'none';
	}
	if (id == 'Genres')
		document.getElementById('divSubNavGenres').style.display = 'block';
	else {
		document.getElementById('divSubNavGenres').style.display = 'none';
	}
	if (id == 'Highlights')
		document.getElementById('divSubNavHighlights').style.display = 'block';
	else {
		document.getElementById('divSubNavHighlights').style.display = 'none';
	}
	if (id == 'MiniSites')
		document.getElementById('divSubNavMiniSites').style.display = 'block';
	else {
		document.getElementById('divSubNavMiniSites').style.display = 'none';
	}	
}

function navOff(id) {
	if (id.substring(0,9) == 'Affiliate') {
		document.getElementById('divNav' + id).style.backgroundColor = '#99999B';
		document.getElementById('divNavArrow' + id).className = 'nav_arrow';
		document.getElementById('ucNav_lnkNav' + id).style.color = '#FFFFFF';		
	} else {
		document.getElementById('divNav' + id).style.backgroundColor = '#FFFFFF';
		document.getElementById('divNavArrow' + id).className = 'nav_arrow';
		document.getElementById('ucNav_lnkNav' + id).style.color = '#262425';	
	}
}

function navOnExtra(index) {
	document.getElementById('ucNav_repExtraSections__ctl' + index + '_divNavExtraSection').style.backgroundColor = '#262425';	
	document.getElementById('ucNav_repExtraSections__ctl' + index + '_divNavArrowExtraSection').className = 'nav_arrow_on';
	document.getElementById('ucNav_repExtraSections__ctl' + index + '_lnkNavExtraSection').style.color = '#FFFFFF';
}

function navOffExtra(index) {
	document.getElementById('ucNav_repExtraSections__ctl' + index + '_divNavExtraSection').style.backgroundColor = '#FFFFFF';	
	document.getElementById('ucNav_repExtraSections__ctl' + index + '_divNavArrowExtraSection').className = 'nav_arrow';
	document.getElementById('ucNav_repExtraSections__ctl' + index + '_lnkNavExtraSection').style.color = '#262425';
}

function navOnExtraAffiliate(index) {
	document.getElementById('ucNav_repAffiliateExtraSections__ctl' + index + '_divNavAffiliateExtraSection').style.backgroundColor = '#262425';
	document.getElementById('ucNav_repAffiliateExtraSections__ctl' + index + '_divNavArrowAffiliateExtraSection').style.color = '#2367C1';
	document.getElementById('ucNav_repAffiliateExtraSections__ctl' + index + '_lnkNavAffiliateExtraSection').style.color = '#FFFFFF';
}

function navOffExtraAffiliate(index) {
	document.getElementById('ucNav_repAffiliateExtraSections__ctl' + index + '_divNavAffiliateExtraSection').style.backgroundColor = '#99999B';
	document.getElementById('ucNav_repAffiliateExtraSections__ctl' + index + '_divNavArrowAffiliateExtraSection').style.color = '#333333';
	document.getElementById('ucNav_repAffiliateExtraSections__ctl' + index + '_lnkNavAffiliateExtraSection').style.color = '#FFFFFF';
}

function subNavOn(id) {
	navOn(id);
}
function subNavOff(id) {
	navOff(id);
	document.getElementById('divSubNav' + id).style.display = 'none';
}

function openMinisite(id) {
	url = strPathToRoot + 'minisite.aspx?ID=' + id;
	winMS = window.open(url,'winMS','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,top=50,left=50,width=617,height=570');
	try {
		winMS.focus();
	}
	catch(err) {
		//if pop-up blocked from onload event, display link
		if (document.getElementById('launch_minisite'))
			document.getElementById('launch_minisite').style.display = 'block';		
	}
}

function openMinisiteArticle(id,articleId) {
	url = strPathToRoot + 'minisite_article.aspx?ID=' + id + '&ArticleID=' + articleId;
	winMS = window.open(url,'winMS','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,top=50,left=50,width=617,height=600');
	winMS.focus();
}

function resizeMinisite(h) {
	window.resizeTo(629,h)
}

function testForEnterQS() { 
	if (event.keyCode == 13) { 
		document.getElementById("ucTop_btnSearch").click(); 
		event.returnValue = false; 
	}  
}

function testForEnterEmail() { 
	if (event.keyCode == 13) { 
		document.getElementById("ucEmailSignUp_btnEnter").click(); 
		event.returnValue = false; 
	}  
}

function testForEnterAS() { 
	if (event.keyCode == 13) { 
		document.getElementById("btnSearch").click(); 
		event.returnValue = false; 
	}  
}

function testForEnterAL() { 
	if (event.keyCode == 13) { 
		document.getElementById("btnLogin").click(); 
		event.returnValue = false; 
	}  
}

function checkEntry() {
	var blnOK = false;
	if (document.forms[0].elements['ucCompetitionForm_txtAnswer']) {
		blnOK = document.forms[0].elements['ucCompetitionForm_txtAnswer'].value.length > 0;
		if (!blnOK) alert('Please enter your answer to the question before submitting your entry.');
	} else {			
		blnOK = document.forms[0].elements['ucCompetitionForm_rdoOptionA'].checked || document.forms[0].elements['ucCompetitionForm_rdoOptionB'].checked || document.forms[0].elements['ucCompetitionForm_rdoOptionC'].checked;
		if (!blnOK) alert('Please select your answer to the question before submitting your entry.');
	}
	return blnOK;
}
