function printImage(src,copies) {
	if (CheckIsIE() == true) { printIE(src,copies); }
	else { printFF(src,copies); }
}

function printFF(src,copies){
	var iframe = document.getElementById("printIframe");
	if (!iframe) {
		var iframe = document.createElement("iframe");
		iframe.id = "printIframe";
		iframe.style.position = "absolute";
		iframe.style.width = "100px";
		iframe.style.height = "100px";
		iframe.style.left = "-100em";
		iframe = document.getElementsByTagName("body")[0].appendChild(iframe);
	}
	iframe.src = "includes/ps3/printer.jsp";
	if (!src.push) {
		src = [src];
	}
	
	window.printImgSrc = src;
	window.printImgFooter = copies;
	
	iframe.onload = function () {
		var src = window.printImgSrc;
		var img = [];
		var body = iframe.contentDocument.getElementsByTagName('body')[0];
		iframe.imgCount = src.length;
		for (var i = 0, ii = src.length; i < ii; i++) {
			img[i] = document.createElement("img");
			body.appendChild(img[i]);
			img[i].onload = function () {
				iframe.imgCount--;
				if (iframe.imgCount == 0) {
					iframe.contentWindow.print();
					notifyFlash();
				}
			}
			img[i].src = src[i];
			if (i == ii - 1) {
				img[i].style.pageBreakAfter = "auto";
			}else{
				img[i].style.pageBreakAfter = "always";
			}
		}
		if(window.printImgFooter){
			var footer, sponsor, sponsorimg;
			copies = window.printImgFooter;
			if(copies.push) {
				footer = copies[0];
				sponsor = copies[1];
				if (copies[2] && String(copies[2]).match(/\.jpg$|\.jpeg$|\.gif$|\.png$/i)) {
					sponsorimg = copies[2];
				}
			}
			else {
				footer = copies;
			}
			
			footerdiv = document.createElement("div");
			footerdiv.innerHTML = footer;
			footerdiv.className = "footer";
			body.appendChild(footerdiv);
			if(sponsor){
				sponsordiv = document.createElement("div");
				sponsordiv.innerHTML = sponsor;
				sponsordiv.className = "sponsor";
				body.appendChild(sponsordiv);
			}
			if(sponsorimg){
				body.innerHTML = "<div class=\"sponsorimg\"><img src=\"" + sponsorimg + "\" \/><\/div>" + body.innerHTML;
			}
		}
	}
}

function printIE(src,copies){
	var iframe = document.getElementById("printIframe");
	if (!iframe) {
		var iframe = document.createElement("iframe");
		iframe.id = "printIframe";
		iframe.style.position = "absolute";
		iframe.style.width = "100px";
		iframe.style.height = "100px";
		iframe.style.left = "-100em";
		iframe = document.getElementsByTagName("body")[0].appendChild(iframe);
	}
	iframe.src = "includes/ps3/printer.jsp";
	
	if (!src.push) {
		src = [src];
	}
	
	window.printImgSrc = src;
	window.printImgFooter = copies;
	
	iframe.onreadystatechange = function () {
		if(iframe.readyState == "complete") {
			var src = window.printImgSrc;
			var img = [];
			var body = iframe.contentWindow.document.getElementsByTagName("body")[0];
			iframe.imgCount = src.length;
			for (var i = 0, ii = src.length; i < ii; i++) {
				img[i] = iframe.contentWindow.document.createElement("img");
				body.appendChild(img[i]);
				img[i].onload = function () {
				
					iframe.imgCount--;
					if (iframe.imgCount == 0) {
						iframe.contentWindow.focus();
						if(navigator.appVersion.indexOf("MSIE 7") != -1) {
							iframe.contentWindow.document.execCommand('print',false,null);
						}
						else{
							iframe.contentWindow.print();
						}
						notifyFlash();
					}
				}
				img[i].src = src[i];
				if (i != ii - 1) {
					img[i].style.pageBreakAfter = "always";
				}else{
					img[i].style.border = "none";
				}

			}
			if(window.printImgFooter){
				var footer, sponsor, sponsorimg;
				copies = window.printImgFooter;
				if(copies.push) {
					footer = copies[0];
					sponsor = copies[1];
					if (copies[2] && String(copies[2]).match(/\.jpg$|\.jpeg$|\.gif$|\.png$/i)) {
						sponsorimg = copies[2];
					}
				}
				else {
					footer = copies;
				}
				
				footerdiv = iframe.contentWindow.document.createElement("div");
				footerdiv.innerHTML = footer;
				footerdiv.className = "footer";
				body.appendChild(footerdiv);
				if(sponsor){
					sponsordiv =  iframe.contentWindow.document.createElement("div");
					sponsordiv.innerHTML = sponsor;
					sponsordiv.className = "sponsor";
					body.appendChild(sponsordiv);
				}
				if(sponsorimg){
					sponsorimgdiv =  iframe.contentWindow.document.createElement("div");
					sponsorimgTag = iframe.contentWindow.document.createElement("img");
					sponsorimgTag.style.pageBreakAfter = "";
					sponsorimgTag.src = sponsorimg;
					sponsorimgdiv.appendChild(sponsorimgTag);
					sponsorimgdiv.className = "sponsorimg";
					body.insertBefore(sponsorimgdiv, body.firstChild);
				}
			}
		}
	}
}

 function notifyFlash() {
    var flash = document.getElementById('flash');
 	if (flash == null)
      flash = document.flash;
	  flash.flashMethod();
  }
  
function CheckIsIE(){
	if (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER') { return true; }
	else { return false; }
}

function flashDeepLink(param){
    var flash = document.getElementById('flash');
 	if (flash == null)
      flash = document.flash;
	  flash.deepLink(param);
}

function getVars() {
	var aVars = {};
	if (!location.search || !location.search.length) {
		flashDeepLink(aVars);
		return;
	}
	var aV = location.search.substr(1).split(/&/g);
	var thisVar;
	for (var i = 0, ii = aV.length; i < ii; i++) {
		thisVar = aV[i].split(/=/);
		aVars[thisVar[0]] = unescape(thisVar[1]);
	}
	flashDeepLink(aVars);
}

function trackIt(param){
	bannerRefresh();
	cto.siteSection='disneyonline:printstation';
	cto.pageName=param;
	cto.trackFlashPV();
}