﻿// Code by Fourthmedia 2007
// #################################### //
// #### PRELOAD AND IMAGE ROLLOVER #### //
// #################################### //
//smart nav


 
function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//function MM_preloadImages() { //v3.0
////  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
////    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
////    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
//}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function CreateBookmarkLink() {
    var title = "Prime TV";   
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, location.href,"");
    } 
    else if( window.external ) 
    { 
    // IE Favorite
        try 
        {
        window.external.AddFavorite( location.href, title); 
        }
        catch (e) {}
        }
    else if(window.opera && window.print) 
    { // Opera Hotlist
    return true; }
}

function loginToRightNow()
{
    if (MyEmail.length > 0) 
    {
        var rn_url = "http://skytv.custhelp.com/cgi-bin/skytv.cfg/php/enduser/acct_login_submit.php?p_next_page=myq_ilp.php&p_userid=";

        var rn_window = window.open("","_blank"); 
	    rn_window.document.writeln('<span style="font-size:11px;font-family:Arial">Please wait...</span>');
        rn_window.document.writeln('<form name="rn_form" method="post" ');
	    rn_window.document.writeln(' action="'+rn_url + MyEmail + '">');
	    rn_window.document.writeln('</form>');
	    rn_window.document.close();
	    rn_window.document.rn_form.submit();
	}
	else{
	    alert('You have to be logged in to see your Questions');
	    }

}


function openVideo (w,h,url)

{

var ww = 1.1 * w;

var wh = 1.1 * h;

var pwin = window.open( "", "photo","width="+ww+",height="+wh+",status=false,scrollbars=false,resizable=false,screenX=20,screenY=40,left=20,top=40");

pwin.document.writeln('<html><body><object width="'+w+'" height="'+h+'" wmode="transparent" data="/Portals/0/Highlights/flvplayer.swf?file=' + url + '" type="application/x-shockwave-flash"><param name="movie" value="/Portals/0/Highlights/flvplayer.swf?file=' + url + '" /><param name="wmode" value="transparent" /></object></body></html>');

pwin.document.close();

} 

function sstchur_SmartScroller_GetCoords()
   {
   try{
      var scrollX, scrollY;
     // alert("hi")
      if (document.all)
      {
         if (!document.documentElement.scrollLeft)
            scrollX = document.body.scrollLeft;
         else
            scrollX = document.documentElement.scrollLeft;
               
         if (!document.documentElement.scrollTop)
            scrollY = document.body.scrollTop;
         else
            scrollY = document.documentElement.scrollTop;
      }   
      else
      {
         scrollX = window.pageXOffset;
         scrollY = window.pageYOffset;
      }
   
      document.getElementById(xCoordHolder).value = scrollX;
      document.getElementById(yCoordHolder).value = scrollY;
      }
       catch(e){}  
   }
   
 function sstchur_SmartScroller_Scroll()
   {
    try{
      var x = document.getElementById(xCoordHolder).value;
      var y = document.getElementById(yCoordHolder).value;
      window.scrollTo(x, y);
      }
       catch(e){}  
  
   }
   

// set the default button     
function fnTrapKD(btnID, event){

var btn = document.getElementById(btnID)
if (btn){
 if (document.all){

  if (event.keyCode == 13){

   event.returnValue=false;

   event.cancel = true;

btn.focus();
 btn.click();

  }

 }

 else if (document.getElementById){

  if (event.which == 13){

   event.returnValue=false;

   event.cancel = true;

btn.focus();
   //btn.click();

  }

 }

 else if(document.layers){

  if(event.which == 13){

   event.returnValue=false;

   event.cancel = true;
  alert("3") 
btn.focus();
 btn.click();

  }

 }

}
}


//add onload function 
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


 try{
 addLoadEvent(sstchur_SmartScroller_Scroll)
 //  window.onload = sstchur_SmartScroller_Scroll;
   window.onscroll = sstchur_SmartScroller_GetCoords;
   window.onkeypress = sstchur_SmartScroller_GetCoords;
   window.onclick = sstchur_SmartScroller_GetCoords;
   }
 catch(e){
 } 

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll; // -17 is used for firefox
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
 //
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//


// JScript File
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	var xScroll;

	if (self.pageXOffset) {
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollLeft){	 // Explorer 6 Strict
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		xScroll = document.body.scrollLeft;
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}



function setProgressBarheight(){
    var overlayobj = document.getElementById("overlayobj")

    if(overlayobj){
        var pageSize =  getPageSize();
       var scrolly =  pageSize[1]
       overlayobj.style.left = "0px";
       overlayobj.style.top = "0px";
       overlayobj.style.height = pageSize[1] + 'px';
       overlayobj.style.width = pageSize[0] + 'px'; 
            pageSize =  getPageSize();
             if  (pageSize[1] > scrolly){ // support for firefox
                 overlayobj.style.height = scrolly + "px";
             }
       var overlayobjImage = document.getElementById("overlayobjImage") 
       if (overlayobjImage){
            var pagescrolled = getPageScroll()
            overlayobjImage.style.left = pageSize[2]/2 + pagescrolled[0] - 110 + 'px';
            overlayobjImage.style.top = pageSize[3]/2 + pagescrolled[1] - 9 + 'px';
       } 
     } 
      
}
function ShowModuleConfig(theid){
    var theobj = document.getElementById(theid);
    if (theobj){
    theobj.style.display = 'block';
    }
}
function HideModuleConfig(theid){
    var theobj = document.getElementById(theid);
    if (theobj){
    theobj.style.display = 'none';
    }
}
function hideAjaxLogin(){
var tempbox = document.getElementById("ajaxLogin") 
if (tempbox){
    tempbox.style.display = "none";
    tempbox.id = 'closed'
}
}


//------------ajax login scripts-----------------------------------

function onfoucsTextbox(object,type){
if (type == "Password"){
    try{
    object.type = "password";
    }
    catch(e){
            }
}
    if (object.value == type){
    object.value = ""
    }
}

function onblurTextbox(object,type){
 if (object.value == ""){
    object.value = type
    if (type == "Password"){
        try{
        object.type = "textbox";
        }
        catch(e){
            }
    }
    }
}
try{
    if (thePasswordbox){
        document.getElementById(passwordbox).type = "textbox";
    }
}
catch(e){
}
function CheckEmptyLogin(txtuser,txtpassword){
    var userobj = document.getElementById(txtuser)
    var passwordobj = document.getElementById(txtpassword)
    if (userobj && passwordobj){
        if (userobj.value != "Email" && passwordobj.value != "Password" && userobj.value != "" && passwordobj.value != ""){
            return true;
        }
    }
    return false;
}