/* Used for embedding flashtext elements such as page titles */

function embedFlashTitle(src, text, width, height) {

	var hasRightVersion = DetectFlashVer(requiredMajorVersion,0,0);
	if(hasRightVersion) { 
		AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width',''+width+'','height',''+height+'','src','/flash/'+src+'','quality', 'high', 'FlashVars', 'titletext='+text+'&wid='+width+'', 'wmode', 'transparent', 'scale','noscale','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','/flash/'+src); //end AC code
	    
	    

	    
	    //document.write('<object codebase="ttp://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="200" height="11" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"> <param name="movie" value="/flash/subtitle_white.swf" /> <param name="quality" value="high" /> <param name="FlashVars" value="titletext=PRESS ROOM&wid=200" /> <param name="wmode" value="transparent" /> <param name="scale" value="noscale" /> <embed width="200" height="11" src="/flash/subtitle_white.swf" quality="high" FlashVars="titletext=PRESS ROOM&wid=200" wmode="transparent" scale="noscale" pluginspage="http://www.macromedia.com/go/getflasherplayer" type="application/x--shockwave-flash" ></embed></object>');
	    
	}else{
		document.write('Unable to load flash, please check your version');
	}
}

var listx = new Array();
function overlay_bg(){
	
	 document.getElementById("ez_overlay").style.visibility = "visible";
     document.getElementsByTagName("body")[0].style.overflow = "hidden";
	
}

function closeoverlay_bg(){

 document.getElementById("ez_overlay").style.visibility = "hidden";
     document.getElementsByTagName("body")[0].style.overflow = "auto";

}

 
/* Embed Quicktime */

function embedQuicktime(src, width, height) {
document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="'+height+'" width="'+width+'">');
document.write('<param name="src" value="'+src+'" />');
document.write('<param name="autoplay" value="true" />');
document.write('<param name="controller" value="true" />');
document.write('<embed src="'+src+'" height="'+height+'" width="'+width+'" autoplay="true" type="video/quicktime" controller="true" pluginspage="http://www.apple.com/quicktime/download/">');
document.write('</object>');
}



/* Popup Browser checker for Portfolios */

function popupCheck(id) {

    if(BrowserDetect.version < "3" && BrowserDetect.browser == "Firefox") {
        //alert(BrowserDetect.OS);
        window.location = "http://www.balancestudios.com/en-us/portfolio/pod.aspx?pd="+id+"&rd=1";
    }
}


/* Used for the DHTML dropdowns on homepage */

var menuInt;
var listx = new Array();
function openMenu(pass){
	if (listx[pass] == "shown") closeMenu(pass);
	else {
	clearInterval( menuInt );
	menuInt = setInterval( "expandDiv(180, '"+pass+"' )",30 );
	listx[pass] = "shown";
	opacity("button"+pass+"", "0", "100", "300");

    document.getElementById("view"+pass).src = "/images/btn_HideReel.gif";
    document.getElementById("view"+pass).alt = "Hide Reel";
    
     if(pass == "1") {
       if(document.getElementById("object3").style.display == "block") document.broadcast_mov.Stop();
    }else if(pass == "3") {
       if(document.getElementById("object1").style.display == "block") document.animation_mov.Stop();
    }
}

function closeMenu(pass){

	if(pass != "2") {
	    
	    
	    if(pass == "1") {
	        if(document.getElementById("object1").style.display == "block") document.animation_mov.Rewind();
	        if(document.getElementById("object1").style.display == "block") document.animation_mov.Stop();
	        document.getElementById("splash1").style.display = "block";
	        document.getElementById("object"+pass).style.display = "none";
	        
	    }else if(pass == "3") {
	        if(document.getElementById("object3").style.display == "block") document.broadcast_mov.Rewind();
	        if(document.getElementById("object3").style.display == "block") document.broadcast_mov.Stop();
	        document.getElementById("splash3").style.display = "block";
	        document.getElementById("object"+pass).style.display = "none";
	    }

	}
	clearInterval( menuInt );
	menuInt = setInterval( "collapseDiv(0, '"+pass+"')",30 );
	listx[pass] = "hidden";
        
        
	document.getElementById("view"+pass).src = "/images/btn_ViewReel.gif";
	document.getElementById("view"+pass).alt = "View Reel";
	}

}


