var Opacity=1;
var OpacityMax=80;
var bar_layer, menu_layer, pic_layer,loading_layer,pic,ad_layer;
var window_w,window_h,menu_w,menu_h;
var NS=false;
var n_img='';
var menu_left_adjusted=false;
var menu_top_adjusted=false;
var timeoutProcess;

function lightup(object, opacity){
if (NS) 
	object.style.MozOpacity=opacity/100
else
	object.style.filter='alpha(opacity='+opacity+')';
}

function GetWindowSize(){
if (document.documentElement && document.documentElement.clientHeight)
{  // Explorer 6 Strict Mode 
window_w = document.documentElement.clientWidth;
window_h = document.documentElement.clientHeight;
}
else if (document.body)
{ // other Explorers 
window_w = document.body.clientWidth;
window_h = document.body.clientHeight;
}
else if (self.innerHeight) 
{// all except Explorer 
window_w = self.innerWidth; 
window_h = self.innerHeight; 
}
}

function CenterElement(ObjID){
GetWindowSize();
var Obj=document.getElementById(ObjID);
var w=Obj.offsetWidth;
var h=Obj.offsetHeight;
var l,t;
l=(w<=window_w)?(window_w-w)/2:0;
t=(h<=window_h)?(window_h-h)/2:0;
Obj.style.left=Math.round(l)+"px";
Obj.style.top=Math.round(t)+"px";
}

function AdjustElementsPos(){
CenterElement('loading_layer');
if (bar_layer.style.visibility=="visible") 
CenterElement('menu_layer');
CenterElement('pic_layer');
}

function showbar(){
CenterElement('menu_layer');
bar_layer.style.visibility="visible";
Opacity=OpacityMax;
lightup(bar_layer,Opacity);
}

function hidebar(){
if (Opacity>0) {
 Opacity=Opacity-5;
 lightup(bar_layer,Opacity);
 setTimeout("hidebar()",20);
 }
else{
 bar_layer.style.visibility="hidden";
 Opacity=0;
 menu_left_adjusted=false;
 menu_top_adjusted=false; 
 }
}

function GetCRC32(){
var url = location.href;
var offset = url.indexOf("/",8)+1;
n_img= url.substring(offset,offset+8);
}

function initialize()
{
NS = (navigator.appName=="Netscape")?true:false;
GetCRC32();
GetWindowSize();
window.onresize=AdjustElementsPos;
bar_layer=document.getElementById('bar_layer');
pic=document.getElementById('pic');
ad_layer=document.getElementById('ad_layer');
pic_layer=document.getElementById('pic_layer');
loading_layer=document.getElementById("loading_layer");
loading_layer.innerHTML="LOADING...";
lightup(loading_layer,50);
CenterElement("loading_layer");
if (NS) pic.onload=setLayerAttr
else pic.onreadystatechange=setLayerAttr;
pic.onerror=picError;
readWidth();
pic.src = "pic/"+n_img;
document.onmousemove = TransparentAD;
}

function picError(){
clearTimeout(timeoutProcess);
loading_layer.style.color="#FF0000";
loading_layer.innerHTML='READ ERROR';
CenterElement("loading_layer");
}

function readWidth(){
if ((pic.offsetWidth==0) || (!NS && pic.offsetWidth==28 && pic.offsetHeight==30)){
	timeoutProcess=setTimeout("readWidth()",10);
	return false;
	}
loading_layer.innerHTML+=" ["+pic.offsetWidth+"x"+pic.offsetHeight+"]";
window.document.title+=" ["+pic.offsetWidth+"x"+pic.offsetHeight+"]";
pic_layer.style.visibility="visible";
AdjustElementsPos();
}

function setLayerAttr(){
if (!NS && pic.readyState!="complete") return false;
clearTimeout(timeoutProcess);
pic_layer.style.visibility="visible";
loading_layer.style.visibility="hidden";
AdjustElementsPos();
}

function GotoFlashPage(){
location.href="http://inspic.com/"+n_img+"f";
}
function VisitURL(URL){
location.href=URL;
}

function FlashPic(){
var url = location.href;
var offset = url.indexOf("/",8)+1;
var n_img= url.substring(offset,offset+8);
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%" id="flashpic" align="middle">  <param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="flash/flashpic.swf?pic_id='+n_img+'" /><embed src="flash/flashpic.swf?pic_id='+n_img+'" width="100%" height="100%" name="flashpic" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

function TransparentAD(evt) {
if (bar_layer.style.visibility=="visible") return;
evt = evt || window.event;
if (evt.pageY)
y = evt.pageY
else
y = evt.clientY;
if (y < 100){
	ad_layer.style.visibility = "visible";
}
else
	ad_layer.style.visibility = "hidden";
}