// main javascript for index page. See also indexcookies.js

var loading=0,picloaded=0;

var uboxTop, uboxLeft, dpi;

function getPixIn(){
var sq=document.createElement("DIV");
sq.setAttribute("id","SQUINT")
sq.style.width="1in";
sq.style.height="1in";
//sq.style.backgroundColor="#ffff33";
sq.style.color="#ffff33";
sq.style.fontFamily="arial";
sq.style.fontSize="12px";
document.body.appendChild(sq)
var w=sq.offsetWidth;
var h=sq.offsetHeight;
//alert("h:"+h+"\nw:"+w)
//sq.innerHTML=w+" dpi.";
return w
}


function doOnload(){
	loading=1;
	var winH=document.body.offsetHeight;
	var winW=document.body.offsetWidth;

	if(!document.getElementById("SQUINT")){dpi=getPixIn()}

	var picTop=parseInt(  (winH/2) -  330 ) + "px";

	if(!document.all){picTop=parseInt(  (winH/2) -  330 ) + "px";}

	var picLeft=parseInt(  (winW/2) -  499 ) + "px"
	with(document.getElementById('SPLASHPICALT').style){top = picTop;left = picLeft;visibility='visible'}
	with(document.getElementById('SPLASHPIC').style){top = picTop;left = picLeft}

	uboxTop=parseInt(picTop)+575 +"px"
	uboxLeft=parseInt(picLeft)+300 +"px"

	var pwboxTop=uboxTop;
	var pwboxLeft=parseInt(picLeft)+490 +"px"

	var sbTop=parseInt(picTop)+570 +"px"
	var sbLeft=parseInt(picLeft)+663 +"px"

	var gkTop=parseInt(picTop)+450 +"px"
	var gkLeft=parseInt(picLeft)+658 +"px"

	var remcukTop=parseInt(picTop)+616 +"px"
	var remcukLeft=parseInt(picLeft)+289 +"px"

	var remmyTop=parseInt(picTop)+614 +"px"
	var remmyLeft=parseInt(picLeft)+291 +"px"

	var retailerframeTop=parseInt(picTop)+150 +"px"
	var retailerframeLeft=parseInt(picLeft)+654 +"px"

	var retailbutsTop=parseInt(picTop)+90+"px"
	var retailbutsLeft=parseInt(picLeft)+830 +"px"

	var bfTop=parseInt(picTop)+8+"px"
	var bfLeft=parseInt(picLeft)+867+"px"

	var forgetfulTop;
	//alert(navigator.appVersion);
	if(navigator.appVersion.match(/MSIE/) ) {
		forgetfulTop =parseInt(picTop)+581 +"px"
		if(dpi>100) {forgetfulTop =parseInt(picTop)+575 +"px" }
		}
	else{forgetfulTop =parseInt(picTop)+560 +"px" }

	var forgetfulLeft=parseInt(picLeft)+466 +"px"

  if(document.getElementById('UID')){
	with(document.getElementById('UID').style){top=uboxTop;left=uboxLeft}
	with(document.getElementById('PW').style){top=pwboxTop;left=pwboxLeft}
	if(document.getElementById('dummyInput')){with(document.getElementById('dummyInput').style){top=pwboxTop;left=pwboxLeft}}
	with(document.getElementById('SB').style){top=sbTop;left=sbLeft}
	with(document.getElementById('GUESTCLICK').style){top=gkTop;left=gkLeft}
	with(document.getElementById('REMCUK').style){top=remcukTop;left=remcukLeft;paddingLeft='20px';if(!document.all){width='130px'}}
	with(document.getElementById('REMMY').style){top=remmyTop;left=remmyLeft;zIndex=12;}
	with(document.getElementById('FORGETFUL').style){top=forgetfulTop;left=forgetfulLeft}
  }

	var jvTop=parseInt(picTop)+450 +"px"
	var jvLeft=parseInt(picLeft)+320 +"px"
	//var jvGoButLeft=parseInt(picLeft)+660 +"px" // see GUESTCLICK

	with(document.getElementById('JUSTVISITING').style){top=jvTop;left=jvLeft}

	if(document.getElementById('FINDARETAILER')){
		with(document.getElementById('FINDARETAILER')){
			style.top=retailerframeTop;
			style.left=retailerframeLeft;
			//style.zIndex=99;
			}
		}

	if(document.getElementById('RETAILBUTS')){
		with(document.getElementById('BRIGHTFLOWER').style){top=bfTop;left=bfLeft}
		with(document.getElementById('RETAILBUTS').style){
			top=retailbutsTop;
			left=retailbutsLeft;
			//style.zIndex=99;
			}
		}

//with(document.getElementById('JUSTVISITINGGOBUT').style){top=jvTop;left=jvGoButLeft}// see GUESTCLICK
//document.getElementById('WARNER').innerHTML="picTop:"+picTop+"<br>boxTop"+boxTop+"<br><br>picleft:"+picLeft+"<br>boxLeft"+boxLeft+"<br>";
//mout(document.getElementById('SB'),"pix/go_normal_but.png")
//mout(document.getElementById('GUESTCLICK'),"pix/go_normal_but.png")
//transparIMG(document.getElementById('JUSTVISITING'),"t.gif");

	processCookie(1);

	loading=0


}



var ab=new Image();
ab.src="pix/go_normal_but.png";
var bb=new Image();
bb.src="pix/go_over_but.png";

function mover(o){
	//if(document.all){transparIMG(o,bb.src)}
	//else{
	//	o.src="pix/go_over_but.png"
		//}
}

function mout(o){
	//if(document.all){transparIMG(o,ab.src)}
	//else{
	//	o.src="pix/go_normal_but.png"
		//}
}