function expandDiv(hd, id){
	var topmenu_height = hd;
	var topmenu = document.getElementById('topmenu'+id);
	current_height = topmenu.offsetHeight;
	new_height = Math.ceil(((topmenu_height-current_height)/3)+topmenu.offsetHeight);
	topmenu.style.height = new_height + "px";
	if( topmenu.offsetHeight == topmenu_height ){
		clearInterval(menuInt);
	}
	
}

function collapseDiv(hd, id){
	var topmenu_height = hd;
	var topmenu = document.getElementById('topmenu'+id);
	
	current_height = topmenu.offsetHeight;
	new_height = Math.floor(((topmenu_height-current_height)/2)+topmenu.offsetHeight);
	topmenu.style.height = (new_height) + "px";
	if( topmenu.offsetHeight == topmenu_height ){
		clearInterval(menuInt);
		//alert( "Cleared" );
	}
	

}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
    
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function showQuicktime(id, src, width, height) {
    if(id == "1") document.getElementById("splash1").style.display = "none";
    if(id == "3") document.getElementById("splash3").style.display = "none";
	opacity("button"+id, "100", "0", "300");
	setTimeout('document.getElementById("object'+id+'").style.display = "block"', 1000);
}


/* This is for the portfolio icons fading in and out */

function showSet(x) {

    var anchors = document.getElementsByTagName("a");
    var acount = 0;
    var ids = new Array();
    var anchset_id = x.substr(6);
    // First we do a loop to find all the anchor tags
    for(y=0; y<=anchors.length-1; y++) {
        myid = "";
        if(anchors[y].id == "setanch"+anchset_id && anchors[y].className == "set") {
            anchors[y].className = "on set";
            
        }
        else if(anchors[y].className == "set" || anchors[y].className == "on set"){
            anchors[y].className = "set";
         }   
        
        
        if(anchors[y].className == x) {
            
            myid = anchors[y].id;
            // This establishes are actual unique ID of the <li>, <a> and <img>
            var mynum = myid.substr(4);
            
            // Now loop to find all the images, because we need to know the source
            var imgs = document.getElementsByTagName("img");
            for(b=0;b<imgs.length;b++) {
                if(imgs[b].id == "img"+mynum) {
                    var src = imgs[b].src;
                    
                    // finally do a loop on all <li>s, so that we may change the inner HTML of it
                    var lis = document.getElementsByTagName("li");
                    for(a=0;a<lis.length;a++) {
                        if(lis[a].id == "li"+mynum) {
                            document.getElementById(lis[a].id).innerHTML = '<a style="filter:alpha(opacity=75); -moz-opacity:.75; opacity:.75" class="'+x+'" href="#" id="port'+ mynum + '" onmouseover="$(\'#port' + mynum + '\').fadeTo(200, 0.99);" onmouseout="$(\'#port' + mynum + '\').fadeTo(200, 0.75);" onclick="AJAXLoad(\'/en-us/portfolio/pod.aspx?pd=' + String(mynum) + '\');return false;"><img id="img'+mynum+'" src="'+src+'" /></a>';                       
                        }
                    }
                    
                }
            
            } 
        }else if(anchors[y].className.slice(0,6) == "option") {
            
            myid = anchors[y].id;
            // This establishes are actual unique ID of the <li>, <a> and <img>
            var mynum = myid.substr(4);
            
            // Now loop to find all the images, because we need to know the source
            var imgs = document.getElementsByTagName("img");
            for(b=0;b<imgs.length;b++) {
               if(imgs[b].id == "img"+mynum) {
                    var src = imgs[b].src;
                    
                    // finally do a loop on all <li>s, so that we may change the inner HTML of it
                    var lis = document.getElementsByTagName("li");
                    for(a=0;a<lis.length;a++) {
                        if(lis[a].id == "li"+mynum) {
                            document.getElementById(lis[a].id).innerHTML = '<a style="filter:alpha(opacity=25); -moz-opacity:.25; opacity:.25" class="'+anchors[y].className+'" href="#" id="port'+ mynum + '" onmouseover="$(\'#port' + mynum + '\').fadeTo(200, 0.99);" onmouseout="$(\'#port' + mynum + '\').fadeTo(200, 0.25);" onclick="AJAXLoad(\'/en-us/portfolio/pod.aspx?pd=' + String(mynum) + '\');return false;"><img id="img'+mynum+'" src="'+src+'" /></a>';          
                        }
                    }
                    
                }
             
            } 
            
        }
    }
    
}


/* Used for hiding/showing listings */

