// This file contains the necessary javascript 
// routines and variables for the Creature Works website.
// Author: Dale Hughes
// Copyright 2003-2008 Creature Works Labs

function newImage(imgname) {
        if (document.images) {
                nwimg = new Image();
                nwimg.src = imgname;
                return nwimg;
        }
}
var imgspreloaded = false;
function changeImages() {
	if (imgspreloaded == false) {
		return;
	}
        else if (document.images && (imgspreloaded == true)) {
                for (var i = 0; i < changeImages.arguments.length; i += 2) {
                        document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
                }
        }
        window.status = " ";
}
function preloadImages() {
        if (document.images) {
		//var eye_closed		= newImage("images/eye_black_09.jpg");
		//var bubbles		= newImage("images/bubbles_14_onblk.jpg");

		var menu_home_off	= newImage("images/home_off.jpg");
		var menu_home_over	= newImage("images/home_over.jpg");

		var menu_about_on	= newImage("images/about_on.jpg");
		var menu_about_over	= newImage("images/about_over.jpg");

		var menu_portfolio_on	= newImage("images/portfolio_on.jpg");
		var menu_portfolio_over	= newImage("images/portfolio_over.jpg");

		var submenu_it_web_on	= newImage("images/it_web_on.gif");
		var submenu_design_on	= newImage("images/design_on.gif");

            imgspreloaded = true;
        }
}
function do_mouseovers(which_set) {
	return true;
}
var portSideBoxVisible = 0;
var portCurIndex = 0;
var portCurXMLinfo = "";
function showPortSideBox() {
	if (!portSideBoxVisible) {
		var portSideBoxID = document.getElementById("portSideBox");
		portSideBoxID.style.display = "block";
		portSideBoxVisible = 1;
	}
}
function hidePortSideBox() {
	if (portSideBoxVisible) {
		portSideBoxID = document.getElementById("portSideBox");
		portSideBoxID.style.display = "none";
		portSideBoxVisible = 0;
	}
}
function handleOuterDisplays(indexFromFlash,infoFromXml,thoughts) {
	//var thoughts = insertBackslashBeforeSingleQuote(thoughtsRaw);
	
	portCurIndex = indexFromFlash;
	portCurXMLinfo = infoFromXml;
	var bubble_Id = document.getElementById('bubble_Box'); 
	var bubble_html;
	bubble_Id.innerHTML = '';

	var portSideBoxTextID = document.getElementById("portSideBoxText");
	portSideBoxTextID.innerHTML = '';

	showPortSideBox();
	portSideBoxTextID.innerHTML = infoFromXml;
	bubble_Id.innerHTML = thoughts;
}
function write_bubble_(which_bubble_) {

	var bubble_Id = document.getElementById('bubble_Box'); 
	var bubble_html;
	bubble_Id.innerHTML = '';
// The span class was moved to the html file where the div is defined because of a bug in IE 5.2 mac
	
	if (which_bubble_ == 'default') {
		bubble_html = "Creature Works...<br><br>your creative <br>collaborator";
		bubble_Id.innerHTML = bubble_html;
	}
	else if (which_bubble_ == 'graphics' || which_bubble_ == 'port_stills') {
		bubble_html = "Logo Design<br>";
		bubble_html += "Corporate Identity<br>";
		bubble_html += "Packaging<br>";
		bubble_html += "Merchandise<br>";
		bubble_html += "Business Collateral<br>";
		bubble_html += "Photo Retouching<br>";
		bubble_html += "2D/3D Illustration<br>";
		bubble_Id.innerHTML = bubble_html;
	}
	else if (which_bubble_ == 'broadcast' || which_bubble_ == 'port_video') {
		bubble_html = "3D/2D Animation<br>";
		bubble_html += "Motion Capture<br>";
		bubble_html += "Character Animation<br>";
		bubble_html += "Commercials<br>";
		bubble_html += "Industrials<br>";
		bubble_Id.innerHTML = bubble_html;
	}
	else if (which_bubble_ == 'advertising') {
		bubble_html = "Direct Mail<br>";
		bubble_html += "Trade Shows<br>";
		bubble_html += "Special Events<br>";
		bubble_html += "Print Advertising<br>";
		bubble_html += "Promotional Items<br>";
		bubble_html += "Commercials<br>";
		bubble_Id.innerHTML = bubble_html;
	}
	else if (which_bubble_ == 'webdev' || which_bubble_ == 'port_web') {
		bubble_html = "Web Sites<br>";
		bubble_html += "B2B Environments<br>";
		bubble_html += "Programming<br>";
		bubble_html += "Email Campaigns<br>";
		bubble_html += "Online Press Kits<br>";
		bubble_html += "Domain Names<br>";
		bubble_html += "Web Hosting";
		bubble_Id.innerHTML = bubble_html;
	}
	else if (which_bubble_ == 'software') {
		bubble_html = "Web Features<br>";
		bubble_html += "B2B Environments<br>";
		bubble_html += "Image Processing<br>";
		bubble_html += "Communications<br>";
		bubble_html += "3D Modeling<br>";
		bubble_html += "Animation<br>";
		bubble_Id.innerHTML = bubble_html;
	}
	else if (which_bubble_ == 'aboutus') {
		bubble_html = "Clients:<br>";
		bubble_html += "Best Buy<br>";
		bubble_html += "Cargill, CBS<br>";
		bubble_html += "Champions on Ice<br>";
		bubble_html += "Disney<br>";
		bubble_html += "Ellerby Becket<br>";
		bubble_html += "3M<br>";
		bubble_Id.innerHTML = bubble_html;
	}
	else if (which_bubble_ == 'contact') {
		bubble_html = "Whoa,<br>";
		bubble_html += "That's it.<br>";
		bubble_html += "I'm calling.<br>";
		bubble_Id.innerHTML = bubble_html;
	}
	else if (which_bubble_ == 'eye_poke') {
		bubble_html = "Ouch!<br>";
		bubble_Id.innerHTML = bubble_html;
	}
	return true;
}
var portfolioWin = null;
function openportfolio() {
	var htmlfile = "portfolio.html";
	if (portfolioWin == null || portfolioWin.closed) {
             portfolioWin = window.open("","","resizable=yes,scrollbars=yes,toolbar=yes,status=yes,width=720,height=500,left=100,top=0");
 	}
	portfolioWin.location = htmlfile;
	portfolioWin.focus();
	portfolioWin.status="Copyright 2004 Creature Works Inc.";
}
var movieWin = null;
function openmoviewindow() {
	var htmlfile = "testimonials.html";
	if (movieWin == null || movieWin.closed) {
             movieWin = window.open("","Testimonials","resizable=no,scrollbars=yes,toolbar=yes,status=no,width=360,height=350,left=100,top=0");
 	}
	movieWin.location = htmlfile;
	movieWin.focus();
	movieWin.status="Copyright 2004 Creature Works Inc.";
}
var imgScreen = new Image();
imgScreen.src = "images/cwl_wideback_midBUB_09.jpg";

