///sky.com top bar dropdown select
function surfto(form) {
       var myindex=form.select1.selectedIndex
       if (form.select1.options[myindex].value != "0") {
        location=form.select1.options[myindex].value;}
}

///image swap
function imageSwap(daImage, daSrc){
  var objStr,obj;
  if(document.images){
    if (typeof(daImage) == 'string') {
      objStr = 'document.' + daImage;
      obj = eval(objStr);
      obj.src = daSrc;
    } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
      daImage.src = daSrc;
    }
  }
}

///homepage navigation information - show&hide layers
function findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;
}

function showHideLayers() { //v3.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

//// OPEN WINDOW IN SKY.COM FRAMESET ////
	function openSkywindow(page, useFrameset,userDefinedWidth,userDefinedHeight) {
		if(openSkywindow.arguments[2]!=null) {
		    var width=userDefinedWidth;
		}
		
		if(openSkywindow.arguments[3]!=null) {
			var height=userDefinedHeight;
		}

		if (useFrameset == 'N') {
			newwin=window.open('','newin','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height);
		  	window.newwin.moveTo(30,30);
			newwin.location = page;
		}
		else {
			newwin=window.open('','newin','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbar=no,scrollbars=auto,resizable=yes,copyhistory=yes,width='+width+',height='+height);
			window.newwin.moveTo(30,30);
			newwin.document.write ('<TITLE>Sky.com</TITLE>');
			newwin.document.write ('<FRAMESET ROWS="42,100%" BORDER="0">');
			newwin.document.write ('<FRAME marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" name="other" scrolling="no" src="external_skycom_frame.html">');
			newwin.document.write ('<FRAME name="destination" scrolling="auto" SRC = "' + page + '" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">');
			newwin.document.write ('</FRAMESET>');
		}
	}
	
/// OPEN POPUP
	function openPopup(theURL,winName,features) 
	{ 
	  window.open(theURL,winName,features);
	}

/// DISPLAY THE POLL POPUP
	function displayPollPopUp(f) {
		var poll_id;
		var checked = 0;
		answer = f.ans;
		var poll_id = f.QID.value;
		
		// Set up the parameter for the popup window
		var width = 352;
		var height = 415;
		var features = 'history=no,resizable=no,status=no,scrollbars=yes,menubar=no';
		
		// Loop through the form controls
		for(var i = 0; i < f.ans.length; i++) {
			if (answer[i].checked == "1")	{
				checked = 1;
				var ans = answer[i].value;
			} 
		}
		if(checked) {
			var url = '/skycom/polls/displayresults/1,,'+poll_id+',00.html?ans='+ans;
			window.open(url,'NewWin',features + "height=" + height + ",width=" + width);
			return false;
		} else {
			alert('Please select an answer !');
			return false;
		}
	}

	// SET THE LOCATION OF THE PARENT WINDOW, AND CLOSE THIS WINDOW DOWN.
	function setParentLocation (newURL) {
		opener.document.location=newURL;
		window.close();
	}

/// VALIDATE THE ADVANCED SEARCH FORM
	function validateAdvSearch(form) {
		// Extract values of fields and select lists into variables
		var queryString = form.QUERY.value;
		
		var dayFromValue = form.DayFrom.options[form.DayFrom.selectedIndex].value;
		var monthFromValue = form.monthFrom.options[form.monthFrom.selectedIndex].value;
		var yearFromValue = form.yearFrom.options[form.yearFrom.selectedIndex].value;
		
		var dayToValue = form.DayTo.options[form.DayTo.selectedIndex].value;
		var monthToValue = form.monthTo.options[form.monthTo.selectedIndex].value;
		var yearToValue = form.yearTo.options[form.yearTo.selectedIndex].value;
		
		// We need to check that there has been some info added to the query, otherwise we
		// are going to return a failure and set the focus to the query input text box
		if (queryString == "")
		{
			alert( 'Please specify a query string.' );
			return false;
		}

		// Check the date values that we are using
		if (dayFromValue != "" && monthFromValue !="" && yearFromValue !="") {
			var todayDate = new Date();
			var submitDate = new Date(yearFromValue, (monthFromValue-1), dayFromValue);
	
			if (submitDate > todayDate) {
				var returnVal = false;
				alert('You have selected a Date From later than today.Please select a valid Date From.');
			} else {
				// Check that the From date is earlier than the To date
				var submitToDate = new Date(yearToValue, (monthToValue-1), dayToValue);
				
				if (submitDate > submitToDate) {
					var returnVal = false;
					alert('You have selected a Date From later than the Date To. Please change either the From or To date.');
				} else {
					var returnVal = true;
				}
			}
		} else {
			var returnVal = true;
		}
		return returnVal;
	}
