 /**
 * 
 * Requires  SWFObject v2.1 <http://code.google.com/p/swfobject/>
 *
 */

function Thumb(magid, name) {
	
	this.magid = magid;
	
	this.name = (typeof name == "undefined") ? "z_thumb" : name;
	
	this.pageID = 1;
	this.fullscreen = true;
	this.backgroundColor = "#ffffff";
	this.border = false;
	this.borderColor = 0;
	this.launchURL = null;
	this.launchTarget = "_blank";
	this.width = 200;
	this.height = 300;
	this.wmode = false;
	/**
	*	sets the SWF file transparency [true/false]
	*	@param transparentSWF BOOLEAN
	*	
	*/
	this.setSWFTransparency = function(SWFTransparency){
		this.wmode = SWFTransparency;
	}
	
	/**
	*	sets the size of the thumb
	*	@param w	width
	*	@param h	height
	*/
	this.setSize = function(w, h) {
		this.width = w;
		this.height = h;
	}
	
	/**
	*	sets the startpage of the thumb
	*	@param id	pageid
	*/
	this.setPageID = function(id) {
		this.pageID = id;
	}

	/**
	*	sets the background color of the thumb
	*	@param backgroundColor	hexadecimal color value
	*/
	this.setBackgroundColor = function(backgroundColor) {
		this.backgroundColor = backgroundColor;
	}
	
	this.setFullscreen = function(flag) {
		this.fullscreen = flag;
	}
	
	this.setBorder = function(border) {
		this.border = border;	
	}
	
	this.setBorderColor = function(borderColor) {
		this.borderColor = borderColor;
	}
	
	this.setLaunchURL = function(launchURL) {
		this.launchURL = escape(launchURL);	
	}
	
	this.setLaunchTarget = function(launchTarget) {
		this.launchTarget = launchTarget;	
	}
	
	this.writeDiv = function() {
		var div = "<div id=" + this.name + "></div>";
		// div += "<a href='" + this.launchURL + "' target='_blank'><img src='../getIndex.xml.php?magid=" + this.magid + "&pageid=" + this.pageID + "' /></a></div>";
		document.write(div);
	}

	this.draw = function() {
                if(!this.launchURL){

                                this.launchURL="http://viewer.zmags.com/showmag.php?magid=" + this.magid;
				this.setFullscreen(false);

                }

		this.writeDiv();
		wmodestring = "opaque";
		if(this.wmode)wmodestring="transparent";
		var flashvars = {
			magid:this.magid,
			__width:this.width,
			fullscreen:this.fullscreen,
			_border:this.border,
			launchURL:this.launchURL,
			launchTarget:this.launchTarget,
			pageid:this.pageID,
			_borderColor:this.borderColor
		};
		var params = {
			wmode:wmodestring
		};
		var attributes = {};

		swfobject.embedSWF("http://viewer.zmags.com/gfx/r_singleFront.swf",this.name, this.width, this.height, "9.0.0","expressInstall.swf", flashvars, params, attributes);
	}
}

function FullscreenWindow(gotoHTML){
	if(window.screen){
		var hori=screen.availWidth;
		var verti=screen.availHeight;
		window.open(gotoHTML,'zmag'+ Math.round(1099999999*Math.random()), 'width='+hori+',height='+verti+',fullscreen=1,channelmode=1, scrollbars=1,titlebar=1,left='+(0)+',top='+(0));
	}
}
