var CancelShowcasePreviewLoad=false;
var LockShowcase=false;
var EyeGraphic=null;


// Collapse Element
function ExpandElement(Element){
	Element=SS_GetElement(Element);
	if (Element.style!=null){
		CollapseAllSubInfo();
		Element.style.position="relative";
		Element.style.height=null;
		var FullHeight=SS_GetElementH(Element);
		SS_SetElementH(Element, 1);
		SS_ShowElement(Element, true);
		SS_AnimateElementSize(Element, null, FullHeight, 200, 5);
	}
}


//Collapse all SubInfo Boxes
function CollapseAllSubInfo(){
	var LoopVar=0;
	var TmpElement=null;
	for (LoopVar=1; LoopVar<=5; LoopVar++){
		TmpElement=SS_GetElement("SubInfo_"+LoopVar);
		if (TmpElement){
			TmpElement.style.position="absolute";
			SS_ShowElement(TmpElement, false);
		}
	}
}



// Collapse Staff Info Box
function ExpandStaffInfo(Element, StaffName, StaffTitle){
	Element=SS_GetElement(Element);
	var Floater=SS_GetElement('StaffInfoFloater');
	var MainContent=SS_GetElement('MainContent');
	if (Element && Floater){
		Floater.style.width=null;
		SS_SetElement(Floater, "<b>"+StaffName+"</b><br />"+StaffTitle);
		var NaturalWidth=SS_GetElementW(Floater);
		SS_SetElementPosition(Floater, SS_GetElementX(Element), SS_GetElementY(Element)+SS_GetElementH(Element));		
		SS_SetElementW(Floater, 1);
		SS_SetElementOpacity(Floater, 0);
		SS_ShowElement(Floater, true);
		SS_AnimateElementOpacity(Floater, 100, 200, 10);
		SS_AnimateElementSize(Floater, NaturalWidth, null, 200, 10);
	}
}


// Put showcase sub links back in their spot
function ReplaceShowcaseSubLinks(ShowcaseID){
	var SubElements=document.getElementsByName(ShowcaseID);
	var LoopVar=0;
	for (LoopVar=0; LoopVar<SubElements.length; LoopVar++){
		SubElements[LoopVar].style.left=null;
		SubElements[LoopVar].style.top=null;
		SubElements[LoopVar].style.position="relative";
		SS_SetElementOpacity(SubElements[LoopVar], 50);
		SS_SetElementSize(SubElements[LoopVar], 24, 24);
	}
}


// Show Showcase Piece
function ShowShowcasePiece(ShowcaseID){
	ReplaceShowcaseSubLinks("Interactive_Website_Development");
	ReplaceShowcaseSubLinks("Email_Campaigns");
	ReplaceShowcaseSubLinks("Interactive_SEO");
	ReplaceShowcaseSubLinks("Online_Advertising");
	ReplaceShowcaseSubLinks("Content_Management");
	ReplaceShowcaseSubLinks("Interactive_Custom_Programming");
	ReplaceShowcaseSubLinks("PR_Social_Media");
	ReplaceShowcaseSubLinks("PR_Event_Based");
	ReplaceShowcaseSubLinks("PR_Integrated_PR_Support");
	ReplaceShowcaseSubLinks("PR_New_Product_Introductions");
	SS_PopulateElement('ShowcaseBox', 'ajax/getcontent.php?ContentSection='+ShowcaseID);
	var SubElements=document.getElementsByName(ShowcaseID);
	var LoopVar=0;
	var CurrX=10;
	var CurrY=160;
	for (LoopVar=0; LoopVar<SubElements.length; LoopVar++){
		SubElements[LoopVar].style.position="absolute";
		SS_AnimateElementPosition(SubElements[LoopVar], CurrX, CurrY);
		SS_AnimateElementOpacity(SubElements[LoopVar], 100);
		SS_AnimateElementSize(SubElements[LoopVar], 32, 32);
		CurrX+=40;
		if (CurrX>200){
			CurrX=10;
			CurrY+=40;
		}
	}
}