var listx = new Array();
function hidediv(pass) {
	var divs = document.getElementsByTagName('div');
	for(i = 0; i < divs.length; i++) {
		if(document.getElementById("img_"+pass+"")) document.getElementById("img_"+pass+"").src = "/images/ico_plus.gif";
		
		if (divs[i].id == ("cont_" + pass)) {
			if (document.getElementById) // DOM3 = IE5, NS6
				divs[i].style.display = 'none';
			else {
				if (document.layers) {
					document.layers[divs[i]].display = 'none';
					document.layers[divs[i]].position = 'absolute';
				}
				else {
					document.all.hideShow.divs[i].visibility = 'none';
					document.all.hideShow.divs[i].position = 'absolute';
				}
			}
		}
	}
	
	listx[pass] = "hidden";
}
function showdiv(pass) {
	if (listx[pass] == "shown") hidediv(pass);
	else {
		var divs = document.getElementsByTagName('div');
		if(document.getElementById("img_"+pass+"")) document.getElementById("img_"+pass+"").src = "/images/ico_minus.gif";
		
		for(i = 0; i < divs.length; i++) {
			if (divs[i].id == ("cont_" + pass)) {
				if (document.getElementById) {
					// IE 6+/NN6
					divs[i].style.display = 'block';
				}
				else {
					if (document.layers) {
						//netscape 5
						document.layers[divs[i]].display = 'block';
						document.layers[divs[i]].position = 'relative';
					}
					else {
						// IE 4 and 5 not 5+
						document.all.hideShow.divs[i].visibility = 'block';
						document.all.hideShow.divs[i].position = 'relative';
					}
				}
			}
		}
		listx[pass] = "shown";
	}
}



/* Used for homepage Interactive slideshow */


function interactiveSlideshow(action) {

   InteractiveAssets();
if (document.images)
{
  preload_image_object = new Image();
  // set image url
//  image_url = new Array();
//  url = new Array(); 
//    
//  image_url[0] = "/images/interactive_ss/med_get_fresh.gif";
//  image_url[1] = "/images/interactive_ss/med_ceili_rain.gif";
//  image_url[2] = "/images/interactive_ss/med_cottonelle_grab_game.gif";
//  image_url[3] = "/images/interactive_ss/med_outsider.gif";
//  image_url[4] = "/images/interactive_ss/med_prestige.gif";
//  image_url[5] = "/images/interactive_ss/med_ki_seeitspecit.gif";
//  image_url[6] = "/images/interactive_ss/med_screen.gif";
//  image_url[7] = "/images/interactive_ss/med_jotogo.gif";
//  image_url[8] = "/images/interactive_ss/med_osmiami.gif";
//  image_url[9] = "/images/interactive_ss/med_lsb.gif";
//  image_url[10] = "/images/interactive_ss/med_wct.gif";
//  image_url[11] = "/images/interactive_ss/med_arclakeland.gif";

//  
//  url[0] = "http://www.getfreshfruit.com";
//  url[1] = "http://www.ceilirain.com";
//  url[2] = "http://www.balancestudios.com/balancebeam/showcase/cottonelle_popgame.htm";
//  url[3] = "http://www.outsiderinc.com";
//  url[4] = "http://www.prestigeparktowers.com";
//  url[5] = "http://www.kihealthcare.com/gallery_view.aspx?glid=113";
//  url[6] = "http://www.screenmag.tv";
//  url[7] = "http://www.jotogo.com";
//  url[8] = "http://www.osmiami.com";
//  url[9] = "http://www.lsb.com/";
//  url[10] = "http://www.wisconsinconnectiontours.com";
//  url[11] = "http://www.arclakeland.org";

  


   var i = 0;
   var med_container = document.getElementById("med_cont");
   var link = document.getElementById("launch_link");
   var enlarge = document.getElementById("enlarge_link");
   //var med_container_src = med_container.src.slice(31, med_container.src.length);
   //USE FOR REAL SITE
   var med_container_src = med_container.src.slice(29, med_container.src.length);
   
   for(i=0; i<=image_url.length; i++) {
	 preload_image_object.src = image_url[i];
	 
	 if(action == "next") {
	    
	    if(image_url[i] == med_container_src)   
	        if(i == image_url.length-1) {
	            med_container.src = image_url[0];
	            link.href = url[0];
	            enlarge.onclick = function() { QBox_Port('',''+i+'','','');return false; }
	        }else{
	            var num = i + 1;
	            med_container.src = image_url[num];
	            link.href = url[num];
	            enlarge.onclick = function() { QBox_Port('',''+num+'','','');return false; }
	        }
	        
	        
	 }else if(action == "prev") {
	    if(image_url[i] == med_container_src)   
	        
	        if(i == 0) {
	           med_container.src = image_url[image_url.length-1];
	           link.href = url[url.length-1];
	           enlarge.onclick = function() { QBox_Port('',''+url.length-1+'','','');return false; }
	        }else{
	           var num = i - 1;
	           med_container.src = image_url[num];
	           link.href = url[num];
	           enlarge.onclick = function() { QBox_Port('',''+(num)+'','','');return false; }
	        }
	 }    
	 
  } } }
 	 
