function preloadImages() {
  if (document.images) {
    var imgFiles = preloadImages.arguments;
    if (document.preloadArray==null)
    	document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
    }
  }
}

function swapImages() {
	var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
	for (i=0; i < (swapImages.arguments.length-1); i+=2) {
		objStr = swapImages.arguments[i];
		obj = eval(objStr);
		swapArray[j++] = obj;
		swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
		obj.src = swapImages.arguments[i+1];
	}
	document.MM_swapImgData = swapArray;
}

function restoreImages() {
	if (document.MM_swapImgData != null)
		document.MM_swapImgData[0].src = document.MM_swapImgData[1];
}

function popupCustom(pathfile,in_width,in_height,scrollbars_on,resize) {
	var windowname = "";
	var newWin = window.open(pathfile,windowname,"resizable="+resize+",status=no,width="+in_width+",height="+in_height+",scrollbars="+scrollbars_on+",top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,alwaysRaised=yes,z-lock=yes");
	newWin.focus();
}

function popupImage(pathfile,in_width,in_height) {
	var titleStr = "Love Tricycle";
	var scrollbars_on="no", resize="no";
	var windowwidth=in_width, windowheight=in_height;
	var screenwidth=screen.width, screenheight=screen.height;
	if (in_width > screenwidth) {
		windowwidth = screenwidth;
		scrollbars_on = "yes";
		resize = "yes";
	}
	if (in_height > screenheight) {
		windowheight = screenheight;
		scrollbars_on = "yes";
		resize = "yes";
	}
	var newWin = window.open("","","resizable="+resize+",status=no,width="+windowwidth+",height="+windowheight+",scrollbars="+scrollbars_on+",top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,alwaysRaised=yes,z-lock=yes");
	var buffer = '<html><head><title>'+titleStr+'</title></head>';
	buffer = buffer + '<body leftMargin="0" topMargin="0" marginwidth="0" marginheight="0" border="0">';
	buffer = buffer + '<div style="position:absolute; top:0; left:0">';
	buffer = buffer + '<img src="'+pathfile+'" height="'+in_height+'" width="'+in_width+'">';
	buffer = buffer + '</div>';
	buffer = buffer + '</body></html>';
	newWin.document.open();
	newWin.document.write(buffer);
	newWin.document.close();
	newWin.focus();
}

function popupMovie(pathfile,in_width,in_height) {
	var windowtitle = "Love Tricycle Trailer";
	if (pathfile.match("mov")) {
		in_height = parseInt(in_height) + 16;
		pathfile = "http://www.loop.com.au/lt/trailer/"+pathfile;
	}
	else {
		in_height = parseInt(in_height) + 45;
		pathfile = "http://www.lovetricycle.com/trailer/"+pathfile;
	}
	var newWin = window.open("","","resizable=no,status=no,width="+in_width+",height="+(in_height+60)+",scrollbars=no,top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,alwaysRaised=yes,z-lock=yes");

	var buffer = '<html><head><title>'+windowtitle+'</title>';
	buffer = buffer + '<link rel="stylesheet" type="text/css" href="../css/main.css">';
	buffer = buffer + '</head>';
	buffer = buffer + '<body leftMargin="0" topMargin="0" marginwidth="0" marginheight="0" border="0" bgcolor="#071D56">';
	buffer = buffer + '<div class="footer" style="position:absolute; top:0; left:0">';
	if (pathfile.match("mov")) {
		buffer = buffer + '<object width="'+in_width+'" height="'+in_height+' classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">';
		buffer = buffer + '<param name="src" value="'+pathfile+'">';
		buffer = buffer + '<param name="autoplay" value="true">';
		buffer = buffer + '<param name="controller" value="true">';
		buffer = buffer + '<embed src="'+pathfile+'" height="'+in_height+'" width="'+in_width+'" type="video/quicktime" controller="true" autoplay="true" loop="false" pluginspage="http://www.apple.com/quicktime/download/"></embed>';
		buffer = buffer + '</object>';
	}
	else {
		buffer = buffer + '<object width="'+in_width+'" height="'+in_height+'" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">';
		buffer = buffer + '<param name="filename" value="'+pathfile+'">';
		buffer = buffer + '<embed src="'+pathfile+'" height="'+in_height+'" width="'+in_width+'" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/mediaplayer/"></embed>';
	}
	buffer = buffer + '</object>';
	buffer = buffer + '<span style="text-align:center; font-size:8pt; color:#5B86F1;"><p>To save the trailer, <a href="'+pathfile+'">right-click here</a><br>and select \'Save Target As\'</span>';
	buffer = buffer + '</div>';
	buffer = buffer + '</body></html>';
	newWin.document.open();
	newWin.document.write(buffer);
	newWin.document.close();
	newWin.focus();
}
