/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;





/**
 * Seenly.com Javascript Library
 * Copyright David Verhasselt 2007
 *
 * DO NOT USE, COPY, DERIVE OR PRINT WITHOUT PERMISSION
 */


/**
 * Load SWFObject.js
 */
var headID = document.getElementsByTagName("head")[0];
/*var newScript = document.createElement("script");
newScript.type = "text/javascript";
newScript.src = "js/swfobject.js";
headID.appendChild(newScript);*/








/**
 * Load CSS
 */

function xAttachEvent(target, eventType, method)
{
	if (target.addEventListener)		// Opera, Mozilla, Netscape
	{
		target.addEventListener(eventType, method, false);
	}

	else					// IE
	{
		target.attachEvent("on" + eventType, method);
	}
}

 
function loadStyleSheet(filename)
{
	var cssNode = document.createElement("link");
	cssNode.type = "text/css";
	cssNode.rel = "stylesheet";
	cssNode.href = "css/" + filename;
	cssNode.media = "screen";
	headID.appendChild(cssNode);
}

loadStyleSheet("seenly.css");

if (navigator.userAgent.indexOf("Opera") != -1)
{
	loadStyleSheet("seenly-opera.css");
}

else if (navigator.userAgent.indexOf("MSIE") != -1)
{
	loadStyleSheet("seenly-ie.css");
}


/**
 * Seenly Container Object
 * Global Object to contain the Seenly instances
 */
function SeenlyFactory()
{
	function compatible()
	{
		return deconcept.SWFObjectUtil.getPlayerVersion().major == "9" || deconcept.SWFObjectUtil.getPlayerVersion().major == "10" ;
	}
	

	/**
	 * Create a Seenly object with the given name
	 */
	function create()
	{
		if (!compatible())
		{
			return null;
		}

		this[this.count] = new Seenly(this.count);
		this.count++;

		return this[this.count -1];
	}

	this.count = 0;
	this.compatible = compatible;
	this.create = create;
}



/**
 * Global SeenlyContainer Variable, constant for the SWF to call
 */
var SeenlyContainer = new SeenlyFactory();






/**
 * Create a Seenly Object
 */
