//-------shading screen-------------
var value = 0;
function setOpacity() {
	value += .3;
	$('#shading').css('width','100%');
	$('#shading').css('height',$(document).height());
	$('#shading').show();
	$('#shading').css('opacity',value/10);
	$('#shading').css('filter','alpha(opacity=' + value*10 + ')');
	myTimeout = setTimeout("setOpacity()", 1);
	
	if ((value/10) >= .5)
		clearTimeout(myTimeout);
}

function removeOpacity(){
	value -= .3;
	myTimeout2 = setTimeout("removeOpacity()", 1);
	$('#shading').css('opacity',value/10);
	$('#shading').css('filter','alpha(opacity=' + value*10 + ')');
	
	if ((value/10) <= 0) {
		$('#shading').hide();
		clearTimeout(myTimeout2);
	}
}
//-------tooltip-------------
var offxp=-60;
var offyp=-25;
var ie=document.all;
var ns6=document.getElementById && !document.all;
var ehint=false;
var tipobj;
	
function ietb(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function shint(thetext){
	if (ns6||ie){
		w=thetext.length*8;
		tipobj.style.width=w+"px";
		tipobj.innerHTML=thetext;
		ehint=true;
		offxp=-1*w;
		return false;
	}
}
function phint(e){
	if (ehint){
		var obj=ietb();
		var curX=(ns6)?e.pageX : event.x+obj.scrollLeft;
		var curY=(ns6)?e.pageY : event.y+obj.scrollTop;
		var rightedge=ie&&!window.opera? obj.clientWidth-event.clientX-offxp : window.innerWidth-e.clientX-offxp-20;
		var bottomedge=ie&&!window.opera? obj.clientHeight-event.clientY-offyp : window.innerHeight-e.clientY-offyp-20;
		var leftedge=(offxp<0)? offxp*(-1) : -1000;
		if (rightedge<tipobj.offsetWidth) tipobj.style.left=ie? obj.scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px";
		else if (curX<leftedge) tipobj.style.left="5px";
			else tipobj.style.left=curX+offxp+"px";
		if (bottomedge<tipobj.offsetHeight) tipobj.style.top=ie? obj.scrollTop+event.clientY-tipobj.offsetHeight-offyp+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offyp+"px";
		else tipobj.style.top=curY+offyp+"px";
		tipobj.style.visibility="visible";
	}
}
function hhint(){
	if (ns6||ie){
		ehint=false;
		tipobj.style.visibility="hidden";
		tipobj.style.left="-1000px";
		tipobj.style.width='';
	}
}
document.onmousemove=phint;

$(document).ready(function () {
	$('img.icon').hover(
		function(){$(this).animate({width:'150px',height:'60px',left:'-20px',top:'0px'}, 300);},
		function(){$(this).animate({width:'180px',height:'72px',left:'0px',top:'-12px'}, 200);}
	);
	$('.pi').wrap('<div class="co"><div class="fr"></div></div>');
	$('.shadow').wrap('<div class="sh-right"><div class="sh-bottom"><div class="sh-corner"></div></div></div>');
	$('.shadow').each(function(){
		w=parseInt($(this).css('width'))+8;
		h=parseInt($(this).css('height'))+8;
		$(this).parent().css('height', h+'px').parent().parent().css('width', w+'px');
	});
	
	//if pano page
	if($('#pano-shower').length>0){
		var qty=getCookie("panorama_qty");
		if(!qty) qty='low';
		// quality type available
		if($('#select-pano-viewer option[value="'+qty+'"]').length>0)
			$('#select-pano-viewer').val(qty);
		else qty=$("select option:selected").val();
		// show pano
		showPano(qty, p_id);
		// quality changer
		$('#select-pano-viewer').change(function(){qtyPano($(this).val())});
		// comment form load
		$('#comment-form').html('<div align="center"><img src="/images/loading.gif"></div>');
		$('#comment-form').load('/ajax/pano/form_comment.php');
	}
	
	$('#cell-logo > img').click(function(){location=location.protocol+'//'+location.hostname;});
	// hint 
	tipobj=document.getElementById("hint");
});
