
function showVeil() {
	var interVeil=document.getElementById("interVeil"); //reference veil
	//var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
	var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
	if (document.compatMode=="CSS1Compat") {
		var ie=document.all && !window.opera
		var dom=document.getElementById
		var scroll_top=(ie)? standardbody.scrollTop : window.pageYOffset;
		var scroll_left=(ie)? standardbody.scrollLeft : window.pageXOffset;
		var docwidth=(ie)? document.documentElement.clientWidth : window.innerWidth;
		var docheight=(ie)? document.documentElement.clientHeight: window.innerHeight;
		var docheightcomplete=(document.documentElement.offsetHeight>document.documentElement.scrollHeight)? document.documentElement.offsetHeight : document.documentElement.scrollHeight;
		var docwidthcomplete=(document.documentElement.offsetWidth>document.documentElement.scrollWidth)? document.documentElement.offsetWidth : document.documentElement.scrollWidth;
	} else {
		var ie=document.all && !window.opera
		var dom=document.getElementById
		var scroll_top=(ie)? standardbody.scrollTop : window.pageYOffset;
		var scroll_left=(ie)? standardbody.scrollLeft : window.pageXOffset;
		var docwidth=(ie)? document.body.clientWidth : window.innerWidth;
		var docheight=(ie)? document.body.clientHeight: window.innerHeight;
		var docheightcomplete=(document.body.offsetHeight>document.body.scrollHeight)? document.body.offsetHeight : document.body.scrollHeight;
		var docwidthcomplete=(document.body.offsetWidth>document.body.scrollWidth)? document.body.offsetWidth : document.body.scrollWidth;
	}
	
	//standardbody.style.overflow="hidden";
	//interVeil.style.width=(docwidth+scroll_left)+"px"; //set up veil over page
	//interVeil.style.height=(docheightcomplete+scroll_top)+"px"; //set up veil over page
	interVeil.style.width=(docwidthcomplete)+"px"; //set up veil over page
	interVeil.style.height=(docheightcomplete)+"px"; //set up veil over page
	interVeil.style.left=0; //Position veil over page
	interVeil.style.top=0; //Position veil over page
	interVeil.style.display="block";
	interVeil.style.visibility="visible"; //Show veil over page
	interVeil.style.zIndex=99;
	opacity("interVeil", 0, 80, 500);
};

var fadeInterval;

function hideVeil() {
	opacity("interVeil", 80, 0, 500);
	fadeInterval = setInterval(closeVeil, 500);
}

function closeVeil() {
	var interVeil=document.getElementById("interVeil");
	interVeil.style.width="0px"; 
	interVeil.style.height="0px"; 
	interVeil.style.left=0; 
	interVeil.style.top=0;
	interVeil.style.visibility="hidden";
	interVeil.style.display="none";
	interVeil.style.zIndex=-1;
	var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
	standardbody.style.overflow="auto";
	clearInterval(fadeInterval);
};

function loadwindow_delayed(url,width,height,strWhichWindow,intDelay) {
	
	loadIFrame(url,strWhichWindow);
	setTimeout("loadwindow('"+url+"',"+width+","+height+",'"+strWhichWindow+"')", intDelay);
}

function loadsignupwindow_delayed(url,width,height,strWhichWindow,intDelay) {
	
	loadIFrame(url,strWhichWindow);
	setTimeout("loadsignupwindow('"+url+"',"+width+","+height+",'"+strWhichWindow+"')", intDelay);
}

function loadscreenshotwindow_delayed(url,width,height,strWhichWindow,intDelay) {
	
	loadIFrame(url,strWhichWindow);
	setTimeout("loadscreenshotwindow('"+url+"',"+width+","+height+",'"+strWhichWindow+"')", intDelay);
}

function loadIFrame(url,strWhichWindow) {
	var strID;
	var intLen;
	strID = window.document.location.toString();
	intLen = strID.indexOf(url);
	strID = strID.substring(0, intLen);
	
	document.getElementById(strWhichWindow+"cframe").src=strID+url;
};

function loadwindow(url,width,height,strWhichWindow){

var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
var ie=document.all && !window.opera;
var dom=document.getElementById;
var scroll_top=(ie)? standardbody.scrollTop : window.pageYOffset;
var scroll_left=(ie)? standardbody.scrollLeft : window.pageXOffset;
var docwidth=(ie)? standardbody.clientWidth : window.innerWidth;
var docheight=(ie)? standardbody.clientHeight: window.innerHeight;
//alert("width=" + width + "px height=" + height + "px");
document.getElementById(strWhichWindow).style.display='';
document.getElementById(strWhichWindow).style.width=width+"px";
document.getElementById(strWhichWindow).style.height=height+"px";
document.getElementById(strWhichWindow+"cframe").style.width=width+"px";
document.getElementById(strWhichWindow+"cframe").style.height=height+"px";
document.getElementById(strWhichWindow+"content").style.width=width+"px";
document.getElementById(strWhichWindow+"content").style.height=height+"px";
document.getElementById(strWhichWindow).style.left=((docwidth/2-width/2)+scroll_left)+"px";
	if (((docheight/2-height/2)+scroll_top) < 0) {
		document.getElementById(strWhichWindow).style.top="0px";
	} else {
		document.getElementById(strWhichWindow).style.top=((docheight/2-height/2)+scroll_top)+"px";
	}
}

