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_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_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_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 clearCurrentLink(){
//    var d = document.getElementsByTagName("div");
//    for(var j=0;j<d.length;j++)
//    {
        var a = document.getElementsByTagName("A");
        for(var i=0;i<a.length;i++)
        {
            if(a[i].href == window.location.href.split("#")[0])
            {
                removeNode(a[i]);
            }
        }
//                removeNode(d[j],[i]);
//    }

}

function removeNode(n){
    spanNode = document.createElement('span');
    level = n.parentNode.id;
    if (!level)
        {
            level = n.parentNode.nodeName;
            if (level == 'LI')
            {
                pLI = n.parentNode;
                pUL = pLI.parentNode;
                pDiv1 = pUL.parentNode;
                level = pDiv1.parentNode.id;
            }
        }
    if (level == 'second-level-nav' || level == 'third-level-nav' || level == 'sidenav-mid' || level == 'sidenav-left-mid_ltgrey' || level == 'sidenav-mid_short' || level == 'nav-text-ltgrey' || level == 'sidenav-mid_very_short' || level == 'nav-title-blue')
    {
        spanAttr = document.createAttribute('class');
        spanAttr.value = level + '-cue';
        spanNode.setAttributeNode(spanAttr);
    }
    if(n.hasChildNodes())
        for(var i=0;i<n.childNodes.length;i++)
        {
            //par = n.parentNode;
            //alert("clear link " + n.parentNode.id);
            spanNode.appendChild(n.childNodes[i].cloneNode(true));
            n.parentNode.insertBefore(spanNode,n);
        }
    //spanNode.createAttribute('class', 'second-level-nav-cue');
    n.parentNode.removeChild(n);
}

function printit(){  
	if (window.print) {
    	window.print() ;  
	} else {
    	var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
	    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
	}
}


/*
function calcHeight()
{
  //find the height of the internal page
  var the_height = document.getElementById('lgi_iframe').contentWindow.document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById('lgi_iframe').height = the_height;
}

function resize() {
    var iframe = document.all.lgi_iframe;
    iframe.height = document.frames["lgi_iframe"].document.body.scrollHeight;
}
*/

/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
* solution copied from: http://www.webmasterworld.com/javascript/3756281.htm
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["lgi_iframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
    window.onload = resizeCaller

function decision(message, url) {
    promptLeaveSite(url);
}

function promptLeaveSite(url) {
    var txt = 'You are about to leave the Liberty Global website. This link does not constitute an '
                + 'endorsement or approval of information offered at sites you reach through this link '
                + 'whether or not Liberty Global is affiliated with the sponsor of the site.  You are '
                + 'subject to the terms of use and privacy policy applicable to such web sites.<br /><br />'
                + 'Press <b>OK</b> to continue or <b>CANCEL</b> to return to LGI.com.'
                + '<input type="hidden" id="url" name="url" value="' + url + '" />';
    $.prompt(txt, {
    buttons: { Ok: true, Cancel: false },
    focus: 1,
    callback: promptLeaveSiteDecision
    });
}

function promptLeaveSiteDecision(v, m, f) {
    //$.prompt('i clicked ' + v);
    if (v) {
        window.open(f.url, 'LGIAffiliate');
    }
}


function openVideo() {
     if (!arguments[3])
    { arguments[3] = 320; }

    if (!arguments[4])
    { arguments[4] = 310; }

    if (!arguments[5] && arguments[5] != 0)
    { arguments[5] = 1; }

    if (!arguments[6])
    { arguments[6] = arguments[3] + 80; }
    if (!arguments[7])
    { arguments[7] = arguments[4] + 165; }

    var params = "video/" + arguments[0] + "/index.aspx?video=" + arguments[1] + "&title=" + arguments[2] + "&w=" + arguments[3] + "&h=" + arguments[4] + "&txt=" + arguments[5];
    openPopUpWindow(params, arguments[6], arguments[7], arguments[0]);
}

function openPopUpWindow(url, width, height, windowname) {
    if (height == null || height == "")
    { height = 500; }

    if (width == null || width == "")
    { width = 600; }

    if (windowname == null || windowname == "")
	{
		var randomnumber=Math.floor(Math.random()*101);
		windowname = "windowPopup" + randomnumber;
	}

    var params = "location=0,status=0,toolbar=0,scrollbars=2,menubar=0,width=" + width + ",height=" + height;

    mywindow = window.open(url, windowname, params);
}
