

/* REVENUE SCIENCE AD TAG CODE
*/

var rsi_segs = [];
var segs_beg=document.cookie.indexOf('rsi_segs=');
if(segs_beg>=0){
 segs_beg=document.cookie.indexOf('=',segs_beg)+1;
 if(segs_beg>0){
  var segs_end=document.cookie.indexOf(';',segs_beg);
  if(segs_end==-1)segs_end=document.cookie.length;
  rsi_segs=document.cookie.substring(segs_beg,segs_end).split('|');
}}
var segLen=20
var segQS="",segArr=new Array()
if (rsi_segs.length<segLen){segLen=rsi_segs.length}
for (var i=0;i<segLen;i++){
    segArr=rsi_segs[i].split("_")
    if (segArr.length>1) segQS+=("rsi"+"="+segArr[1]+"+")
}

/* END REVENUE SCIENCE AD TAG CODE
*/

///Automatic iFrame resize
function adjustIFrameSize (iframeWindow) { 
  if (iframeWindow.document.height) { 
    var iframeElement = parent.document.getElementById 
		(iframeWindow.name); 
    iframeElement.style.height = iframeWindow.document.height + 16 + 'px'; 
  } 
  else if (document.all) { 
    var iframeElement = parent.document.all[iframeWindow.name]; 
    if (iframeWindow.document.compatMode && 
        iframeWindow.document.compatMode != 'BackCompat')  
    { 
      iframeElement.style.height =  
iframeWindow.document.documentElement.scrollHeight + 5 + 'px'; 

    } 
    else { 
      iframeElement.style.height =  
iframeWindow.document.body.scrollHeight + 1 + 'px'; 
{ 
      iframeElement.style.height =  
iframeWindow.document.body.offsetHeight + 1 + 'px'; 

    } 
    } 
  } 
} 

///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;
    }
  }
}

/// OPEN POPUP
	function openPopup(theURL,winName,features) 
	{ 
	  window.open(theURL,winName,features);
	}

var newWin = null; 
function popUp(strURL, strType, strHeight, strWidth) { 
 if (newWin != null && !newWin.closed) 
   newWin.close(); 
 var strOptions=""; 
 if (strType=="video") 
     strOptions="height="+ 
     strHeight+",width="+strWidth;
 if (strType=="gallery") 
   strOptions="height="+ 
     strHeight+",width="+strWidth; 
 if (strType=="terms")
 	strOptions="scrollbars,height="+
	 strHeight+",width="+strWidth;	 
 newWin = window.open(strURL, 'newWin', strOptions, 'status=no'); 
 newWin.focus(); 
}

/// OPEN POPUP
function openPopup(theURL,winName,features) 
{ 
	window.open(theURL,winName,features);
}

function NewWindow(strURL, strType, strHeight, strWidth) { 
 if (newWin != null && !newWin.closed) 
   newWin.close(); 
 var strOptions=""; 
 if (strType=="video") 
     strOptions="height="+ 
     strHeight+",width="+strWidth;
 if (strType=="gallery") 
   strOptions="height="+ 
     strHeight+",width="+strWidth; 
 if (strType=="terms")
 	strOptions="toolbar=0,height="+
	 strHeight+",width="+strWidth;	 
 newWin = window.open(strURL, 'newWin', strOptions); 
 newWin.focus(); 
}

function isChecked(f)
{	
    // Loop through the elements of the form, looking for all
    // radio buttom elements that have their check property set to true.
	// If the checkbox is set to true, exit the function returning true.
	// Otherwise, display an appropriate error message to the user and
	// return false to indicate that none of the check boxes have
	// been selected.		
    for(var i = 0; i < f.elements.length; i++) {
        var e = f.elements[i];
		// Check to see that we have a radio button
		
		if (e.type == "radio") {
			// Now check to see that it is checked.
			// As soon as we find one that is checked
			// exit the proc.
			if (e.checked == "1") {
				return true;
			}
		}
	}
	
	// Check box not checked so return false
	alert('Please select an Answer');
	return false;
}

function google_ss(w,id) {
  window.status = w;
  return true; 
}

function google_cs() {
  window.status = "";
}

function f_onSubmit (mo_form)
{
	f_setJSEnabled (mo_form);
	
	o_elem = mo_form.elements["Email"];
	
	if (! f_checkEmail (o_elem.value))
	{
		alert ("Please enter a valid Email address");
		o_elem.focus();
		return false;
	}

	return true;
}

	function MM_displayStatusMsg(msgStr) 
	{ //v1.0
		status = msgStr;
		document.MM_returnValue = true;
	}
	
	function f_setJSEnabled (mo_form)
	{
		mo_form.elements["js_enabled"].value = "true";
	}
	
	
/* Newsletter signup JS */

    function f_onSubmit (mo_form)  {   
	f_setJSEnabled (mo_form);      
	o_elem = mo_form.elements["Email"];
	if (! f_checkEmail (o_elem.value))   {
		alert ("Please enter a valid Email address");    
		o_elem.focus();    
		return false;
	}
	return true;
    }    