function transparIMG(obj,imname){
return
imname=imname.replace(/.*\//, "");
//alert(obj.id+" - "+imname)
if(document.all){
	var sr="pix/"+imname;
	obj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+sr+", sizingMethod='scale')"
}
else{return}
}


function checkAndSub(){

	if(document.getElementById('UID').value.match(/Enter your/) ){alert("Please enter your username");return}
	else if(!document.getElementById('UID').value || document.getElementById('UID').value.length <7){
		alert("Your username should be at least 7 characters long");
		return
	}

	//else if(document.getElementById('dummyInput').value.match(/Enter your/) ){alert("Please enter your password");return}
	else if(!document.getElementById('PW').value || document.getElementById('PW').value.length <7 ){alert("Your password should be at least 7 characters long");return}

else{document.forms[0].submit()}

}

function clearField(o){
	if( o.value.match(/password/i)  ){
			o.setAttribute("type","password")
		}
	if(o.value.match(/user name|password/i)){
		o.value=""
		}
}

function showLogins(){
	if(im.id=="SPLASHPIC" && document.getElementById('UID') ){
	with(document.getElementById('UID').style){display="block"}
	with(document.getElementById('PW').style){visibility="visible"}
	if(document.getElementById('dummyInput')){with(document.getElementById('dummyInput').style){visibility='visible'}}
	with(document.getElementById('SB').style){display="block"}
	with(document.getElementById('REMCUK').style){display='block'}
	with(document.getElementById('REMMY').style){display='block'}
    with(document.getElementById('FORGETFUL').style){display='block'}
   document.getElementById('GUESTCLICK').style.visibility="visible"
   document.getElementById('JUSTVISITING').style.visibility="visible"
   // document.getElementById('JUSTVISITINGGOBUT').style.visibility="visible"
	}
}


var bf;
var im;
var op;

function fadeInSplash(im,op){ //called only once a page has loaded...

	self.op=op;
	self.im=im;

	var splashim = im; //document.getElementById('SPLASHPIC');

	if(splashim=="undefined"){setTimeout("fadeInSplash(im,op)",1000);return}

	else{

		try{splashim.style.visibility='visible'	 }catch(e){}

		}

//	alert(bod.innerHTML)
	var reportedOpacity=0;

	if(document.all){
		reportedOpacity=splashim.style.filter;
		if(reportedOpacity.match(/\=100/)){
		//alert("returning - already at 100")
		showLogins()
			return
			}
		splashim.style.filter="alpha(opacity="+op+")"
	//	alert(bod.style.filter)
	}
	else{
		reportedOpacity=splashim.style.opacity;
		if(reportedOpacity==1){
		//alert("returning - already at 100")

		showLogins();
			return
			}
		splashim.style.opacity=parseFloat(op/100)}

if(op<91){
	op=parseInt(op+10);
	self.op=op;
	//alert(op)
	setTimeout("fadeInSplash(im,op)",100);
	}
	else{
		op=10;self.op=op;

		if(im.id.match(/ALT/)){



		}

		showLogins()
} //reset for next page


} // end func fadeIn

var flashCount=0;

function flashFlower(){

	bf=document.getElementById('BRIGHTFLOWER');
	if(document.all){bf.style.filter="alpha(opacity=90)"} else{bf.style.opacity=.9}

			setTimeout("document.getElementById('BRIGHTFLOWER').style.display='block'",1000)
			setTimeout("document.getElementById('BRIGHTFLOWER').style.display='none'",1100)

			setTimeout("document.getElementById('BRIGHTFLOWER').style.display='block'",1200)
			setTimeout("document.getElementById('BRIGHTFLOWER').style.display='none'",1300)

			setTimeout("document.getElementById('BRIGHTFLOWER').style.display='block'",1400)
			setTimeout("document.getElementById('BRIGHTFLOWER').style.display='none'",1500)

			setTimeout("document.getElementById('BRIGHTFLOWER').style.display='block'",1600)
			setTimeout("document.getElementById('BRIGHTFLOWER').style.display='none'",1700)

			setTimeout("document.getElementById('BRIGHTFLOWER').style.display='block'",1800)
			setTimeout("document.getElementById('BRIGHTFLOWER').style.display='none';flashCount++;if(flashCount<6){flashFlower()}",3000)

}

function fI(){

setTimeout("fadeInSplash(document.getElementById('SPLASHPIC'),10)",1000)
if(document.all){setTimeout("flashFlower()",3000)}
else{setTimeout("flashFlower()",3000)}

}

function fIA(){
setTimeout("fadeInSplash(document.getElementById('SPLASHPICALT'),10)",3000)
}


var firstTime=1;

function changeTextBox(obj){
		obj.parentNode.removeChild(obj);
		with(document.getElementById('PW')){
			style.visibility="visible"
			focus()
		}
		return true
}

var ima,opa;
function fadeInFlower(ima,opa){
opa+=10;
self.ima=ima;self.opa=opa;
if(opa<100){
	//alert(opa)
	setOpacity(ima,opa);
	setTimeout("fadeInFlower(ima,opa)",200)
	}
	else{setTimeout("alert(22);fadeOutFlower(ima,100)",500)}
}

function fadeOutFlower(ima,opa)	{
opa-=10;
self.ima=ima;self.opa=opa;
if(opa>0.1){
	//alert(opa)
	setOpacity(ima,opa) ;
	setTimeout("fadeOutFlower(ima,opa)",200)
	}
}

function setOpacity(ima,opa){
if(document.all){ima.style.filter="alpha(opacity="+opa+")"}
else{
	var littleopa=opa/100;
	ima.style.opacity=littleopa
	}
}