function interactiveSlideshow_LG(action) {

    if (document.images)
    {
      preload_image_object = new Image();
      // set image url
//      image_url = new Array();
//      url = new Array(); 
           InteractiveAssetsLG();
//  image_url[0] = "/images/interactive_ss/source_get_fresh.jpg";
//  image_url[1] = "/images/interactive_ss/source_ceili_rain.jpg";
//  image_url[2] = "/images/interactive_ss/source_cottonelle_grab_game.jpg";
//  image_url[3] = "/images/interactive_ss/source_outsider.jpg";
//  image_url[4] = "/images/interactive_ss/source_prestige.jpg";
//  image_url[5] = "/images/interactive_ss/source_ki_seeitspecit.jpg";
//  image_url[6] = "/images/interactive_ss/source_screenmag.jpg";
//  image_url[7] = "/images/interactive_ss/source_jotogo.jpg";
//  image_url[8] = "/images/interactive_ss/source_osmiami.jpg";
//  image_url[9] = "/images/interactive_ss/source_lsb.jpg";
//  image_url[10] = "/images/interactive_ss/source_wct.jpg";
//  image_url[11] = "/images/interactive_ss/source_arclakeland.jpg";

//  
//  url[0] = "http://www.getfreshfruit.com";
//  url[1] = "http://www.ceilirain.com";
//  url[2] = "http://www.balancestudios.com/balancebeam/showcase/cottonelle_popgame.htm";
//  url[3] = "http://www.outsiderinc.com";
//  url[4] = "http://www.prestigeparktowers.com";
//  url[5] = "http://www.kihealthcare.com/gallery_view.aspx?glid=113";
//  url[6] = "http://www.screenmag.tv";
//  url[7] = "http://www.jotogo.com";
//  url[8] = "http://www.osmiami.com";
//  url[9] = "http://www.lsb.com/";
//  url[10] = "http://www.wisconsinconnectiontours.com";
//  url[11] = "http://www.arclakeland.org";
//      


       var i = 0;
       var med_container = document.getElementById("med_cont_LG");
       var link = document.getElementById("launch_link_LG");
       //var med_container_src = med_container.src.slice(31, med_container.src.length);
       
       //USE FOR REAL SITE
       var med_container_src = med_container.src.slice(29, med_container.src.length);
      
       
       for(i=0; i<=image_url.length; i++) {
	     preload_image_object.src = image_url[i];
    	 
	     if(action == "next") {
	        if(image_url[i] == med_container_src)   
	            if(i == image_url.length-1) {
	                med_container.src = image_url[0];
	                link.href = url[0];
	            }else{
	                med_container.src = image_url[i+1];
	                link.href = url[i+1];
	            }
    	        
    	        
	     }else if(action == "prev") {
	        if(image_url[i] == med_container_src)   
    	        
	            if(i == 0) {
	               med_container.src = image_url[image_url.length-1];
	               link.href = url[url.length-1];
	            }else{
	               med_container.src = image_url[i-1];
	               link.href = url[i-1];
	            }
	     }    
    	 
      }
    }
}

//function GalleryAssets(gallery) {
//    
//      image_url = new Array();
//      caption = new Array(); 
//        
//        switch(gallery) {
//        
//            case "fun":
//                image_url[0] = "/images/environment/05_11_07/fun/Birthday_Celebration.jpg";
//                caption[0] = "Birthday Celebration";

//                image_url[1] = "/images/environment/05_11_07/fun/Bowling_German_Tina.jpg";
//                caption[1] = "Bowling German Tina!";

//                image_url[2] = "/images/environment/05_11_07/fun/Celctic_D_Bowling.jpg";
//                caption[2] = "Celtic D Bowling!";