// Show/Hide the login box
function ToggleLoginBox(){
	if (SS_GetElement('LoginBox').style.visibility=="visible"){
		SS_ShowElement('LoginBox', true);
		SS_SetElementSize('LoginBox', 300, 150);
		SS_AnimateElementSize('LoginBox', 1, 1, 200);
		SS_SetElementOpacity('LoginBox', 100);
		SS_AnimateElementOpacity('LoginBox', 0, 200);
		SS_SetElement('LoginBox', '');
	} else {
		SS_ShowElement('LoginBox', true);
		SS_SetElementSize('LoginBox', 1, 1);
		SS_AnimateElementSize('LoginBox', 300, 150, 200);
		SS_SetElementOpacity('LoginBox', 0);
		SS_AnimateElementOpacity('LoginBox', 100, 200);
		SS_PopulateElement('LoginBox', 'ajax/boardlogin.html');
	}
}



function ClickShowcaseThumbnail(SWF, Frame){
	LockShowcase=true;
	CancelShowcasePreviewLoad=true;
	SS_ShowElement('ShowcasePreviewBox', false);
	SS_ShowElement('ShowcasePreviewBox', false);
	SS_SetElement('ShowcaseFullViewInterior', '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="shell" align="middle" width="800" height="550"><param name="allowScriptAccess" value="sameDomain"><param name="movie" value="showcase_images/swfs/shell.swf?frame='+Frame+'&amp;filename=showcase_images/swfs/'+SWF+'.swf&amp;type=Print"><param name="quality" value="high"><param name="bgcolor" value="#ffffff"><embed src="showcase_images/swfs/shell.swf?frame='+Frame+'&amp;filename=showcase_images/swfs/'+SWF+'.swf&amp;type=Print" quality="high" bgcolor="#ffffff" name="shell" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" align="middle" width="800" height="550"></object>');
	SS_SetElementOpacity('ShowcaseFullViewBox', 0);
	SS_AnimateElementOpacity('ShowcaseFullViewBox', 100, 200, 10);
}

function OverShowcaseThumbnail(Element, ShowcaseID){
	Element=SS_GetElement(Element);
	if (Element!=null && !LockShowcase){
		CancelShowcasePreviewLoad=false;
		SS_SetElementOpacity('ShowcasePreviewBox', 0);
		SS_SetElementPosition('ShowcasePreviewBox', SS_GetElementAbsoluteX(Element)+SS_GetElementW(Element)+10, SS_GetElementAbsoluteY(Element)-100);
		SS_PopulateElement('ShowcasePreviewInterior', 'ajax/getshowcase.php?ContentSection='+ShowcaseID, '&nbsp;', 'if (!CancelShowcasePreviewLoad) SS_AnimateElementOpacity(\'ShowcasePreviewBox\', 100, 200);');
	}
}

function OffShowcaseThumbnail(Element){
	Element=SS_GetElement(Element);
	if (Element!=null && !LockShowcase){
		CancelShowcasePreviewLoad=true;
		SS_AnimateElementOpacity('ShowcasePreviewBox', 0, 200);
	}
}

if (!window.ShowFullProjectView){
	ShowFullProjectView=function(State){
		LockShowcase=false;
		SS_ShowElement('ShowcaseFullViewBox', State);
	}
}



function InitEyes(){
	EyeGraphic=SS_GetElement("EyeGraphic");
	if (EyeGraphic!=null){
		var Preloader=null;
		Preloader=new Image(); 
		Preloader.src="images/eyes/eyes_w2.gif";
		Preloader=new Image(); 
		Preloader.src="images/eyes/eyes_w1.gif";
		Preloader=new Image(); 
		Preloader.src="images/eyes/eyes_0.gif";
		Preloader=new Image(); 
		Preloader.src="images/eyes/eyes_e1.gif";
		Preloader=new Image(); 
		Preloader.src="images/eyes/eyes_e2.gif";
		document.onmousemove=function(Event){
			if (!Event){
				Event=window.event;
			}
			var EyeX=SS_GetElementAbsoluteX(EyeGraphic)+(SS_GetElementW(EyeGraphic)/2);
			if (Event.clientX<EyeX-20){
				EyeGraphic.src="images/eyes/eyes_w2.gif";
			} else if (Event.clientX<EyeX-10){
				EyeGraphic.src="images/eyes/eyes_w1.gif";
			} else if (Event.clientX>EyeX+20){
				EyeGraphic.src="images/eyes/eyes_e2.gif";
			} else if (Event.clientX>EyeX+10){
				EyeGraphic.src="images/eyes/eyes_e1.gif";
			} else {
				EyeGraphic.src="images/eyes/eyes_0.gif";
			}
		}
	}
}