// JavaScript Document
// Layer realign thing
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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 P7_Snap() { //v2.67 by PVII
 var g,x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,pa='px',args=P7_Snap.arguments;a=parseInt(a);
 if(document.layers||window.opera){pa='';}for(k=0;k<(args.length);k+=4){
 if((g=MM_findObj(args[k]))!=null){if((el=MM_findObj(args[k+1]))!=null){
 a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
 da="document.all['"+args[k]+"']";if(document.getElementById){
 d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
 d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
 }else if(document.all){d=da;}if(document.all||document.getElementById){while(tx==1){
 p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
 }else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);tw=x+ox+y+oy;
 if(tw==0||(navigator.appVersion.indexOf("MSIE 4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){
  ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);}else{
  w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
  x=document.body.scrollLeft+event.clientX+bx;y=document.body.scrollTop+event.clientY;}}
 }else if(document.layers){x=g.x;y=g.y;q0=document.layers,dd="";for(var s=0;s<q0.length;s++){
  dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');
  break;}}}e=(document.layers)?el:el.style;xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
 if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
  xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);}
 e.left=xx+pa;e.top=yy+pa;}}}
}

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')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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 imageHighlight() {
	currentURL = String(window.location);
	splitURL = currentURL.split("/");
	currentPage = (splitURL[3]);
	idSplit = currentPage.split(".");
	currentId = (idSplit[0]);
	
	//alert(currentId);
	
	

	//Work Array
	if(currentPage in {'branding.php':'', 'marketing.php':'','advertisements.php':'' ,'invitations.php':'' }) {
		document.getElementById('work').style.color = "#d5242b";
		P7_Snap('alignhere','subnavbox',215,58);
		MM_showHideLayers('subnavbox','','show');
		document.getElementById(currentId).style.color = "#d5242b";
		
	}
}

function highlightParent(theId) {
	document.getElementById(theId).style.color = "#d5242b";
	
}

function resetHighligh(theId) {
	document.getElementById(theId).style.color = "#7F7F7F";
	
}

function randOrd(){
	return (Math.round(Math.random())-0.5);
}

swapImageTimer = "";
theCallTime = "";
nameArray = new Array ;
currentURL = String(window.location);
	
	//Local
	//theServer = "http://redletter-design.local/";
	//Dev
	//theServer = "http://redletter-designs.byte-productions.com/";
	//Live
	if (location.href == "http://redletter-design.com/"){
		theServer = "http://redletter-design.com/";
	}else{
		theServer = "http://www.redletter-design.com/";
	}
	
	
	