//                image_url[3] = "/images/environment/05_11_07/fun/Darren_Hall_of_personalities.jpg";
//                caption[3] = "Darren's Hall of Personalities";

//                image_url[4] = "/images/environment/05_11_07/fun/Disney_Darren_Tina_Dan.jpg";
//                caption[4] = "Darren, Tina, and Dan's Disney Adventure";

//                image_url[5] = "/images/environment/05_11_07/fun/Dr_T_w_Cheese_hat.jpg";
//                caption[5] = "Dr T with his Cheese Hat";

//                image_url[6] = "/images/environment/05_11_07/fun/GroundHog_3.jpg";
//                caption[6] = "Kerstin on Ground Hogs Day";

//                image_url[7] = "/images/environment/05_11_07/fun/GroundHog_Action_shot.jpg";
//                caption[7] = "Ground Hog's festivities";

//                image_url[8] = "/images/environment/05_11_07/fun/GroundHog_Annual_Musical_Chairs.jpg";
//                caption[8] = "Bert doesn't spill.";

//                image_url[9] = "/images/environment/05_11_07/fun/GroundHog_Group.jpg";
//                caption[9] = "Serious drinking going down on Ground Hog's Day";

//                image_url[10] = "/images/environment/05_11_07/fun/GroundHog_Kiss.jpg";
//                caption[10] = "Live Ground Hog's day performance by KISS aka Buck Russell and the Grippy Slippers";

//                image_url[11] = "/images/environment/05_11_07/fun/GroundHog_Set_Up.jpg";
//                caption[11] = "Setting up for the Ground Hog's party";

//                image_url[12] = "/images/environment/05_11_07/fun/Happy_40th_Darren.jpg";
//                caption[12] = "Happy 40th Darren!";

//                image_url[13] = "/images/environment/05_11_07/fun/LA_Disney_Welcome_sign.jpg";
//                caption[13] = "Entering Disneyland ";

//                image_url[14] = "/images/environment/05_11_07/fun/Tina_Finally_At_Gobblers_Knob.jpg";
//                caption[14] = "Tina has arrived";

//                image_url[15] = "/images/environment/05_11_07/fun/Tina_Finally_At_Gobblers_Knob_2.jpg";
//                caption[15] = "Tina awaiting Phil";

//                image_url[16] = "/images/environment/05_11_07/fun/Tina_Finally_At_Gobblers_Knob_3.jpg";
//                caption[16] = "Tina at Gobbler's Knob";
//                break;
//            
//            case "travels":
//                image_url[0] = "/images/environment/05_11_07/travels/DC_Lincoln.jpg";
//                caption[0] = "Spending time with Lincoln";

//                image_url[1] = "/images/environment/05_11_07/travels/DC_WWII_memorial.jpg";
//                caption[1] = "Washington, D.C.";

//                image_url[2] = "/images/environment/05_11_07/travels/Japan_D_Tomio_MoCap.jpg";
//                caption[2] = "Darren at Wine Studios - Sendai, Japan";

//                image_url[3] = "/images/environment/05_11_07/travels/Japan_Darren_Mocap.jpg";
//                caption[3] = "Darren sporting his motion capture suit";

//                image_url[4] = "/images/environment/05_11_07/travels/Japan_Darren_Tina_MoCap.jpg";
//                caption[4] = "Who's actually taller?";

//                image_url[5] = "/images/environment/05_11_07/travels/Japan_Group_In_Conference.jpg";
//                caption[5] = "Sanjeev, DC, Dan, Nyouki, Darren, Tina - Sendai, Japan";

//                image_url[6] = "/images/environment/05_11_07/travels/Japan_MeySen_1.jpg";
//                caption[6] = "Darren, Dan and Tina at Meysen School - Sendai, Japan";

//                image_url[7] = "/images/environment/05_11_07/travels/Japan_MeySen_2.jpg";
//                caption[7] = "Meysen School - Sendai, Japan";

//                image_url[8] = "/images/environment/05_11_07/travels/Japan_Studios_shot.jpg";
//                caption[8] = "Wine Studios' Motion Capture Studio";

//                image_url[9] = "/images/environment/05_11_07/travels/Japan_Welcome_sign.jpg";
//                caption[9] = "Train Station in Tokyo, Japan";

