// JavaScript Document
<!--
var px2num = function(px){
	return parseFloat(px.replace("px",""));
};

var check_clipping = function(widget,second){
	
	var w_l = px2num(widget.css("left")) + px2num(widget.css("width"));	
//	var w_lr = px2num(widget.css("left")) + px2num(widget.css("width"));	
	var w_lz = px2num(widget.css("left"));
	var w_t = px2num(widget.css("top")) + px2num(widget.css("height"));		
//	var w_tr = px2num(widget.css("top")) + px2num(widget.css("height"));		
	var w_tz = px2num(widget.css("top"));
	
	var screen_d = centerThis($('#dummy'));

	var mod = (second)? "2":"";
	
	$('.checker'+mod).hide();

	if(w_l <= 0 && w_t <= 0){
		$('#topleft_check'+mod).show();
		$('#left_check'+mod).css({top:1,left:1});
		$('#top_check'+mod).css({top:1,left:1});
	}else if(w_lz+75 >= screen_d.w && w_tz+25 >= screen_d.h){
		$('#bottomright_check'+mod).show();
		$('#right_check'+mod).css({top:1,left:(screen_d.w-75)});
		$('#bottom_check'+mod).css({top:(screen_d.h-50),left:1});
	}else if(w_lz+75 >= screen_d.w && w_t <= 0){
		$('#topright_check'+mod).show();
		$('#right_check'+mod).css({top:1,left:(screen_d.w-75)});
		$('#top_check'+mod).css({top:1,left:1});
	}else if(w_l <= 0 && w_tz+25 >= screen_d.h){
		$('#bottomleft_check'+mod).show();
		$('#left_check'+mod).css({top:1,left:1});
		$('#bottom_check'+mod).css({top:(screen_d.h-50),left:1});
	}else if(w_l <= 0){
		$('#left_check'+mod).show();
		$('#left_check'+mod).css('top',w_t - (px2num(widget.css("height"))/2) - 25 );
		if(px2num($('#left_check'+mod).css("top")) < 0 ){
			$('#left_check'+mod).hide();
			$('#topleft_check'+mod).show();
		}else if(px2num($('#left_check'+mod).css("top"))+55 > screen_d.h ){
			$('#left_check'+mod).hide();
			$('#bottomleft_check'+mod).show();
		}

	
	}else if(w_lz >= screen_d.w){
		$('#right_check'+mod).show();
		$('#right_check'+mod).css('top',w_t - (px2num(widget.css("height"))/2)-10 );
		if(px2num($('#right_check'+mod).css("top")) < 0 ){
			$('#right_check'+mod).hide();
			$('#topright_check'+mod).show();
		}else if(px2num($('#right_check'+mod).css("top"))+55 > screen_d.h ){
			$('#right_check'+mod).hide();
			$('#bottomright_check'+mod).show();
		}

	
	}else if(w_t <= 0){
		$('#top_check'+mod).show();
		$('#top_check'+mod).css('left',w_l - (px2num(widget.css("width"))/2) - 25 );
		if( px2num($('#top_check'+mod).css("left")) < 0){	
			$('#top_check'+mod).hide();
			$('#topleft_check'+mod).show();
		}else if(px2num($('#top_check'+mod).css("left"))+75 > screen_d.w){	
			$('#top_check'+mod).hide();
			$('#topright_check'+mod).show();
		}
	}else if(w_tz >= screen_d.h){
		$('#bottom_check'+mod).show();
		$('#bottom_check'+mod).css('left',w_l - (px2num(widget.css("width"))/2) - 25 );
		if( px2num($('#bottom_check'+mod).css("left")) < 0){	
			$('#bottom_check'+mod).hide();
			$('#bottomleft_check'+mod).show();
		}else if(px2num($('#bottom_check'+mod).css("left"))+75 > screen_d.w){	
			$('#bottom_check'+mod).hide();
			$('#bottomright_check'+mod).show();
		}
	}
	
};

var centerThis = function(widget){
	var center_body_h = 0;
	if($.browser.msie)
		center_body_h = (document.body.clientWidth)/2;
	else
		center_body_h = px2num($('body').css("width"))/2;		
	
	var center_widget_h = center_body_h - px2num(widget.css("width"))/2;
	//alert(center_widget);

	//var center_body_v = px2num($('body').css("height"))/2;
	var center_body_v = window.innerHeight/2;
	if(!(center_body_v > 200))
		center_body_v = 200;
//	var center_widget_v = center_body_v - px2num(widget.css("height"))/2; 
	var center_widget_v = center_body_v - 133; 
	//alert(center_widget);
	widget.css("left",center_widget_h);	
	widget.css("top",center_widget_v);

	return 	{"w":center_body_h*2,"h":center_body_v*2};
};

var keyl = function(widget){
	var wgt_w = px2num(widget.css("width"));
		widget.animate({"left":"-=10"},0);

};
	
var keyr = function(widget){
	var wgt_w = px2num(widget.css("width"));
		widget.animate({"left":"+=10"},0);
};
var keyd = function(widget){
	widget.animate({"top":"+=10"},0);
};
var keyu = function(widget){
	widget.animate({"top":"-=10"},0);
};
var checkKey = function(e){
	document.eee = e.keyCode;
	switch (e.keyCode) {
		case 40:
			if(e.ctrlKey)
				keyd($('#hidden'));
			else
				keyd($('#mobile_box'));
			break;
		case 38:
			if(e.ctrlKey)
				keyu($('#hidden'));
			else
				keyu($('#mobile_box'));
			break;
		case 37:
			if(e.ctrlKey)
				keyl($('#hidden'));
			else
				keyl($('#mobile_box'));
			break;
		case 39:
			if(e.ctrlKey)
				keyr($('#hidden'));
			else
				keyr($('#mobile_box'));
			break;
		default:
			break;
	}      
	check_clipping($('#mobile_box'));
	check_clipping($('#hidden'),true);
	$('.lefter').show();
};

$(document).ready(function(){  
						   	
	if ($.browser.mozilla) {
			//$(document).bind ('keypress',checkKey);
			$(document).keypress (checkKey);
		} else {
			$(document).keydown (checkKey);
			//$(document).bind ('keydown',checkKey);
	} 
});
//-->

