var pos=0;
var maxpos=99999999999999;

this.pngfix = function() {
	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	if (jQuery.browser.msie && (ie55 || ie6)) {		
		$("*").each(function(){
			var bgIMG = $(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				$(this).css('background-image', 'none');
				$(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='crop')";
			};
		});
	};		
};

this.init = function() {
		//pos++;
	pngfix();
};

function runEffect(){
	//get effect type from 
	var selectedEffect = 'blind';//blind,bounce.clip,drop,explode,clip
	//run the effect
	var options = {};
	//$('#body').effect(selectedEffect,options,500,callback);
	$('#body').effect('blind');
		};

//callback function to bring a hidden box back
function callback(){
	setTimeout(function(){
		window.close();
	}, 1000);
};

function shakeAndBakeClose(n) {
	if (parent.moveBy) {
	for (i = 60; i > 0; i--) {
		for (j = n; j > 0; j--) {
			parent.moveBy(0,i);
			parent.moveBy(i,0);
			parent.moveBy(0,-i);
			parent.moveBy(-i,0);
			 }
		  }
	   		//runEffect();
			//return false;
	   var thetimer=setTimeout(function(){
		window.close();
	}, 1000);
	   }
	  
	}	

function setPosition(){
	$("#globalErrorPanel").css("background-position", pos+"px "+pos+"px");
	pos++;
}

$(document).ready(function(){			   
	//init();
	var timer = setInterval('setPosition()', 30); 
	$(document).bind('SHOW_SHOWCASE',null,function(e){
		$('#content').fadeIn();
		$.scrollTo('50%', 1500, { easing: 'elasout' });	
	});
	$(document).bind('HIDE_SHOWCASE',null,function(e){
		$('#content').fadeOut();
	});
	$(document).bind('DISPLAY_ERROR_MESSAGE', null, function(e) {
    $('.errorPanel').slideToggle('slow');
  	//setTimeout(function() { $('.errorPanel').slideToggle('slow'); }, 5000);
	});
	
	$(document).bind('CLOSE_BROWSER',null,function(e){
			clearInterval(timer);
			$('#globalErrorPanel').slideToggle('slow');
			var shaker=setTimeout('shakeAndBakeClose(2);',1000);									   
	});
	$(document).bind('CANCEL_BROWSER_CLOSE',null,function(e){
		$('.errorPanel').slideToggle('slow');
	});
});