//                image_url[10] = "/images/environment/05_11_07/travels/Japan_Wine_Studios.jpg";
//                caption[10] = "Wine Studios - Sendai, Japan";

//                image_url[11] = "/images/environment/05_11_07/travels/Japan_with_group.jpg";
//                caption[11] = "Bill, Katherine, Dan, Tina, and Darren";

//                image_url[12] = "/images/environment/05_11_07/travels/LA_DiNozzi_Rudy_Etc.jpg";
//                caption[12] = "Bob Dinozzi, Tina, Rudy Sarzo, Dan, Razor, Darren, Luz Mary";

//                image_url[13] = "/images/environment/05_11_07/travels/LA_Robbies.jpg";
//                caption[13] = "Darren, Jeff, Luz Mary, tina, Razor, Dan";

//                image_url[14] = "/images/environment/05_11_07/travels/LA_Tina_Darren_Rudy_Sarzo.jpg";
//                caption[14] = "Darren, Tina, and Rudy";

//                image_url[15] = "/images/environment/05_11_07/travels/Seattle_GC_Shoot.jpg";
//                caption[15] = "Dan on film shoot - Seattle";
//                break;
//            
//            case "work":
//                image_url[0] = "/images/environment/05_11_07/work/Balance_Group_shot_Thomas_and_hats.jpg";
//                caption[0] = "The Balance Clan";
//                
//                 image_url[1] = "/images/environment/05_11_07/work/Balance_Group_Shot_w_Thomas.jpg";
//                caption[1] = "The Balance Family";
//                
//                image_url[2] = "/images/environment/05_11_07/work/Balance_Group_Shot_with_Thomas_laughing.jpg";
//                caption[2] = "The Balance Insanity";
//                
//                image_url[3] = "/images/environment/05_11_07/work/Balance_Open_Sign.jpg";
//                caption[3] = "Cool sign in studio";
//                
//                image_url[4] = "/images/environment/05_11_07/work/Beagle_On_screen.jpg";
//                caption[4] = "Stardogs Development";
//                
//                image_url[5] = "/images/environment/05_11_07/work/Brett_Kerstin.jpg";
//                caption[5] = "Bert and Fish";
//                
//                image_url[6] = "/images/environment/05_11_07/work/Dog_Inside_Model.jpg";
//                caption[6] = "Stardogs Development";
//                
//                image_url[7] = "/images/environment/05_11_07/work/Dog_Model.jpg";
//                caption[7] = "Stardogs Development";
//                
//                image_url[8] = "/images/environment/05_11_07/work/Dogs_Muzzle.jpg";
//                caption[8] = "Stardogs Development";
//                
//                image_url[9] = "/images/environment/05_11_07/work/Dr_Thomas_Tang_GrapeCity.jpg";
//                caption[9] = "Dr Thomas Tang from Grape City";
//                
//                image_url[10] = "/images/environment/05_11_07/work/Jerrod_Grakin.jpg";
//                caption[10] = "Jerrod and Grakin";
//                
//                image_url[11] = "/images/environment/05_11_07/work/Jerrod_Monitor_Mirror.jpg";
//                caption[11] = "Jerrod's monitors and mirror";
//                
//                image_url[12] = "/images/environment/05_11_07/work/Joshua_Tomio_visit_Balance.jpg";
//                caption[12] = "Joshua Tomio visits Balance";
//                
//                image_url[13] = "/images/environment/05_11_07/work/Seamus_Monitor.jpg";
//                caption[13] = "Seamus on monitor";
//                
//                image_url[14] = "/images/environment/05_11_07/work/Steve_D_Jerrod.jpg";
//                caption[14] = "Steve, Darren and Jerrod";
//                
//                image_url[15] = "/images/environment/05_11_07/work/Steve_Snippets.jpg";
//                caption[15] = "Steve and snippets";
//                
//                image_url[16] = "/images/environment/05_11_07/work/Studios_foosball.jpg";
//                caption[16] = "Studio Foosball Table"; 
//                break;
//        
//        }
//     
//}

