// JavaScript Document

///UTILITIES////
function loaders(jsonStrFns){
	for (t=0;t<jsonStrFns.length;t++){
		valueStr='';
		for (v=0;v<jsonStrFns[t][1].length;v++){
			valueStr+="'"+jsonStrFns[t][1][v]+"'";
			if (v!=jsonStrFns[t][1].length-1){valueStr+=",";}	
		}
		functionStr=jsonStrFns[t][0]+"("+valueStr+")";
		eval(functionStr);		
	}
}
function btn_overs(sel, newImage){
	var theImage=document.getElementById(sel);
	theImage.src=newImage;
}
function createLoaderDiv(divId){
	var newdiv = document.createElement('div');
	newdiv.setAttribute('id', divId);
	document.getElementById("preloadDiv").appendChild(newdiv);
}
function removeLoaderDiv(divId){//preloadDiv the parent Div
	var child = document.getElementById(divId);
	var parent = document.getElementById("preloadDiv");
	parent.removeChild(child);
}
//END UTILITIES///



////FLASH EMBED STUFF///////
function setTitle(title,theDiv){
	var flash='/images/siteAssets/titles/pageTitle.swf?theText='+title;	
	loadFlashInDiv(flash,theDiv);
}

function loadFlashInDiv(flash,theDiv){
	var flash_width="100%";
	var flash_height="100%";
	var version='8,0,24,0';
	var str='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+'" width="'+flash_width+'" height="'+flash_height+'">';
	str+='<param name="movie" value="'+flash+'"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="SCALE" value="noborder">';
	str+='<embed src="'+flash+'" width="'+flash_width+'" height="'+flash_height+'" wmode="transparent" scale="noborder" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>';
	var theTarg=document.getElementById(theDiv);
	theTarg.innerHTML=str;
	//new Effect.Opacity(theTarg, { from: 0, to: 1 });//fade in
}
/////END FLASH EMBED STUFF

///popup div
function loadVid(vid){
	//var flash='http://danzank.com/cms/get/flash/video.swf?vid='+vid;
	//loadFlashInDiv(flash,'vidStage');
	var url='http://danzank.com/cms/get/flash/vid.php?vid='+vid;
	document.getElementById('vidFrame').src=url;
	return fade('popup');
}

function closeVid(){
	var url='http://danzank.com/cms/get/flash/vid.php';
	document.getElementById('vidFrame').src=url;
	fade('popup','page');
}


function fade(messId,destLink) {
if(!document.getElementById) return true;
if(!document.getElementById("popup")) return true;

var hide = document.getElementById("popup");
var htmlEl = document.getElementsByTagName('html')[0];
var mesEl = document.getElementById(messId);
var dest = '#';
if(htmlEl.id == null) return true;
		if(htmlEl.id =="fade-off") {
			htmlEl.id=htmlEl.id.replace(new RegExp("fade-off\\b"), "fade-on");
			mesEl.style.display="block";
			return false;
			}
			else if (htmlEl.id =="fade-on") {		
			htmlEl.id=htmlEl.id.replace(new RegExp("fade-on\\b"), "fade-off");
		 	mesEl.style.display="none";
			window.location = dest;
			return false;
		}
 return true;
}
//end popup


function readMoreSwap(id,direction,dur) {
var theDiv='details_'+id;
var theTextDiv='moreText_'+id;
var theTextLink=document.getElementById(theTextDiv);
var moreDiv='more_'+id;
var lessDiv='less_'+id;
var readMore=document.getElementById(moreDiv);
var readLess=document.getElementById(lessDiv);

switch (direction){
case 'down':
Effect.BlindDown(theDiv, { duration: dur });
readLess.style.display='block';
//theTextLink.style.display='none';
readMore.style.display='none';

break;case 'up':
 Effect.BlindUp(theDiv, { duration: dur });
readLess.style.display='none';
readMore.style.display='block';
 //theTextLink.style.display='inline';
break;
}
}