function Seenly(seenlyId)
{
	/**
	 * Misc Function to create another that calls some function
	 */
	this.bindFunction = function(method, obj)
	{
		var temp = function()
		{
			return method.apply(obj, arguments);
		};

		return temp;
	};

	/**
	 * Misc Function to create another that calls some function using predefined arguments
	 */
	this.bindFunctionArgs = function(method, obj)
	{
		var args = [];

		for (var i=0; i<arguments.length-2; i++)
		{
			args[i] = arguments[i+2];
		}

		var temp = function()
		{
			return method.apply(obj, args);
		};

		return temp;
	};

	/**
	 * Force redraw on safari
	 */
	this.forceRedraw = function()
	{
		if (navigator.userAgent.indexOf("Safari") != -1)
		{
			this.divs.divRedraw.innerHTML += " ";
		}
	};

	/**
	 * Initialize Settings
	 */
	this.setDimension = function(newWidth, newHeight)
	{
		this.width = newWidth;
		this.height = newHeight
	};

	/**
	 * Generates the URL to the show-page
	 */
	this.getShowPic = function()
	{
		return "http://guinea.seenly.com/pic.php?show=" + this.url;
	};


	/**
	 * Generate random id for Plumbing
	 */
	this.generatePlumbingId = function()
	{
		this.plumbingId = Math.random().toString(10);
	};


	/**
	 * Bind the Seenly-stuff to the appropriate div
	 */
	this.write = function(divId)
	{
		var containingDiv = document.getElementById(divId);

		if (containingDiv == null)
		{
			return false;
		}

		this.divs = new Object();
		
		this.parentDiv = this.create_div("divSeenlyContainer");

		if (this.galleryEnabled)
		{
			this.parentDiv.style.width = "750px";
		}
		else
		{
			this.parentDiv.style.width = "500px";
		}

		containingDiv.appendChild(this.parentDiv);


		this.create_swfs();

		// SAFARI DEBUG
		var divRedraw = this.create_div("divRedraw");				this.divs.divRedraw = divRedraw;
		this.parentDiv.appendChild(divRedraw);

		// Create all the necessary div's
		var divDisplay = this.create_div("divSeenlyDisplay");			this.divs.divDisplay = divDisplay;			divDisplay.seenly_visible = true;
	
		if (this.galleryEnabled)
		{
			var divGallery = this.create_div("divSeenlyGallery");			this.divs.divGallery = divGallery;			this.hide_loading_div(divGallery);
		}

		else
		{
			this.divs.divGallery = null;
		}

		var divWebcamButtons = this.create_div("divSeenlyWebcamButtons");	this.divs.divWebcamButtons = divWebcamButtons;		this.hide_loading_div(divWebcamButtons);
		var divPhotoButtons = this.create_div("divSeenlyPhotoButtons");		this.divs.divPhotoButtons = divPhotoButtons;		this.hide_loading_div(divPhotoButtons);
		var divInfoBox = this.create_div("divSeenlyInfoBox");			this.divs.divInfoBox = divInfoBox;
		var divEffectButton = this.create_div("divSeenlyEffectButton");		divEffectButton.innerHTML = "Select Effect";		divEffectButton.className = "seenlyBottomBarButton";
		xAttachEvent(divEffectButton, "click", this.bindFunctionArgs(this.showEffectPage, this));


		var divButtonShutter = this.create_div("divSeenlyButtonShutter");
		var divButtonRetry = this.create_div("divSeenlyButtonRetry");
		var divButtonUse = this.create_div("divSeenlyButtonUse");
		var divButtonOr = this.create_div("divSeenlyButtonOr");


		// Put them in their containers
		divWebcamButtons.appendChild(divButtonShutter);
		divWebcamButtons.appendChild(divEffectButton);


		divPhotoButtons.appendChild(divButtonUse);
		divPhotoButtons.appendChild(divButtonOr);
		divPhotoButtons.appendChild(divButtonRetry);
		
		// Add them to the document
		this.parentDiv.appendChild(divDisplay);
		this.parentDiv.appendChild(divWebcamButtons);
		this.parentDiv.appendChild(divPhotoButtons);
		this.parentDiv.appendChild(divInfoBox);
		if (this.galleryEnabled)
		{
			this.parentDiv.appendChild(divGallery);
		}

		// Create other divs
		this.createAfterEffects();


		// Fill them
		this.soDisplay.write(divDisplay.id);

		if (this.galleryEnabled)
		{
			this.soGallery.write(divGallery.id);
		}
		this.soButtonShutter.write(divButtonShutter.id);
		this.soButtonRetry.write(divButtonRetry.id);
		this.soButtonUse.write(divButtonUse.id);
		divButtonOr.innerHTML = "or";
	};

	this.hide_loading_div = function(divElement)
	{
		if (divElement == null)
		{
			return;
		}

		if (this.isIE)
		{
			divElement.style.position = "relative";
			divElement.style.left = "-10000px";
			divElement.seenly_visible = false;
		}

		else
		{
			this.hide_div(divElement);
		}
	};

	this.hide_loaded_div = function(divElement)
	{
		if (divElement == null)
		{
			return;
		}

		if (this.isIE)
		{
			this.hide_div(divElement);
			divElement.style.left = "0px";
		}
	};

	this.hide_div = function(divElement, implicit)
	{
		if (divElement == null)
		{
			return;
		}

		divElement.style.visibility = "hidden";
		if (!implicit)
		{
			divElement.seenly_visible = false;		// Save state for when generally hiding/showing seenly
		}

		if ((navigator.userAgent.indexOf("Safari") != -1) && (!divElement.style.position == "absolute"))
		{
			divElement.style.position = "relative";
			divElement.style.left = "-200px";		// Safari Fix
		}

		this.forceRedraw();
	};

	this.show_div = function(divElement, implicit)
	{
		if (divElement == null)
		{
			return;
		}

		if (!implicit)
		{
			divElement.seenly_visible = true;		// Save state for when generally hiding/showing seenly
		}

		if ((navigator.userAgent.indexOf("Safari") != -1) && (!divElement.style.position == "absolute"))	
		{
			divElement.style.left = "0px";			// Safari Fix
			divElement.style.visibility = "visible";
		}

		else
		{
			divElement.style.visibility = "visible";
		}

		this.forceRedraw();
	};

	this.create_swfs = function()
	{
		this.soDisplay = new SWFObject("swf/display.swf", "seenlyDisplay", "480", "360", "9", "#FFFFFF");
			
		this.soDisplay.addParam("allowScriptAccess", "always");
		this.soDisplay.addVariable("seenlyId", this.seenlyId);
		this.soDisplay.addVariable("width", this.width);
		this.soDisplay.addVariable("height", this.height);
		this.soDisplay.addVariable("plumbingId", this.plumbingId);
		if (this.galleryEnabled)
		{
			this.soDisplay.addVariable("galleryEnabled", "true");
		}

		else
		{
			this.soDisplay.addVariable("galleryEnabled", "false");
		}
		this.soDisplay.addParam("name", "seenlyDisplay");

		
		if (this.galleryEnabled)
		{

			this.soGallery = new SWFObject("swf/gallery.swf", "seenlyGallery", "750", "120", "9", "#DADADA");

			this.soGallery.addParam("allowScriptAccess", "always");
			this.soGallery.addVariable("width", this.width);
			this.soGallery.addVariable("height", this.height);
			this.soGallery.addVariable("plumbingId", this.plumbingId);
		}


		this.soButtonUse = new SWFObject("swf/btn_use.swf", "seenlyButtonUse", "120", "30", "9", "#000000");

		this.soButtonUse.addParam("allowScriptAccess", "always");
		this.soButtonUse.addVariable("plumbingId", this.plumbingId);



		this.soButtonRetry = new SWFObject("swf/btn_retry.swf", "seenlyButtonRetry", "120", "30", "9", "#000000");

		this.soButtonRetry.addParam("allowScriptAccess", "always");
		this.soButtonRetry.addVariable("plumbingId", this.plumbingId);



		this.soButtonShutter = new SWFObject("swf/btn_shutter.swf", "seenlyButtonShutter", "120", "30", "9", "#000000");

		this.soButtonShutter.addParam("allowScriptAccess", "always");
		this.soButtonShutter.addVariable("plumbingId", this.plumbingId);
	};
		
		
	this.create_div = function(divId)
	{
		var newDiv = document.createElement("div");
		newDiv.id = divId;

		return newDiv;
	};


	this.create_span = function(spanId)
	{
		var newSpan = document.createElement("span");
		newSpan.id = spanId;

		return newSpan;
	};

	
	this.create_anchor = function(anchorId)
	{
		var newAnchor = document.createElement("a");
		newAnchor.id = anchorId;
		newAnchor.href = "#";

		return newAnchor;
	}
	

	/**
	 * Start seenly if it's loaded, or set seenly up so that it starts when fully loaded
	 */
	this.start = function()
	{
		if (this.loaded)
		{
			document.getElementById("seenlyDisplay").seenlyStart();
		}

		this.starting = true;
	};

	/**
	 * Stop seenly
	 */
	this.stop = function()
	{
		if (this.loaded && this.starting)
		{
			document.getElementById("seenlyDisplay").seenlyStop();
		}

		this.starting = false;
	};

	/**
	 * Sets a property in the SWF
	 */
	this.setProperty = function(name, value)
	{
		if (this.loaded)
		{
			document.getElementById("seenlyDisplay").setProperty(name, value);
		}

		else
		{
			if (!this.properties)
			{
				this.properties = new Object();
			}

			this.properties[name] = [name,value];
		}
	};

	/**
	 * Show a effect-page
	 */
	this.showEffectPage = function(page)
	{
		if (typeof(page) == 'undefined')
		{
			page = this.currentEffectPage;
		}

		if (!this.showingEffectPage)
		{
			this.showingEffectPage = true;
			this.hide_div(this.divs.divWebcamButtons);
			this.hide_div(this.divs.divPhotoButtons);

			this.createEffectPager(3);

			document.getElementById("seenlyDisplay").showEffectPage(page);
		}

		else if (this.currentEffectPage != page)
		{
			var previousPage = this.currentEffectPage;
			this.currentEffectPage = page;
			document.getElementById("divSeenlyEffectPager" + parseInt(previousPage, 10)).className = "passive";
			document.getElementById("divSeenlyEffectPager" + parseInt(page, 10)).className = "active";
			document.getElementById("seenlyDisplay").showEffectPage(page);
		}

		this.currentEffectPage = page;
		document.getElementById("divSeenlyEffectPager" + parseInt(page, 10)).className = "active";
	};

	/**
	 * Cancel effect-page
	 */
	this.cancelEffectPage = function()
	{
		if (this.showingEffectPage)
		{
			document.getElementById("seenlyDisplay").cancelEffectPage();
		}
	}

	/**
	 * Flip the snap
	 */
	this.flip = function()
	{
		document.getElementById("seenlyDisplay").flip();
	}


	/**
	 * Hide seenly
	 */
	this.hide = function()
	{
		for (var divIndex in this.divs)
		{
			if (this.divs[divIndex])
			{
				this.hide_div(this.divs[divIndex], true);
			}
		}
	};

	/**
	 * Show seenly
	 */
	this.show = function()
	{
		// Warn that Seenly is shown again
	//	document.getElementById("seenlyDisplay").seenlyShow();

		for (var divIndex in this.divs)
		{
			if (this.divs[divIndex])
			{
				if (this.divs[divIndex].seenly_visible)
				{
					this.show_div(this.divs[divIndex], true);
				}
			}
		}
	};

	/**
	 * Create the after-effect buttons
	 */
	this.createAfterEffects = function()
	{
		var afterEffectsDiv = this.create_div("divSeenlyAfterEffects");
		var aeFlipDiv = this.create_div("divSeenlyAEFlip");

		aeFlipDiv.innerHTML = "Flip";
		aeFlipDiv.className = "seenlyAfterEffectsButton";
		xAttachEvent(aeFlipDiv, "click", this.bindFunction(this.flip, this));

		afterEffectsDiv.appendChild(aeFlipDiv);
		this.divs.divAfterEffects = afterEffectsDiv;
		this.parentDiv.appendChild(afterEffectsDiv);
	}


	/**
	 * Create the countdown ETA
	 */
	this.createCountDown = function(totalSeconds)
	{
		var countDownDiv = this.create_div("divSeenlyCountDown");

		var numberDiv;
		
		for (var i=totalSeconds; i>0; i--)
		{
			numberDiv = this.create_div("divSeenlyCountDown" + parseInt(i, 10));
			numberDiv.className = "passive";
			numberDiv.innerHTML = i;
			numberDiv.style.left = "" + parseInt((3-i)*45 + 5, 10) + "px";
			countDownDiv.appendChild(numberDiv);
		}

		var smileDiv = this.create_div("divSeenlyCountDownSmile");
		smileDiv.innerHTML = "Smile!";
		smileDiv.style.right = "0px";
		countDownDiv.appendChild(smileDiv);

		countDownDiv.childNodes[0].className = "active";
		this.divs.divCountDown = countDownDiv;

		this.divs.divInfoBox.appendChild(countDownDiv);

		this.showInfoBox();
	};


	/**
	 * Display choices in design
	 */
	this.createEffectPager = function(totalPages)
	{
		var effectPagerDiv = this.create_div("divSeenlyEffectPager");
		var cancelDiv = this.create_div("divSeenlyEffectPagerCancel");

		cancelDiv.innerHTML = "Cancel";	
		cancelDiv.className = "seenlyBottomBarButton";	
		cancelDiv.style.left = "0px";
		xAttachEvent(cancelDiv, "click", this.bindFunction(this.cancelEffectPage, this));		
		effectPagerDiv.appendChild(cancelDiv);


		var effectPageDiv;

		for (var i=totalPages-1; i>=0; i--)
		{
			effectPageDiv = this.create_div("divSeenlyEffectPager" + parseInt(totalPages-i-1, 10));
			effectPageDiv.className = "passive";
			effectPageDiv.innerHTML = parseInt(totalPages-i, 10);
			effectPageDiv.style.right = "" + parseInt(i*45, 10) + "px";

			xAttachEvent(effectPageDiv, "click", this.bindFunctionArgs(this.showEffectPage, this, totalPages-i-1));

			effectPagerDiv.appendChild(effectPageDiv);
		}

		this.divs.divEffectPager = effectPagerDiv;

		this.divs.divInfoBox.appendChild(effectPagerDiv);

		this.showInfoBox();
	};

	/**
	 * Create Processing Text
	 */
	this.createProcessingInfo = function()
	{
		var processingInfoDiv = this.create_div("divSeenlyProcessingInfo");
		processingInfoDiv.innerHTML = "<span>Saving...</span>";

		this.divs.divProcessingInfo = processingInfoDiv;
		this.divs.divInfoBox.appendChild(processingInfoDiv);
		this.showInfoBox();
	};

	/** 
	 * Display the infobox
	 */
	this.showInfoBox = function()
	{
		this.show_div(this.divs.divInfoBox);
	};

	/**
	 * Hide the infobox
	 */
	this.hideInfoBox = function()
	{
		this.hide_div(this.divs.divInfoBox);
	};
	
	/**
	 * Position the gallery correctly
	 */
	this.positionGallery = function()
	{
		this.divs.divGallery.style.position = "relative";
		this.divs.divGallery.style.top = "-80px";
	};
		


	/**
	 * Gets called by seenly when it's fully loaded and ready
	 */
	this.call_loaded = function()
	{
		this.loaded = true;

		// Add event handlers to the SWF's
		//document.getElementById("seenlyButtonShutter").addEventListener('mouseout', function() { alert("Button Shutter - Mouse Out"); }, true);
				
		// Return the swf's to their original positions
		this.hide_loaded_div(this.divs.divWebcamButtons);
		this.hide_loaded_div(this.divs.divPhotoButtons);
		this.hide_loaded_div(this.divs.divGallery);


		// Push all property-changes

		for (var property in this.properties)
		{
			this.setProperty(property[0], property[1]);
		}

		if (this.starting)
		{
			this.start();
		}
	};

	/**
	 * Gets called by seenly when a preview is in progress
	 */
	this.call_preview = function(url)
	{
		this.hideInfoBox();
			
		if (url.length == "")
		{
			// Photo isn't saved yet
			this.hide_div(this.divs.divWebcamButtons);
			this.show_div(this.divs.divPhotoButtons);
			this.show_div(this.divs.divAfterEffects);
			this.show_div(this.divs.divGallery);
		}

		else
		{
			// Photo *is* saved
			this.hide_div(this.divs.divWebcamButtons);
			this.show_div(this.divs.divPhotoButtons);
			this.hide_div(this.divs.divAfterEffects);
			this.show_div(this.divs.divGallery);
		}
	};

	/**
	 * Gets called by seenly when a webcam-view is in progress
	 */
	this.call_webcam = function()
	{
		if (this.showingEffectPage)
		{
			this.showingEffectPage = false;
			this.divs.divInfoBox.removeChild(this.divs.divEffectPager);
			this.hideInfoBox();
		}

		this.hide_div(this.divs.divPhotoButtons);
		this.show_div(this.divs.divWebcamButtons);
		this.hide_div(this.divs.divAfterEffects);
		this.show_div(this.divs.divGallery);
	};

	/**
	 * Gets called by seenly when an error is shown (not allowed, not found, unknown). Hides the controls
	 */
	this.call_error = function()
	{
		this.hide_div(this.divs.divPhotoButtons);
		this.hide_div(this.divs.divWebcamButtons);
		this.hide_div(this.divs.divGallery);
		this.hide_div(this.divs.divAfterEffects);
	}

	/**
	 * Gets called by seenly when an error during saving of the pic happened
	 */
	this.call_processerror = function()
	{
		this.hide_div(this.divs.divPhotoButtons);
		this.hide_div(this.divs.divWebcamButtons);
		this.hide_div(this.divs.divAfterEffects);
		this.hide_div(this.divs.divGallery);

		var errorDiv = this.create_div("divSeenlyError");
		errorDiv.innerHTML = "<span>There was an error.</span> <span id=\"spanSeenlyErrorBack\">Back</span>";

		this.divs.divError = errorDiv;
		this.divs.divInfoBox.innerHTML = "";
		this.divs.divInfoBox.appendChild(errorDiv);

		xAttachEvent(document.getElementById("spanSeenlyErrorBack"), "click", this.bindFunctionArgs(function()
		{
			this.hideInfoBox();
			this.divs.divInfoBox.innerHTML = "";
			this.show_div(this.divs.divPhotoButtons);
			this.show_div(this.divs.divGallery);

		}, this));

		this.showInfoBox();

	};

	/**
	 * Gets called when encoding and sending a photo
	 */
	this.call_processing = function()
	{
		this.hide_div(this.divs.divPhotoButtons);
		this.hide_div(this.divs.divWebcamButtons);
		this.hide_div(this.divs.divAfterEffects);
		this.hide_div(this.divs.divGallery);
		
		this.createProcessingInfo();	
	};

	/**
	 * Gets called by seenly when a photo is taken and sent
	 */
	this.call_photo = function(url)
	{
		this.url = url

		this.call_preview(true);

		if (this.divs.divProcessingInfo)
		{
			this.divs.divInfoBox.removeChild(this.divs.divProcessingInfo);
			this.divs.divProcessingInfo = null;
		}

		if (this.event_photo != null)
		{
			this.event_photo(url);
		}
	};

	/**
	 * Gets called to alert us of impending (potential) countdown
	 */
	this.call_startshutter = function(totalSeconds)
	{
		this.hide_div(this.divs.divPhotoButtons);
		this.hide_div(this.divs.divWebcamButtons);
		this.hide_div(this.divs.divAfterEffects);

		//if (totalSeconds)
		//{
			this.createCountDown(totalSeconds);
		//}
	};

	/**
	 * Gets called by seenly to countdown to the specified number of seconds
	 */
	this.call_countdown = function(eta)
	{
		document.getElementById("divSeenlyCountDown" + (eta+1)).className = "passive";
		document.getElementById("divSeenlyCountDown" + eta).className = "active";
	
		this.forceRedraw();
	};

	/**
	 * Gets called by seenly to designate the shutter as being in process
	 */
	this.call_shutterinprogress = function()
	{
		this.hideInfoBox();
		this.divs.divInfoBox.removeChild(this.divs.divCountDown);
		this.divs.divCountDown = null;
	};

	/**
	 * Gets called by seenly when a new effect is selected
	 */
	this.call_effectselected = function(effect)
	{
		this.effectName = effect;
	};


	// Initialize
	this.seenlyId = seenlyId;
	this.loaded = false;
	this.starting = false;
	this.url = "";
	this.showingEffectPage = false;
	this.currentEffectPage = 0;
	this.effectName = "effect_normal";
	this.galleryEnabled = true;
	
	this.isIE = ((navigator.userAgent.indexOf("MSIE") != -1) && (navigator.userAgent.indexOf("Opera") == -1));
	this.width = 480;
	this.height = 360;

	this.generatePlumbingId();


	// Events set by webmaster
	this.event_photo = null;
}