function PhotoGallery(action,gallery) {

    if (document.images)
    {
      preload_image_object = new Image();
      GalleryAssets(gallery);

    

       var i = 0;
       var med_container = document.getElementById("photo_LG");
       var caption_cont = document.getElementById("caption_LG");
       //var med_container_src = med_container.src.slice(31, med_container.src.length);
       
       //USE FOR REAL SITE
       var med_container_src = med_container.src.slice(29, med_container.src.length);
      
       
       for(i=0; i<=image_url.length; i++) {
	     preload_image_object.src = image_url[i];
    	 
	     if(action == "next") {
	        //alert(med_container_src + "==" + image_url[i]);
	        if(image_url[i] == med_container_src)   
	            if(i == image_url.length-1) {
	                med_container.src = image_url[0];
	                caption_cont.innerHTML = caption[0];
	            }else{
	            
	                med_container.src = image_url[i+1];
	                caption_cont.innerHTML = caption[i+1];
	            }
    	        
    	        
	     }else if(action == "prev") {
	        if(image_url[i] == med_container_src)   
    	        
	            if(i == 0) {
	               med_container.src = image_url[image_url.length-1];
	               caption_cont.innerHTML = caption[caption.length-1];
	            }else{
	               med_container.src = image_url[i-1];
	               caption_cont.innerHTML = caption[i-1];
	            }
	     }    
    	 
       } 
    }
}



/* Browser Check */

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();









/* -----AJAX CONFIG -------------------------------------------------------------------*/

var what = "AjaxStatus(req.responseText)";
function DoCallback(url)
{
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open('GET', url, true);
        req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject('Microsoft.XMLHTTP')
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open('GET', url, true);
            req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            req.send(null);
        }
    }
}

function processReqChange() {
    // only if req shows 'loaded'
    if (req.readyState == 4) {
        // only if 'OK'
        if (req.status == 200) {
            eval(what);
        } else {
            alert('There was a problem retrieving the XML data: ' + req.responseText);
        }
    }
}

function AjaxStatus(Status)
{			
	
	if(Status == "SendFriend_Success") {
        document.getElementById("ctl00_ContentPlaceHolder1_ctl00_successmsg").innerHTML = "Success, your message has been sent!";
	    trigger_hideme("share");
	}else if(Status == "Contact_Success") {
        document.getElementById("ctl00_ContentPlaceHolder1_ctl00_con_successmsg").innerHTML = "Success, your message has been sent!";
	    trigger_hideme("contact");
	}
	
}

function trigger_hideme(type) {
	if(type == "share") {
	    var name1=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_Name1');
        var email1=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_Email1');
        var name2=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_Name2');
        var email2=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_Email2');
        var pid=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_HdnID');
        var msg=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_Msg');
        var type=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_HdnType');
        name1.value = "";
        name2.value = "";
        email1.value = "";
        email2.value = "";
        if(type.value == "Video")
            msg.value = "Please check out this video.";
        else if(type.value == "Link")
            msg.value = "Please check out this link.";
            
	}else if(type == "contact") {
	    var name=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_Name');
        var company=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_Company');
        var email=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_Email');
        var phone=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_Phone');
        var pid=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_HdnID');
        var msg=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_Msg');
        name.value = "";
        company.value = "";
        email.value = "";
        phone.value = "";
        msg.value = "";
	}
}


/* AJAX/JS FOR PORTFOLIO */

function showDetails(val) {
    document.getElementById("sd1").className = "a_share on";
    document.getElementById("details").style.display = "block";

    document.getElementById("sd2").className = "a_share";
    document.getElementById("share").style.display = "none";

    document.getElementById("sd3").className = "a_share";
    document.getElementById("contact").style.display = "none";
}
function showShare(val) {
    if(BrowserDetect.browser == "Explorer")
        if(document.movie)
            document.movie.Stop();

    document.getElementById("sd1").className = "a_share";
    document.getElementById("details").style.display = "none";

    document.getElementById("sd2").className = "a_share on";
    document.getElementById("share").style.display = "block";

    document.getElementById("sd3").className = "a_share";
    document.getElementById("contact").style.display = "none";
}

function showContact(val) {
    if(BrowserDetect.browser == "Explorer")
        if(document.movie)
            document.movie.Stop();

    document.getElementById("sd1").className = "a_share";
    document.getElementById("details").style.display = "none";

    document.getElementById("sd2").className = "a_share";
    document.getElementById("share").style.display = "none";

    document.getElementById("sd3").className = "a_share on";
    document.getElementById("contact").style.display = "block";
}