function checkScreen() {
	// we don't want to load the content into the screen before the screen is displayed
	if (!imgScreen.complete) {
		//setTimeout('checkScreen()',10000); //10 seconds?
		setTimeout('checkScreen()',1000);
	}
	else {
		document.getElementById("screenFrame").style.backgroundImage = "url("+imgScreen.src+")";
		// open the eye
		openEye();
		loadScreen(menuHomeIndex);
		write_bubble_('default')
		preloadImages();
	}
}
function load_all() {

	setPupilHandle();
	checkScreen();
}
var webWin = null;
function openwebpage(url) {
        if (webWin == null || webWin.closed) {
             webWin = window.open("","","resizable=yes,scrollbars=yes,toolbar=yes,status=yes,width=800,height=600,left=100,top=0");  
        }
        webWin.location = url;
        webWin.focus();
        webWin.status="Copyright 2004 Creature Works Inc.";
}
var webWin2 = null;
function openwebpage2(url) {
        if (webWin2 == null || webWin2.closed) {
             webWin2 = window.open("","","resizable=yes,scrollbars=yes,toolbar=yes,status=yes,width=950,height=720,left=100,top=0");  
        }
        webWin2.location = url;
        webWin2.focus();
        webWin2.status="Copyright 2004 Creature Works Inc.";
}

function insertBackslashBeforeSingleQuote(str){
	var reg = /'/g;
	var newstr = "\\'"
	return str.replace(reg,newstr);
}