function loadsignupwindow(url,width,height,strWhichWindow){

var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
var ie=document.all && !window.opera;
var dom=document.getElementById;
var scroll_top=(ie)? standardbody.scrollTop : window.pageYOffset;
var scroll_left=(ie)? standardbody.scrollLeft : window.pageXOffset;
var docwidth=(ie)? standardbody.clientWidth : window.innerWidth;
var docheight=(ie)? standardbody.clientHeight: window.innerHeight;
//alert("width=" + width + "px height=" + height + "px");
document.getElementById(strWhichWindow).style.display='';
document.getElementById(strWhichWindow).style.width=width+"px";
document.getElementById(strWhichWindow).style.height=height+"px";
document.getElementById(strWhichWindow).style.left=((docwidth/2-width/2)+scroll_left)+"px";
document.getElementById(strWhichWindow).style.top="50px";
}

function loadscreenshotwindow(url,width,height,strWhichWindow){

var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
var ie=document.all && !window.opera;
var dom=document.getElementById;
var scroll_top=(ie)? standardbody.scrollTop : window.pageYOffset;
var scroll_left=(ie)? standardbody.scrollLeft : window.pageXOffset;
var docwidth=(ie)? standardbody.clientWidth : window.innerWidth;
var docheight=(ie)? standardbody.clientHeight: window.innerHeight;
//alert("width=" + width + "px height=" + height + "px");
document.getElementById(strWhichWindow).style.display='';
document.getElementById(strWhichWindow).style.width=width+"px";
document.getElementById(strWhichWindow).style.height=height+"px";
if (((docheight/2-height/2)+scroll_top) > 1) {
	document.getElementById(strWhichWindow).style.left=((docwidth/2-width/2)+scroll_left)+"px";
	document.getElementById(strWhichWindow).style.top=((docheight/2-height/2)+scroll_top)+"px";
} else {
	document.getElementById(strWhichWindow).style.left=((docwidth/2-width/2)+scroll_left)+"px";
	document.getElementById(strWhichWindow).style.top="50px";
};
}


function closeit(strWhichWindow){
	document.getElementById(strWhichWindow).style.display="none";
	hideVeil();
	//showSlideshow();
}

function launchLogin() {
 	showVeil();
	loadwindow_delayed('/login_popup.asp',550,385,'loginwindow',1000);
};

function launchTimeout() {
 	showVeil();
	loadwindow_delayed('/session-timeout.asp',550,385,'loginwindow',1000);
};

function launchCompare() {	
	showVeil();
	loadwindow_delayed('compare-home-inventory-popup.asp',847,525,'comparewindow',1000);
};

function launchAddRoom() {
 	showVeil();
	loadwindow_delayed('createRoom_popup.asp',210,135,'addroomwindow',1000);
};

function launchEditProperty() {
 	showVeil();
	loadwindow_delayed('editProperty_popup.asp',240,315,'editpropertywindow',1000);
};

function launchAddProperty() {
 	showVeil();
	loadwindow_delayed('addProperty_popup.asp',240,315,'editpropertywindow',1000);
};

function launchEditImage(intImageID, intRoomID) {
 	showVeil();
	loadwindow_delayed('editImage_popup.asp?ImageID=' + intImageID + '&RoomID=' + intRoomID,240,270,'editimagewindow',1000);
};

function launchEditRoom(intRoomID) {
 	showVeil();
	loadwindow_delayed('editRoom_popup.asp?RoomID=' + intRoomID,240,270,'editroomwindow',1000);
};

function launchSignup(strPromoCode) {
	showVeil();
	loadwindow_delayed('/signup_popup.asp?PromoCode='+strPromoCode,650,550,'signupwindow',1000);
};

function launchUploadVideo() {
	showVeil();
	loadwindow_delayed('/video.asp?V=uploadPhotos.flv&W=960&H=540',960,540,'videowindow',1000);
};

function launchTaggingVideo() {
	showVeil();
	loadwindow_delayed('/video.asp?V=tagItems.flv&W=960&H=540',960,540,'videowindow',1000);
};

function launchABCVideo() {
	showVeil();
	loadwindow_delayed('/video.asp?V=abcNews-2-17-2011.flv&W=640&H=480',640,480,'videowindow',1000);
};

function launchCBSVideo() {
	showVeil();
	loadwindow_delayed('/video.asp?V=CBSNews.flv&W=640&H=360',640,360,'videowindow',1000);
};

function launchTellAFamily() {
	showVeil();
	loadwindow_delayed('footerEmail.asp',140,260,'referwindow',1000);
};

function showTellAFamily() {
	document.getElementById('referwindow').style.display = '';
};

function closeVideo(){
	document.getElementById('videowindow').style.display="none";
	hideVeil();
	loadIFrame('video.asp','videowindow');
	//document.getElementById('').
}

function launchScreenshot(strWhich) {
	showVeil();
	loadscreenshotwindow_delayed('screenshot.asp?IMG=' + strWhich,1000,910,'screenshotwindow',1000);
};

function launchBugReport() {
	showVeil();
	loadwindow_delayed('bugReport.asp',550,470,'bugreportwindow',1000);
};


/** TOOL TIPS **/
var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();