function SendFriend(input, val){
 
    var name1=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_Name1');
    var email1=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_Email1');
    var name2=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_Name2');
    var email2=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_Email2');
    var pid=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_HdnID');
    var msg=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_share_Msg');
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var error = 0;
    
    document.getElementById("ctl00_ContentPlaceHolder1_ctl00_successmsg").style.visibility = "hidden";
    // This checks to make sure these events are triggered onblur, not on the button send being clicked
    if(val == "") {
        // Check to see if the field is filled out
        if(input.value == "") {
        
            input.className = "share_txt ERROR";
                        
        }else{
        
            input.className = "share_txt";
        
            // Let's see if this input is an Email address, based on the ID name
            if(input.id.indexOf("Email") > 0) {
            
                if(reg.test(input.value) == false) {
                
                    input.className = "share_txt ERROR";
                }else{
                    input.className = "share_txt";
                }
            
            }
        }
        
        var inputs = document.getElementsByTagName("input");
        var count = 0;
        document.getElementById("error").style.display = "none";
        for(i = 0; i < inputs.length; i++) {
            if(inputs[i].className == "share_txt ERROR") {
                document.getElementById("error").style.display = "block";
                count++;
            }
        }
        
    }else if(val == "send") {

        if (name1.value == '')
        {
            error = 1;
            name1.className = "share_txt ERROR";
            
        }
        if(reg.test(email1.value) == false) 
        {
            error = 1;
            email1.className = "share_txt ERROR";
        }
        if (name2.value == '')
        {
            error = 1;
            name2.className = "share_txt ERROR";
        }
        if(reg.test(email2.value) == false) {
            error = 1;
            email2.className = "share_txt ERROR";
        }
    
        if(error != 1)
        {
            document.getElementById("error").style.display = "none";
            if(val == "send"){
            document.getElementById("ctl00_ContentPlaceHolder1_ctl00_successmsg").style.visibility = "visible";
            DoCallback("http://www.balancestudios.com/en-us/portfolio/ajax.aspx?method=sendfriend&name1="+name1.value+"&email1="+email1.value+"&name2="+name2.value+"&email2="+email2.value+"&pid="+pid.value+"&msg="+msg.value);
            }
        }
        else
        {
            document.getElementById("error").style.display = "block";
        }
    }
}

function Contact(input, val){
 
    var name=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_Name');
    var company=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_Company');
    var email=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_Email');
    var phone=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_Phone');
    var pid=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_HdnID');
    var msg=document.getElementById('ctl00_ContentPlaceHolder1_ctl00_con_Msg');
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var error = 0;
    
    document.getElementById("ctl00_ContentPlaceHolder1_ctl00_con_successmsg").style.visibility = "hidden";
    // This checks to make sure these events are triggered onblur, not on the button send being clicked
    if(val == "") {
        // Check to see if the field is filled out
        if(input.value == "") {
        
            input.className = "share_txt ERROR";
                        
        }else{
        
            input.className = "share_txt";
        
            // Let's see if this input is an Email address, based on the ID name
            if(input.id.indexOf("Email") > 0) {
            
                if(reg.test(input.value) == false) {
                
                    input.className = "share_txt ERROR";
                }else{
                    input.className = "share_txt";
                }
            
            }
        }
        
        var inputs = document.getElementsByTagName("input");
        document.getElementById("con_error").style.display = "none";
        for(i = 0; i < inputs.length; i++) {
            if(inputs[i].className == "share_txt ERROR") {
                document.getElementById("con_error").style.display = "block";
            }
        }
        var txts = document.getElementsByTagName("textarea");
        for(t = 0; t < txts.length; t++) {
            if(txts[t].className == "share_txtarea ERROR") {
                document.getElementById("con_error").style.display = "block";
            }
        }
        
    }else if(val == "send") {

        if (name.value == '')
        {
            error = 1;
            name.className = "share_txt ERROR";
            
        }
        if(reg.test(email.value) == false) 
        {
            error = 1;
            email.className = "share_txt ERROR";
        }
        if (msg.value == '')
        {
            error = 1;
            msg.className = "share_txtarea ERROR";
        }
    
        if(error != 1)
        {
            document.getElementById("con_error").style.display = "none";
            if(val == "send"){
            document.getElementById("ctl00_ContentPlaceHolder1_ctl00_con_successmsg").style.visibility = "visible";
            DoCallback("http://www.balancestudios.com/en-us/portfolio/ajax.aspx?method=contact&name="+name.value+"&company="+company.value+"&email="+email.value+"&phone="+phone.value+"&pid="+pid.value+"&msg="+msg.value);
            }
        }
        else
        {
            document.getElementById("con_error").style.display = "block";
        }
    }
}



