/* Browser Detect & Redirect */

if (!document.getElementById) { // Detect DOM
	window.location = "http://www.debbietravisfacelift.com/browser.php";
}

/* PopUp */

function Popup(page,width,height,scroll,location,statusbar,menubar,resizable) {
	/*if (!scroll) { scroll = 'no'; } else { scroll = 'yes'; }
	if (!location) { location = 'no'; } else { scroll = 'yes'; }
	if (!statusbar) { statusbar = 'no'; } else { scroll = 'yes'; }
	if (!menubar) { menubar = 'no'; } else { scroll = 'yes'; }
	if (!resizable) { resizable = 'no'; } else { scroll = 'yes'; }*/
	
	var now = new Date();
	var hour        = now.getHours();
	var minute      = now.getMinutes();
	var second      = now.getSeconds();
	
	if (!scroll) { scroll = 'no'; }
	if (!location) { location = 'no'; }
	if (!statusbar) { statusbar = 'no'; }
	if (!menubar) { menubar = 'no'; }
	if (!resizable) { resizable = 'no'; }
	//var name = page.substring(0,(page.length - 4));
	if (page.match('http')) var name = hour +''+ minute +''+ second;
	else var name = hour +''+ minute +''+ second +''+ page.substring(0,(page.length - 4));
	//window.open(page,name,'toolbar=0,scrollbars='+ scroll +',location=0,statusbar=0,menubar=0,resizable=0,width='+ width +',height='+ height);
	window.open(''+ page +'',name,'toolbar=0,scrollbars='+ scroll +',location='+ location +',statusbar='+ statusbar +',menubar='+ menubar +',resizable='+ resizable +',width='+ width +',height='+ height);
}

/* Episode OnMouseover popup Div */

//document.onmousemove = getMouseXY; // Set-up to use getMouseXY function onMouseMove.

var vDivID = ''; // Active popup Div.
var vMouseX = 0 // Mouse position.
var vMouseY = 0
var vWindowW = 0 // Window size.
var vWindowH = 0
var vDivW = 300; // Popup Div size.
var vDivH = '';

function ImgOver(vPosition,vDiv) { // Show/hide popup Div.
	document.onmousemove = getMouseXY; // Set-up to use getMouseXY function onMouseMove.
	if (vPosition == 'over') {
		vDivH = document.getElementById(vDiv).scrollHeight;
		vDivID = vDiv;
		document.getElementById(vDiv).style.visibility = "visible";
	}
	if (vPosition == 'out') {
		vDivH = '';
		vDivID = '';
		document.getElementById(vDiv).style.visibility = "hidden";
	}
}

function getMouseXY(e) { // Postion popup Div.
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) { // Mozilla/Opera
		vWindowW = eval(document.body.offsetWidth);
		vWindowH = eval(document.body.offsetHeight);
		vMouseX = e.pageX;
		vMouseY = e.pageY;
	}
	else if (e.clientX || e.clientY) { // IE
		vWindowW = document.body.offsetWidth;
		vWindowH = document.body.offsetHeight;
		if (!window.print) {
			vMouseX = e.clientX + document.body.scrollLeft; // IE 5 Mac
			vMouseY = e.clientY + document.body.scrollTop; // IE 5 Mac
		}
		else {
			vMouseX = e.clientX + document.documentElement.scrollLeft; // IE 6
			vMouseY = e.clientY + document.documentElement.scrollTop; // IE 6
		}
	}
	if (vDivID != '') {
		if ((eval(vMouseX) + eval(vDivW)) > vWindowW) vDivX = (eval(vMouseX) - eval(vDivW)) - 10;
		else vDivX = vMouseX + 10;
		if ((eval(vMouseY) + eval(vDivH)) > vWindowH) vDivY = (eval(vMouseY) - eval(vDivH)) - 10;
		else vDivY = vMouseY + 10;
		document.getElementById(vDivID).style.left = vDivX +"px";
		document.getElementById(vDivID).style.top = vDivY +"px";
		//vPopX = vDivX +"px";
		//vPopY = vDivY +"px";
	}
}

/* Episode Dropdown Finder */

function FindEpisode() {
	var URL = document.finder.show.options[document.finder.show.selectedIndex].value;
	if (URL == '0') {
		alert ('Please Select A Show');
		return false;
	}
	else { window.location.href = URL; }
}

/* Episode Show/Hide functions for non-pointer layer/objects */

var vPointer = 'div_01_after'; // After image.

function show(vID) {
	hide(vPointer);
	vPointer = vID;
	document.getElementById(vID).style.visibility = "visible";
}

function hide(vID) {
	document.getElementById(vID).style.visibility = "hidden";
}

/* Episode Before and After Image Switch */

var beforenum = '1';

function before(num) {
	beforenum = num;
	if (num > 1) rotate(1);
}

function rotate(num) {
	if (num > beforenum) num = 1;
	document.Before.src = 'images/0'+ num +'_before.jpg';
	num = num + 1;
	setTimeout('rotate('+ num +')',5000)
}

/* Coming Before and After Image Switch */

var comingnum = '1';
var comingdate = '';

function coming(date,num) {
	comingnum = num;
	comingdate = date;
	if (num > 1) comingrotate(1);
}

function comingrotate(num) {
	if (num > comingnum) num = 1;
	document.Coming.src = 'images/popup/'+ comingdate +'_'+ num +'.jpg';
	num = num + 1;
	setTimeout('comingrotate('+ num +')',5000)
}

//function coming(date,num) {
//	if (num > 3) num = 1;
//	document.Coming.src = 'images/popup/'+ date +'_'+ num +'.jpg';
//	num = num + 1;
//	setTimeout('coming('+ date +','+ num +')',5000)
//}

/* Close Window */

function WindowClose() {
	timer = setTimeout('window.close();', 10);
}

/* Blink Text In Explorer */

var vis = true;

function BlinkText() {
	id = 'blink';
	if (ie) {
        if (vis == true) { document.getElementById(id).style.visibility = "visible"; }
        else { document.getElementById(id).style.visibility = "hidden"; }
		vis = (!vis);
		setTimeout('BlinkText();', 500);
	}
}

/* Previous Episodes Thumbnail*/

function Previous(season,episode) {
	document[season].src= episode +'/images/01_after_thmb.jpg';
}