var DHTML = (document.getElementById || document.all || document.layers);
if ( !DHTML ) alert('Please enable Javascript in your browser for this site to function properly.');

var fadingIn=true;
var fadingInWithDelay=true;
var QT_PARAMS=null;
var FLASH_SRC=null;

var allImgs = ['images/filmatixlogo.jpg',
			   'img/bg_fplogo.jpg',
			   'images/submenu_icons/bio_hover.jpg',
			   'img/bg_fpindie.jpg',
			   'img/bg_fpphoto.jpg',
			   'images/submenu_icons/post_hover.jpg',
			   'images/submenu_icons/reps_hover.jpg',
			   'images/submenu_icons/video_hover.jpg',
			   'images/filmatix_title_text.jpg',
			   'images/filmatix_title_text_black.jpg',
			   'images/3rd_party_logos/get_adobe_reader.gif',
			   'images/3rd_party_logos/get_flash_player.gif',
			   'images/3rd_party_logos/getquicktime.gif'];

//Contents for Photography's submenu
/*var photography=new Array()
photography[0]='<a href="javascript:redirectURL(\'photography/commercial.html\')">Commercial</a>';
photography[1]='<a href="javascript:redirectURL(\'photography/landscape.html\')">Landscape</a>';
photography[2]='<a href="javascript:redirectURL(\'photography/artistic.html\')">Artistic</a>';
photography[3]='<a href="javascript:redirectURL(\'photography/sports.html\')">Sports</a>';
photography[4]='<a href="javascript:redirectURL(\'photography/event.html\')">Event</a>';
photography[5]='<a href="javascript:redirectURL(\'photography/portrait.html\')">Portrait</a>';
photography[6]='<a href="javascript:redirectURL(\'photography/wedding.html\')">Wedding</a>';
*/
//Contents for Corporate's submenu
var corporate=new Array()
corporate[0]='<a href="javascript:redirectURL(\'corporate/corporate_image.html\')">Corporate Image</a>'
corporate[1]='<a href="javascript:redirectURL(\'corporate/marketing.html\')">Sales & Marketing</a>'
corporate[2]='<a href="javascript:redirectURL(\'corporate/training.html\')">Training</a>'

//Contents for Commercial's submenu
var commercial=new Array()
commercial[1]='<a href="javascript:redirectURL(\'commercial/tv_spots.html\')">TV Spots</a>'
commercial[2]='<a href="javascript:redirectURL(\'commercial/product_promotion.html\')">Product&nbsp;Promotion</a>'
//commercial[2]='<a href="javascript:redirectURL(\'commercial/music_videos.html\')">Music Videos</a>'
//commercial[3]='<a href="javascript:redirectURL(\'commercial/documentaries.html\')">Documentaries</a>'
//commercial[4]='<a href="javascript:redirectURL(\'commercial/product_sales.html\')">Product Sales</a>'
//commercial[5]='<a href="javascript:redirectURL(\'commercial/infomercials.html\')">Infomercials</a>'

//Contents for Post's submenu
var post=new Array()
post[0]='<a href="javascript:redirectURL(\'post/editing.html\')">Editing</a>'
post[1]='<a href="javascript:redirectURL(\'post/motion_graphics.html\')">Motion Graphics</a>'
post[2]='<a href="javascript:redirectURL(\'post/web_video.html\')">Web Video</a>'
//post[1]='<a href="javascript:redirectURL(\'post/dvd_authoring.html\')">DVD Authoring</a>'
//post[2]='<a href="javascript:redirectURL(\'post/web_video.html\')">Web Video</a>'
//post[3]='<a href="javascript:redirectURL(\'post/slideshow.html\')">Slideshow</a>'
//post[4]='<a href="javascript:redirectURL(\'post/duplication.html\')">Duplication</a>'

//Contents for Independent's submenu
var indie=new Array()
indie[0]='<a href="http://www.filmatixfilms.com" target="_blank">Filmatix Films</a>'

//Contents for Represent's submenu
/*
var reps=new Array()
reps[0]='<a href="javascript:redirectURL(\'represents/cory_lash.html\')">Cory Lash</a>'
reps[1]='<a href="javascript:redirectURL(\'represents/chris_butler.html\')">Chris Butler</a>'
reps[2]='<a href="http://www.anthonywentzel.com" target="_blank">Anthony Wentzel</a>'

//Contents for Biography's submenu
var biography=new Array()
biography[0]='<a href="javascript:redirectURL(\'bios/kevin_crisp.html\')">Kevin Crisp</a>'
biography[1]='<a href="javascript:redirectURL(\'bios/duston_lash.html\')">Duston Lash</a>'
*/

var changeMediaPanel=true;
var menuwidth='100px' //default menu width
var disappeardelay=0  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="no" //hide menu when user clicks within menu?
var DefaultMediaPanel = '<img src="img/bg_fplogo.jpg" hspace=0 vspace=0 align="top">'; //Main Title Image will change to this dynmaic image on hover
var currentMenuName = 'main';
/////END GLOBALS
var ie4=document.all
var ns6=document.getElementById&&!document.all
var mainmenu=null

function LOAD() {
//	document.onclick = exitURL; // route all click events
	var ip = new ImagePreloader(allImgs, onPreload);
	setBodySize();
	fadeIn('MediaPanel',100,1);
//	fadeInWithDelay('ContentPanel',0,4,true);
}

function getQTParams() {
	return QT_PARAMS
}

function setQTParams(QT_Info) {
	QT_PARAMS = QT_Info
}

function getFlashParams(src) {
	return FLASH_SRC
}

