// JavaScript Document
function getFlashMovie(objectId,embedId) {
  return (window[objectId]) ? window[objectId] 
              : document[embedId];
}
function flashgo(x){
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	//gsa.flash = (isIE) ? window["FlashID"] : document.getElementById("FlashID");
	gsa.flash = document.getElementById("FlashID");
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	var movie=getFlashMovie('swf2','swf');

	if(x=='webdesign'){
		
	movie.webdesigngo();
	 
	}
	if(x=='video'){
		movie.videogo();
	}
	if(x=='photo'){
		movie.photogo();
	}
	if(x=='model'){
		movie.model();
	}
	if(x=='contact'){
		movie.contact();
	}
    
}//  //  flash
function flashMovie(src,width,height,div,eid,oid){
	this.object;
	this.mode = 'transparent';
	if(!gsa.flashct)gsa.flashct=0;
	
	
	if(!eid)this.eid='flashmovid'+gsa.flashct;
	else this.eid=eid;
	if(!oid)
		this.oid ='flashmoveid'+gsa.flashct;
		else
		this.oid=oid;
	var r = [];
	
	this.eidx='flashmovid'+gsa.flashct;
	this.oidx='flashmoveid'+gsa.flashct;
	gsa.flashct++;
	r.push("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+width+"px' height='"+height+"px' id='"+this.oid+"'>");
	r.push("<param name='wmode' value='"+this.mode+"'>");
	r.push("<param name='movie' value='"+src+"'>");
	r.push("<param name='allowScriptAccess' value='always' />");
    r.push("<param name='swLiveConnect' value='true' />");
	r.push("<embed src='"+src+"' width='"+width+"px' height='"+height+"px' id='"+this.eid+"' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' wmode='"+this.mode+"' allowScriptAccess='always' swLiveConnect='true' ></embed>");
	r.push("</object>");
	this.div = div;
	this.loaded = false;
	this.show = function(){
		sethtml(this.div,r.join(""));
		this.register();
	}
	this.setMode = function(x){
		if(x=='normal')this.mode = 'opaque';
		else this.mode = 'transparent';
	}
	this.register = function(){
		this.object = getFlashMovie(this.oid,this.eid);
	}
	this.code = function(){
		return r.join("");
	}
}//  //  xfalsh
function alertme(x){
	alert(x);
}//  //  alert me
function init(){
	var btn = document.getElementById('btn1')
	btn.onkeydown = btn.blur;
	preloadImages();
	setStyle('menu','marginLeft','25px');
	if(gsa.display.IEVersion=='8' || !gsa.display.IE){
	document.getElementById('btn1').style.marginLeft = '-4px'; 
	document.getElementById('btn2').style.marginLeft = '-4px';
	document.getElementById('btn3').style.marginLeft = '-4px';
	document.getElementById('btn4').style.marginLeft = '-4px';
	document.getElementById('btn5').style.marginLeft = '-4px';
	}else{
	document.getElementById('btn1').style.marginLeft = '-4px'; 
	document.getElementById('btn2').style.marginLeft = '-4px';
	document.getElementById('btn3').style.marginLeft = '-4px';
	document.getElementById('btn4').style.marginLeft = '-4px';
	document.getElementById('btn5').style.marginLeft = '-4px';
	}
}//  //  init
function loadingLoaded(){
	crpa='';
}
function topLoaded(){
	gsa.loadedct++;
	afterLoaded();
	
}
gsa.callback.initialImagesLoaded = function(){
	gsa.loadedct++;
	afterLoaded();
	
}
function afterLoaded(){
	if(gsa.loadedct==2){
		closelayer('loading'); 
		document.body.style.background='#666666';
		setStyle('container','border','1px solid white');
		openlayer('containersub');
		var div = gid('header');
		div.style.width='900px';
		div.style.height='200px';
		document.getElementById('container').style.height='900px';
		openlayer('footer');
		preloadImages2();
	}
	var x = [];
	x.push("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='720px' height='480px' id='swf4'>");
    x.push("<param name='wmode' value='transparent'>");
   	x.push("<param name='movie' value='flash/jrvideo.swf'>");
    x.push("<embed src='flash/jrvideo.swf' width='720px' height='480px' id='swf3' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' wmode='transparent'></embed>");
    x.push("</object>");
	sethtml('modelvid',x.join(""));
}//  //  afterloaded
function restartButtons(){
	crap='';
}//  //  restart buttons
function preloadImages(){
	gsa.images=[];
	gsa.images.def = new imageLoader('def');
	gsa.images.def.add('close','../incons/closelabelo.png');
	gsa.images.def.preload();
	gsa.images.port = new imageLoader('port','gsa.callback.initialImagesLoaded()',true);
	gsa.images.port.addclick('port1','../images/connected.jpg',100,0);
	gsa.images.port.addclick('port2','../images/CHRISTIAN.jpg',100,0,'christianfulgium.com');
	gsa.images.port.addclick('port3','../images/ONCALL.jpg',100,0,'paffordoncall.com');
	gsa.images.port.addclick('port4','../images/AIRONE.jpg',100,0,'paffordairone.com');
	gsa.images.port.addclick('port5','../images/AIRMAPx.jpg',100,0,'paffordairone.com');
	//gsa.images.port.addclick('fight','../images/fc.jpg',100,0,'thefightclub.tv');
	//gsa.images.port.addclick('paffordems','../images/PAFF.jpg',100,0);
	gsa.images.port.preload();
}
function preloadImages2(){
	gsa.images.photo = new imageLoader('photo',null,true);
	gsa.images.photo.add('wed','../images/wed.jpg',250,0);
	gsa.images.photo.addclick('hdr1','../images/hdr1.jpg',200,0);
	gsa.images.photo.addclick('hdr2','../images/hdr2.jpg',200,0);
	gsa.images.photo.add('jk','../images/jk.jpg');
	gsa.images.photo.add('cassie','../images/cassie.jpg');
	gsa.images.photo.add('ang','../images/ang.jpg');
	gsa.images.photo.preload();
	//gsa.images.model = new imageLoader('model',null,true);
	////gsa.images.model.add('Model1','../images/front.jpg',0,200);
	//gsa.images.model.add('Model2','../images/top2.jpg',0,200);
	//gsa.images.model.add('Model3','../images/copter.jpg');
	//gsa.images.model.preload();
}//  //  preload images

function emptyFunction(){
	crap='';
}
function goWebdesign(){
	closeall();
	openlayer('webdesign');
	openlayer('facebook');
	openlayer('latestWebsite');
	openlayer('inProduction');
	openlayer('webside');
	flashgo('webdesign');
	document.getElementById('btn1-1').blur();
}//  //  go webdesign
function goVideo(){
	closeall();
	openlayer('video');
	openlayer('newsViewer');
	var ff = new flashMovie("../flash/VIDEO.swf",'900','700','video');
	ff.show();
	flashgo('video');
	document.getElementById('btn2-1').blur();
	gsa.newsFlash = new flashMovie('newsScroller2.swf', '560','458','newsViewer');
	gsa.newsFlash.setMode('normal');
	gsa.newsFlash.show();
	document.getElementById('container').style.height='1000px';
}
function newsReaderReady(){
	gsa.newsFlash.object.addNews('No Country for Dead Men','Trevino Class Productions','A zombie short from Trevino Class Productions where I am currently working on the post production visual effects. ','images/v2.jpg','dead');
	gsa.newsFlash.object.addNews('Pafford EMS Presentation','motion graphic presentation','A short presentation for Pafford EMS that was displayed at a health fair.  Combines video clips and motion graphics.','images/fair.jpg','fair');
	gsa.newsFlash.object.addNews('Pafford Air One','Action Promo Video','Promotional video featuring  Pafford Air One.  Footage for this video was gathered mainly from cell phone video and digital cameral video provided for the Air One crew.','images/v3.jpg','airone');
	gsa.newsFlash.object.addNews('Pyro experiment','Visual Effects','I was given an image of a house that was being built and asked if I could make it like it was on fire.  I took it a step further with a video of it burning.  All i need now is to add some wicked sound to it. I had fun creating this one.','images/fire.jpg','fire');
	gsa.newsFlash.object.addNews('Modern Warfare 2 Trailer','Scored Music','A quick video game trailer I put together at the request of my son.  He wanted something to put on youtube. The audio in this clip is from my library of scored music.','images/V1.jpg','zac');
	gsa.newsFlash.object.loadNext();
}//  //  go video
function newsReturn(wht){
	
	switch(wht){
		case 'dead': deadmov(); break;
		case 'airone': airmov(); break;
		case 'zac':  zacvid(); break;
		case 'fire': firevid(); break;
		case 'fair': fairvid(); break;
	}
		
}
function airmov(){
	
	gsa.airMovie = new flashMovie("http://paffordair.com/videos/aironesite.swf",600,430);
	var info = gsa.airMovie.code();
	gsa.airMovie.register();
	quickPanel(600,460,info,false);
}
function zacvid(){
	gsa.airMovie = new flashMovie("../flash/zac.swf",640,480);
	var info = gsa.airMovie.code();
	gsa.airMovie.register();
	quickPanel(640,520,info,false);
}
function firevid(){
	gsa.airMovie = new flashMovie("../flash/fire.swf",599,470);
	var info = gsa.airMovie.code();
	gsa.airMovie.register();
	quickPanel(599,500,info,false);
}
function fairvid(){
	gsa.airMovie = new flashMovie("../flash/fair.swf",720,530);
	var info = gsa.airMovie.code();
	gsa.airMovie.register();
	quickPanel(720,550,info,false);
}
function deadmov(){
	gsa.airMovie = new flashMovie("../dead.swf",700,550);
	var info = gsa.airMovie.code();
	gsa.airMovie.register();
	quickPanel(700,550,info,false);
}//  //  movies
function goModel(){
	closeall();
	openlayer('sideModel');
	openlayer('model');
	var ff = new flashMovie("../flash/threed.swf",'900','595','model');
	ff.show();
	document.getElementById('container').style.height='840px';
	flashgo('model');
	document.getElementById('btn3-1').blur();
}//  //  go model
function goContact(){
	closeall();
	openlayer('contact');
	flashgo('contact');
	document.getElementById('btn5-1').blur();
	var r = [];
	r.push("<br><br><table><tr><td>Name:</td><td><input type='text' id='contactname' size='32'/></td></tr>");
	r.push("<tr><td>EMail:</td><td><input type='text' id='contactemail'size='32'/></td></tr>");
	r.push("<tr><td>Subject:</td><td><input type='text' id='contactsubject'size='32'/></td></tr>");
	r.push("<tr valign='top'><td>Message:</td><td><textarea id='contactmessage' cols='26' rows='5'/></textarea></td></tr>");
	r.push("<tr><td></td><td><input type='button' value='Send' onclick='contactsend()'/></td></tr></table>");
	sethtml('contact',r.join(""));
}//  //  contact
function contactsend(){
	
	var pass = true;
	var name = getValue('contactname');
	var email = getValue('contactemail');
	var subject = getValue('contactsubject');
	var message = getValue('contactmessage');
	if(name==''){ setRed('contactname'); pass=false; }
	if(subject==''){ setRed('contactsubject'); pass=false; }
	if(email==''){ setRed('contactemail'); pass=false; }
	if(message==''){ setRed('contactmessage'); pass=false; }
	//if(!isAlpha('contactname')) pass=false;
	//if(!isAlpha('contactemail')) pass=false;
	//if(!isAlpha('contactmessage')) pass=false;
	//if(!isAlpha('contactsubject')) pass=false;
	if(pass){
		var url = '../Scripts/mail.php';
		var params = "to=jrice@paffordems.com&from="+name+"&subject=JRMEDIA "+subject+"&return="+email+"&message="+message;
		ajax.post(url,params,gsa.callback.send);
	}
	
}
gsa.callback.send = function(x){
	sethtml('contact',"<br><br>Your message has been sent");
}//  //  contact me
function goPhoto(){
	gsa.images.photo.loadAll();
	closeall();
	openlayer('photo');
	openlayer('sidePhoto');
	document.getElementById('container').style.height='1000px';
	flashgo('photo');
	document.getElementById('btn4-1').blur();
}//  //  go photo
function closeall(){
	document.getElementById('container').style.height='900px';
	closelayer('inProduction');
	closelayer('webside');
	closelayer('latestWebsite');
	closelayer('sidePhoto');
	closelayer('sideModel');
	closelayer('webdesign');
	closelayer('video');
	closelayer('photo');
	closelayer('model');
	closelayer('contact');
	closelayer('newsViewer');
	closelayer('facebook');
}//  //  closeall



function ckpw(id){
	gsa.passId=id;
	var x = "<table style='color:white'><tr><td>Password: </td><td><input type='password' id='pass'/> </td><td><input type='button' value='login' onclick=\"ckpwgo('"+id+"')\" /></td></tr></table>";
	quickPanel(300,60,x);
	document.getElementById('pass').onkeydown = passEnter;
	setFocus('pass');
	}
function passEnter(e){
	var key = getKey(e);
	if(key=='13')
	ckpwgo(gsa.passId); 
}
	
function ckpwgo(id){
	var p = gid('pass');
	if(p.value==''){setRed('pass'); return false;}
	ajax.post('../PHOTOSHOP/bank.php','id='+id+'&pw='+p.value,gsa.callback.pwck);
}
gsa.callback.pwck = function(x){
	if(x.indexOf('|x|')==-1)return;
	var z = x.split('|x|');
	if(z[1]!='1'){ alert('invalid password'); setRed('pass'); setValue('pass',''); return; }
	quickPanelOff();
	eval(z[2]);
}//  //  password


	