function open_movie(mov)
{
	//if (!APPLICATION_ROOT) { APPLICATION_ROOT = '/'; }
	// write mov
/*	var myQTObject = new QTObject(APPLICATION_ROOT + "pixel.mov", "mov_pop", "1", "1");
	myQTObject.addParam("controller", "false");
	//myQTObject.addParam("qtnext1", "<" + mov + ">T<quicktimeplayer>E<scale='Aspect' width='" + screen.availWidth + "' height='" + screen.availHeight + "'>");
	myQTObject.addParam("qtnext1", "<" + mov + ">T<quicktimeplayer>E<scale='Aspect' width='500' height='500'>");
	myQTObject.addParam("autoplay", "true");
	myQTObject.write('mov_div');
*/
	//	Scale down, but not up
	//var width = 1280;
	//var height = 735;	//	+15 for the controls
	//if (screen.availWidth < width) {
	//	height = (height / width) * screen.availWidth; 
	//	width = screen.availWidth;
	//}
	//if (screen.availHeight < height) {
	//	width = (width / height) * screen.availHeight;
	//	height = screen.availHeight;
	//}
	
	var width = screen.availWidth;
	var height = screen.availHeight;
	//alert(width + ':' + height);
	//popup("/hd/?mov=" + mov, width, height);
	popup(mov, width, height);

}

function popup(url,width,height) {
	//alert(width + ':' + height);
	var sx = (screen.availWidth - width) / 2;
	var sy = (screen.availHeight - height) / 2;
	//alert(sx + ":" + sy);
	var properties = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,width=" + width + ",height=" + height + ",screenX=" + sx + ",screenY=" + sy;
	var myPopup = window.open(url, "myPopup", properties);
	myPopup.focus();
}

function downloadFile(url) {
	myTempWindow = window.open(url,'','left=10000,screenX=10000');
	myTempWindow.document.execCommand('SaveAs','null',url);
	myTempWindow.close();
}

function trackpage(url) {
	pageTracker._trackPageview(url);
}


function trackevent(category, action, label, value) {
	var vf = parseInt(value);
	var result = pageTracker._trackEvent(category, action, label, vf);
	//window.console.log('trackEvent: ' + result);
}

var swfId = "flashContent";

function openWindow(pageUrl) {
    var winName = Math.round(9999*Math.random()) + new Date().getTime();
    var winNew = window.open(pageUrl,winName,"toolbar=1,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width=1000,height=700,left=200,top=100");

    if(!winNew) {
        getSwf(swfId).openWindowFromSwf(pageUrl);
    }
    else {
        winNew.focus();
    }
}

function getSwf(id) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[id];
    } 
    else {
        return document[id];
    }
}    
    
function showad3(url) {

    function genSetRandDARTNumber()
    {
        bust = Math.round(Math.random()*1000000000000);
    }

    genSetRandDARTNumber();

    var ad1 = document.getElementById('adcontent1');
    if (ad1 != null) {
    	document.getElementById('adcontent1').style.display = "";
    	document.getElementById('adcontent1').innerHTML = "<iframe width='100%' scrolling='no' height='100%' frameborder='0' allowtransparency='true' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0' src='" + url + "/leaderboard.html'></iframe>";
    }
    
    var ad2 = document.getElementById('adcontent2');
    if (ad2 != null) {
    	document.getElementById('adcontent2').style.display = "";
	    document.getElementById('adcontent2').innerHTML = "<iframe width='100%' scrolling='no' height='100%' frameborder='0' allowtransparency='true' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0' src='" + url + "/square.html'></iframe>";
	}
}

function getPos(inputElement) {
    var coords =  new Object();
    coords.x = 0;
    coords.y = 0;
    try {
        targetElement = inputElement;
        if(targetElement.x && targetElement.y) {
            coords.x = targetElement.x;
            coords.y = targetElement.y;
        } else {
            if(targetElement.offsetParent) {
                coords.x += targetElement.offsetLeft;
                coords.y += targetElement.offsetTop;
                while(targetElement = targetElement.offsetParent) {
                    coords.x += targetElement.offsetLeft;
                    coords.y += targetElement.offsetTop;
                }
            } else {
                //alert("Could not find any reference for coordinate positioning.");
            }
        }
        return coords;
    } catch(error) {
        //alert(error.msg);
        return coords;
    }
}