function setFlashParams(src) {
	FLASH_SRC = src
}

function getBodySize() {
  	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
	    myWidth = window.innerWidth;
    	myHeight = window.innerHeight;
	} else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
    	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    	//IE 4 compatible
	    myWidth = document.body.clientWidth;
    	myHeight = document.body.clientHeight;
	}
	
	var size=new Array();
	size[0] = myWidth;
	size[1] = myHeight;

	return size;
}

function setBodySize() {
	var size = getBodySize();
	var myBody = getObj('THE_BODY');
	var left = size[0]/2 - parseInt(myBody.style.width)/2;
	myBody.style.left = left.toString() + 'px';
	myBody.style.visibility = 'visible';
}

function LOAD_FAST() {
	setBodySize();
//	fadeIn('MediaPanel',0,4);
	fadeInWithDelay('ContentPanel',0,4,true);
}

function LOAD_QT(QT_Info) {
	setBodySize();
	fadeIn('MediaPanel',0,4);
	fadeInWithDelay('ContentPanel',0,4,true);
	setQTParams(QT_Info)	
/*	var MP = getObj('MediaPanel');	
	var size = getBodySize();
	var left = getposOffsetLeft(MP) + 402 - QT_Info[1]/2
	var top = getposOffsetTop(MP) + 7
	
	if (browser == "IE")
		top+=8
	else if (browser=="Safari")
		top+=7

	var QTdiv = getObj('quicktime');
	QTdiv.left = left +'px';
	QTdiv.visibility = 'visible';
	
	setQTParams(QT_Info)
	var MP = getObj('MediaPanel');	
	var QTdiv = getObj('QTdiv');
	var MP = getObj('MediaPanel');

	var width, height=255;
	
	if (QT!=null)
		width = QT.width;
	else {
		width = 432;	// default widescreen 16:9 ratio
	}
	
	QTdiv.style.width = width + 'px';
	QTdiv.style.height = height + 'px';
	var size = getBodySize();
	var left = getposOffsetLeft(MP) + 402 - QT_Info[1]/2
	var top = getposOffsetTop(MP) + 7
	if (browser == "IE")
		top+=8
	else if (browser=="Safari")
		top+=7

	var QTdiv = getObj('quicktime');
	QTdiv.left = left +'px';

	

	QTdiv.style.top = top + 'px';
	QTdiv.style.left = left + 'px';
	QTdiv.style.zIndex = 9;
	QTdiv.style.visibility = 'visible';
	
	loadQT(QT_Info);
		
	QTdiv.style.visibility = 'visible';*/
}

function waitToPlay() {
	if (fadingIn) {
		setTimeout(waitToPlay, 500)
	} else {
		loadQT();
	}
}

function waitToLoadFlash() {
	if (fadingIn) {
		setTimeout(waitToPlay, 500)
	} else {
		loadFlash();
	}
}

function LOAD_FLASH(src) {
	setBodySize();
//	fadeIn('MediaPanel',0,12);
	fadeInWithDelay('ContentPanel',0,4,true);
	
/*	var MP = getObj('MediaPanel');	
	var size = getBodySize();
	var left = getposOffsetLeft(MP) + 402 - QT_Info[1]/2
	var top = getposOffsetTop(MP) + 7
	
	if (browser == "IE")
		top+=8
	else if (browser=="Safari")
		top+=7

	var QTdiv = getObj('MediaPanel');
	QTdiv.left = left +'px';
	QTdiv.visibility = 'visible';*/
	
	setFlashParams(src)
}

function getObj(name) {
	var obj;
	
	if (document.getElementById) {
		obj = document.getElementById(name);
	} else if (document.all) {
		obj = document.all[name];
	} else {
		obj = document.layers[name];
	}

	return obj;
}

function setMediaPanel(innerHTML) {
	var MP = getObj('MediaPanel');

	MP.innerHTML = innerHTML;
	//fadeIn('MediaPanel',0,17);
	fadeIn('MediaPanel',99,1);
}

// This will load the photography slideshow into the Media Panel
// and the content in the Content Panel
function loadFooterLink(img, e, menucontents, menuwidth) {
	var ip = new ImagePreloader(allImgs, onPreload);
	setBodySize();
	
	setMediaPanel(getImgTag(img));
	fadeInWithDelay('MediaPanel',0,4,false);
	
	var obj=getObj('FOOTER');

	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv

	mainmenu=obj
	mainmenu.style.color = '#000000';
	mainmenu.style.textDecoration='underline';

	dropmenuobj.style.left=dropmenuobj.style.top=-500
	dropmenuobj.widthobj=dropmenuobj.style
	dropmenuobj.widthobj.width=menuwidth
//	setOpacity(dropmenuobj,0);	
	dropmenuobj.style.visibility='visible'
//	fadeIn('dropmenudiv',0,20);

	dropmenuobj.x=getposOffsetLeft(obj)
	dropmenuobj.y=getposOffsetTop(obj)
	dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
	dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	populatemenu(menucontents)

	currentMenuName = mainmenu.name;
}

function onPreload(imgs, nImages) {
// no errors please
}

function redirectURL(url) {
	var pathname = window.location.pathname;
	var upone = '';
	if (pathname.indexOf('corporate') > -1 ||
		pathname.indexOf('commercial') > -1 ||
		pathname.indexOf('post') > -1)
		upone = '../';
	var directory = pathname.substring(0,pathname.lastIndexOf('/')+1);
	var absoluteURL = 'http://' + window.location.hostname + directory + upone + url;
	window.location.href = absoluteURL;
}