function thumbLoad(myPage) {
	theHtml ="";
	
	if (currentURL == theServer){
		currentPage = "index.php";
		currentId = "index";
	}else{
		splitURL = currentURL.split("/");
		currentPage = (splitURL[3]);
		idSplit = currentPage.split(".");
		currentId = (idSplit[0]);
	}
	
	//defaultArray = new Array('advertise_bayarea.jpg','advertise_bugsbutterflys.jpg','advertise_cadillacurology.jpg','advertise_gtoc.jpg','advertise_gtradiologists.jpg','advertise_maxbauer.jpg','brand_agency.jpg','brand_bayareacontracting.jpg','brand_bianci.jpg','brand_bishopheintz.jpg','brand_bugsbutterflys.jpg','brand_bythebay.jpg','brand_footankle.jpg','brand_freshcutxmas.jpg','brand_gemjam.jpg','brand_maxbauer.jpg','brand_radiologists.jpg','brand_roadgo.jpg','brand_tamarack.jpg','invite_beckywed.jpg','invite_elmerroy.jpg','invite_girlsweekend.jpg','invite_irwinunion.jpg','invite_ks.jpg','invite_ml.jpg','invite_winecheese.jpg','invite_xmas2006.jpg','market_bishopheintz.jpg','market_candyworld.jpg','market_dha.jpg','market_mexus.jpg','market_minersnorth.jpg','market_omenabay.jpg','market_tamarack.jpg','market_traversearts.jpg','market_widing.jpg');
	brandingArray = new Array('brand_agency.jpg','brand_bayareacontracting.jpg','brand_bianci.jpg','brand_bishopheintz.jpg','brand_bugsbutterflys.jpg','brand_bythebay.jpg','brand_footankle.jpg','brand_freshcutxmas.jpg','brand_gemjam.jpg','brand_maxbauer.jpg','brand_radiologists.jpg','brand_roadgo.jpg','brand_tamarack.jpg');
	marketingArray = new Array('market_bishopheintz_1-2.jpg','market_candyworld_1-3.jpg','market_dha_1-2.jpg','market_mexus_1-2.jpg','market_minersnorth_1-2.jpg','market_omenabay_1-3.jpg','market_tamarack_1-4.jpg','market_traversearts_1-2.jpg','market_widing_1-5.jpg');
	advertisementsArray = new Array('advertise_bayarea.jpg','advertise_bugsbutterflys.jpg','advertise_cadillacurology.jpg','advertise_gtoc.jpg','advertise_gtradiologists.jpg','advertise_maxbauer.jpg','advertise_woodenhammer_1-2.jpg');
	invitationsArray = new Array('invite_beckywed.jpg','invite_elmerroy.jpg','invite_girlsweekend.jpg','invite_irwinunion.jpg','invite_ks_1-2.jpg','invite_ml.jpg','invite_winecheese.jpg','invite_xmas2006.jpg');
	
	allArrays = (advertisementsArray +","+ marketingArray +","+ brandingArray  +","+ invitationsArray);
	
	indexArray = allArrays.split(",");
	
	curArrayString = (currentId+'Array');
	curArray = window[curArrayString];
	curArray.sort(randOrd);
	
	
	
	l=curArray.length;
	c=2;
	
	
	
	
	for (i=0, ln=l; i<ln; ++i ){
		
		
		imageSplit = curArray[i].split(".");
		curImageId = (imageSplit[0]);
		curImageName = curImageId+"_name"
		
		if (currentId == "index"){
			theHtml = theHtml +'<span id="'+curImageId+'" style="visibility:hidden;"><a href="#" onMouseOver="showLargeImage(\''+curArray[i]+'\');" onMouseOut="showText(\''+curArray[i]+'\');"><img src="/mainimages/boxes/'+ curArray[i] +'"alt="Click to see larger" border="0" hspace="4" vspace="4" name="'+curImageName+'"></a></span>';	
		}else{
			theHtml = theHtml +'<span id="'+curImageId+'" style="visibility:visible;"><a href="#" onMouseOver="showLargeImage(\''+curArray[i]+'\');" onMouseOut="showText(\''+curArray[i]+'\');"><img src="/mainimages/boxes/'+ curArray[i] +'"alt="Click to see larger" border="0" hspace="4" vspace="4" name="'+curImageName+'" onMouseOver="redSwap(this.name);" onMouseOut="restoreSwap(this.name, \''+curArray[i]+'\');"></a></span>';
		}
		
		
		nameArray.push(curImageId);
		if (i == c){
			theHtml = theHtml+"<br>";
			c=c+3;
		}
		
		if (i == 11){ break; }
				
	}
	
	
	 
	thumbDiv = myPage+'Thumbs';
	document.getElementById(thumbDiv).innerHTML = theHtml;
	
	
	//n = nameArray.length;
	nameArray.sort(randOrd);
	if (currentId == "index"){
		theRandomImage = setTimeout("revealImages(0)", 750);
	}
	


}

function revealImages(pos){
	
	clearTimeout(theRandomImage);
	if (pos < nameArray.length){
		document.getElementById(nameArray[pos]).style.visibility = 'visible';
		theRandomImage = setTimeout("revealImages("+(pos+1)+")", 750);
	}else{
		theBlockImage = setTimeout("blockImages(0)", 750);
	}
}

function redSwap(myImage){
	document[myImage].src = '/mainimages/boxes/red.jpg';
}

function restoreSwap(myImage, mySrc){
	document[myImage].src = '/mainimages/boxes/'+mySrc;
}


function blockImages(pos){
	
	//cool
	//if (pos != 0){ document[theImage].src = '/mainimages/boxes/'+nameArray[pos-1]+".jpg" };
	
	clearTimeout(theBlockImage);
	theImage = nameArray[pos]+"_name";
	
	if (pos < nameArray.length){
		 if (pos%2==1){
			document[theImage].src = '/mainimages/boxes/grey.jpg';
		 }else{
			document[theImage].src = '/mainimages/boxes/red.jpg';
		 }
		theBlockImage = setTimeout("blockImages("+(pos+1)+")", 750);
	}else{
		//cool
		//theBlockImage = setTimeout("blockImages(0)", 1000);
		theReloadImage = setTimeout("reloadImages(0)", 750);
	}	
		
}

