// JavaScript Document
function LavIDeviceOrientation(appendto){
	this.blocker;
	this.graphic;
	this.appendto = appendto;
	this.initialize();
	this.shown = false;
}
LavIDeviceOrientation.prototype.initialize = function(){
	$(window).scroll($lavdelegate(this, this.onWindowChanged));
	$(window).resize($lavdelegate(this, this.onWindowChanged));
}
LavIDeviceOrientation.prototype.onWindowChanged = function(){
	return;
	if(this.shown){
		try{
			this.graphic.css({top:$(window).scrollTop() + $(window).height() - ($(window).height()/2)-300, left:$(document).width()/2 - 100});
			this.blocker.css({width:$(document).width(), height:$(document).height()});
		}catch(err){
		}
	}
}
LavIDeviceOrientation.prototype.show = function(){
	if(this.shown) return;
	this.shown = true;
	this.blocker = $("<div id='preload_blocker'></div>");
	this.preloadimage = $("<img src='common/images/idevice_rotate.png' border='0' style='margin-top:10px'/>");
	this.preloadimage.css({opacity:.6});
	this.graphic = $("<div id='preload_graphic'></div>");
	this.graphic.append(this.preloadimage);
	this.graphic.css({opacity:0, width:234, height:234, position:"absolute", top:$(window).scrollTop()+($(window).height()/2)-300, left:$(document).width()/2 - 100});
	this.blocker.css({width:$(document).width(), height:$(document).height(), background:"#000000", position:"absolute", top:"0%", left:"0%", opacity:.85});
	this.blocker.css("z-index", 9999999999);
	this.graphic.css("z-index", 99999999999);	
	this.appendto.append(this.blocker);
	this.appendto.append(this.graphic);
	this.graphic.stop().delay(100).animate({opacity:1}, {duration:500, ease:"easeInQuint"});

	
}
LavIDeviceOrientation.prototype.hide = function(){
	/*
	this.blocker.stop().animate({opacity:0}, {duration:100, ease:"easeOutQuad"});
	this.graphic.stop().animate({opacity:0}, {duration:100, ease:"easeOutQuad", complete:$lavdelegate(this, function(){*/
	this.shown = false;
	setTimeout($lavdelegate(this, function(){
		
		try{
			this.graphic.stop();
			$("#"+this.blocker.attr("id")).remove();	
			$("#"+this.graphic.attr("id")).remove();
			this.graphic.remove();
			this.blocker.remove();
			this.blocker = null;
		}catch(err){}	
//	})});
	
								}), 1);
}
LavIDeviceOrientation.prototype.getViewportDimensions = function(ref){
	var o = {};
	if(!$.browser.msie){
		o.width = ref.innerWidth;
		o.height = ref.innerHeight;
	}else{
		if (document.body && document.body.offsetWidth) {
		 winW = document.body.offsetWidth;
		 winH = document.body.offsetHeight;
		}
		if (document.compatMode=='CSS1Compat' && document.documentElement && document.documentElement.offsetWidth) {
		 winW = document.documentElement.offsetWidth;
		 winH = document.documentElement.offsetHeight;
		}
		o.width = winW;
		o.height = winH;	
	}

	return o;
}
