/*
Designed by <theFactor.e>
http://www.tfe.nl

CVS Header Information:  
    $Source: f:/tfecvs/cvs/tfe/internet/htdocs/js/default.js,v $
    $Revision: 1.2 $
    $Date: 2006/05/10 14:48:48 $
    $Name:  $
    $Author: kleinebeer#joshua $
*/
// JavaScript Document
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}


/*******************************************************
FLASH DETECT 2.5
All code by Ryan Parman and mjac, unless otherwise noted.
(c) 1997-2004 Ryan Parman and mjac
http://www.skyzyx.com
*******************************************************/

// This script will test up to the following version.
flash_versions = 20;

// Initialize variables and arrays
var flash = new Object();
flash.installed=false;
flash.version='0.0';

// Dig through Netscape-compatible plug-ins first.
if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
			flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
			flash.installed = true;
			break;
		}
	}
}

// Then, dig through ActiveX-style plug-ins afterwords
else if (window.ActiveXObject) {
	for (x = 2; x <= flash_versions; x++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
			if(oFlash) {
				flash.installed = true;
				flash.version = x + '.0';
			}
		}
		catch(e) {}
	}
}

// Create sniffing variables in the following style: flash.ver[x]
// Modified by mjac
flash.ver = Array();
for(i = 4; i <= flash_versions; i++) {
	eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true : false;");
}

// Sifr component
if(typeof sIFR == "function")
{
	sIFR.replaceElement(named({sSelector:"h1.showcase", sWmode:"transparent", sFlashSrc:"swf/arial22.swf", sColor:"#999999", sLinkColor:"#000000", sBgColor:"#FFFFFF", sHoverColor:"#333333", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
	sIFR.replaceElement(named({sSelector:".txtContainer h1", sWmode:"transparent", sFlashSrc:"swf/arial22.swf", sColor:"#ffffff", sLinkColor:"#ffffff", sBgColor:"#FFFFFF", sHoverColor:"#ffffff", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
	sIFR.replaceElement(named({sSelector:"h1", sWmode:"transparent", sFlashSrc:"swf/arial22.swf", sColor:"#333333", sLinkColor:"#000000", sBgColor:"#FFFFFF", sHoverColor:"#333333", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left&offsetTop=0"}));
}
function toggleBox(szDivID, iState)
{
	var obj = document.layers ? document.layers[szDivID] :
	document.getElementById ? document.getElementById(szDivID).style :
	document.all[szDivID].style;
	obj.display = document.layers ? (iState ? "none" : "block") : (iState ? "block" : "none");
}

// Show hide layer in banner AzG
function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "block";
}
function ReverseContentDisplay(d) {
	if(d.length < 1) { return; }
	if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
	else { document.getElementById(d).style.display = "none"; }
}
	  
// PORTFOLIO FUNCTIONS
function setContentHeight(height)
{
	//portfolio div is pushing footer down
	var portfolioDiv = document.getElementById('portfolio');
	portfolioDiv.style.height = (height-175)+"px";
	
	//swf div gets full height
	var swfDiv = document.getElementById('flashContent');
	swfDiv.style.height = (height+160)+"px";			
}

var currentSwfState = 0;
function sendSwfToBack() {	
	if (currentSwfState != 0) {
		var swfDiv = document.getElementById('flashContent');
		//swfDiv.style.zIndex = '1';
		togglePortfolio();		
		currentSwfState = 0;
	} 
}
function sendSwfToFront() {
	if (currentSwfState != 1) {
		var swfDiv = document.getElementById('flashContent');
		//swfDiv.style.zIndex = '9999';
		togglePortfolio();
		currentSwfState = 1;
	}				
}	

// Function used for page tracking in flash. Instead of calling it directly, this method allows for another tracking to be inserted without changing the flash file.
function trackPage(pageId){
	pageTracker._trackPageview(pageId);
}

function addToDelicious(){
	trackAction(encodeURIComponent(location.href), 1, "Add to delicious" , "Delicious", 1, 1);
	window.open('http://del.icio.us/post?v=4&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=700,height=400');
	return false;
}

function trackAction(sku, total, productname, category, unitprice, quantity) {
	var orderNum = getOrderID();
		pageTracker._addTrans(
		orderNum, 
		"", 
		total,
		"", "", "", "",	"" 
	);
					
	pageTracker._addItem(
		orderNum,
		sku,
		productname,	
		category,
		unitprice,
		quantitiy
	);
	pageTracker._trackTrans();
}
			
function mail(to, productname) {
	location.href = "mailto:" + to;		
	trackAction(to, 1, productname, "Contact", 1, 1);
}

function togglePortfolio() {
	$('.mainmenuitems a').hover(function() {
  		$(this).css('background-position', '0 -20px');
	}, function() {
		$(this).css('background-position', '');
	});
	if ($('#flashBox').css('z-index') == 1) {
		$('#flashBox').css('z-index', 100);
	} else {
		setTimeout("$('#flashBox').css('z-index', 1);", 1000);
	}
}