function reloadImages(pos){
	
	clearTimeout(theReloadImage);
	theImage = nameArray[pos]+"_name";
	
	if (pos < nameArray.length){
		document[theImage].src = '/mainimages/boxes/'+nameArray[pos]+".jpg"
		theReloadImage = setTimeout("reloadImages("+(pos+1)+")", 750);
	}else{
		theBlockImage = setTimeout("blockImages(0)", 750);
	}
}


function showLargeImage(theImage){
	

	disText = "";
	disclamerArray = new Array('brand_bayareacontracting.jpg', 'brand_bythebay.jpg', 'brand_radiologists.jpg', 'market_widing_1-5.jpg', 'advertise_bugsbutterflys.jpg','invite_irwinunion.jpg', 'market_omenabay_1-3.jpg', 'market_minersnorth_1-2.jpg', 'brand_bianci.jpg', 'market_candyworld_1-3.jpg', 'brand_footankle.jpg', 'brand_freshcutxmas.jpg', 'market_dha_1-2.jpg', 'advertise_bayarea.jpg', 'market_bishopheintz_1-2.jpg','brand_bugsbutterflys.jpg', 'brand_agency.jpg','brand_maxbauer.jpg', 'advertise_maxbauer.jpg', 'brand_bishopheintz.jpg', 'market_traversearts_1-2.jpg', 'advertise_gtoc.jpg', 'advertise_gtradiologists.jpg');
	
	
	
	l=disclamerArray.length;
	for (i=0, ln=l; i<ln; ++i ){
		if (theImage == disclamerArray[i]){
			disText = "Designed while employed at Idea Stream";
			break;
		}
	}
	
	if (currentURL == theServer){
		currentPage = "index.php";
		currentId = "index";
	}else{
		splitURL = currentURL.split("/");
		currentPage = (splitURL[3]);
		idSplit = currentPage.split(".");
		currentId = (idSplit[0]);
	}
	
	contentDiv = currentId+"Content";
	
	document.getElementById(contentDiv).style.visibility = "hidden";
	document.getElementById('largeimage').style.visibility = "visible";

	theImageSplit = theImage.split("_");
	theImageNum = theImageSplit[2];
	theImageBase = theImageSplit[0]+"_"+theImageSplit[1];
	
	if (theImageNum){
		
		if (theImageNum.indexOf("1-") != -1){
			theLengthSplit = theImageNum.split("-");
			lString = theLengthSplit[1];
			l = Number(lString.charAt(0));
			i = 1;

				theSwapImage = ('/mainimages/large/'+theImageBase+"_"+i+"-"+l+".jpg");
				document['theLargeImage'].src = theSwapImage;
				
				swapImageTimer = setTimeout("swapTheNextLarge("+i+","+l+")", 2000);
				theHTML = "viewing "+i+" of "+l+" images";  
				document.getElementById('footer').innerHTML = theHTML+'<br>'+disText;	
		}
		
	}else{
	document.getElementById('footer').innerHTML = disText;	
	document['theLargeImage'].src = '/mainimages/large/'+theImage;
	}
	return;
}

function swapTheNextLarge(i,l){
	i++;
	clearTimeout(swapImageTimer);
	mySwapImage = ('/mainimages/large/'+theImageBase+"_"+i+"-"+l+".jpg");
	document['theLargeImage'].src = mySwapImage;
	
	theHTML = "viewing "+i+" of "+l+" images";  
	
	if(i == l){
		i = 0;
	}
	
	swapImageTimer = setTimeout("swapTheNextLarge("+i+","+l+")", 2000);
	document.getElementById('footer').innerHTML = theHTML+'<br>'+disText;
}

function showText(){
	
	document.getElementById('footer').innerHTML = "";
	
	if (swapImageTimer){
		clearTimeout(swapImageTimer);
	}
	contentDiv = currentId+"Content";
	document.getElementById('largeimage').style.visibility = "hidden";
	document.getElementById(contentDiv).style.visibility = "visible";
	
}


function initImage() {
  imageId = 'largeImageFade';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 100/4;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

//-->
