﻿    function showTabContent(id)
    {
       // hide all others
        var divs = document.getElementsByTagName("div");
        for (i= 0; i < divs.length; ++i)
        {
          if (divs[i].className == 'tabData')
          {
           divs[i].style.display = 'none';
          }
        }
       
       document.getElementById(id).style.display = 'block';
    }
    
   
    function showService(id,mediaClass,infoClass)
    {
       var divs = document.getElementsByTagName("div");
       
       for (i = 0; i < divs.length; ++i)    
       {  
            if (divs[i].getAttribute('name') == mediaClass) { divs[i].style.display = 'none'; }
       };
           
        document.getElementById(id).style.display = 'block';
      
       var items = document.getElementsByTagName("a");
       for (i = 0; i < items.length; ++i)    
       {  
        if (items[i].getAttribute('name') == 'sublink') { 
            if (items[i].getAttribute('id') == "link_" + id)
            {   items[i].className = 'selected'; 
            } else {
                items[i].className = 'none';
            }            
        }
       };     
    }
   
   
    function show(id,mediaClass,infoClass)
    {
       var divs = document.getElementsByTagName("div");
       
       for (i = 0; i < divs.length; ++i)    
       {  
            if (divs[i].getAttribute('name') == mediaClass || divs[i].getAttribute('name') == infoClass) { divs[i].style.display = 'none'; }
       };
       
       document.getElementById(id).style.display = 'block';
     
       document.getElementById('info_' + id).style.display = 'block';

	   var myitemsLinks = document.getElementsByTagName("a");
       for (i = 0; i < myitemsLinks.length; ++i)    
       {  
        if (myitemsLinks[i].getAttribute('name') == 'sublink') { 
            if (myitemsLinks[i].className == 'selected')
            {   myitemsLinks[i].className = 'none'; 
            }           
        }
       }; 	
       document.getElementById("link_" + id).className = 'selected';		   
    }
     
     function showOnlyMovie(projectid)
     {     
          var domain = "http://" + document.domain;
     
		   var so = new SWFObject("/_swf/portfolio/preloader.swf", "preloader", "683", "377", "9", "#FFFFFF");
		    so.useExpressInstall('/_swf/expressinstall.swf');
			so.addVariable("project", projectid); 
			so.addParam("wmode", "transparent");
			so.addParam("base",domain);
		    so.write("flashcontent");			  
	        document.getElementById("flashcontent").style.display = "block";
		
	   var myitemsLinks = document.getElementsByTagName("a");
       for (i = 0; i < myitemsLinks.length; ++i)    
       {  
        if (myitemsLinks[i].getAttribute('name') == 'sublink') { 
            if (myitemsLinks[i].className == 'selected')
            {   myitemsLinks[i].className = 'none'; 
            }           
        }
       }; 	
       document.getElementById("link_" + projectid).className = 'selected';					
	}
    
    function showMovie(projectid)
     {     
     var domain = "http://" + document.domain;
         
		   var so = new SWFObject("/_swf/portfolio/preloader.swf", "preloader", "683", "377", "9", "#FFFFFF");
		    so.useExpressInstall('/_swf/expressinstall.swf');
			so.addVariable("project", projectid); 
			so.addParam("wmode", "transparent");
			/*if (document.location.href.indexOf("_templates") != -1)
			{
		        so.addParam("base","/_templates/");
		    }*/
		    so.addParam("base",domain);		    
		    so.write("flashcontent");			  

		document.getElementById("flashcontent").style.display = "block";						
		show(projectid,'servicedetail','infodetail');
	}
	function showExample(url) 
	{
	    document.getElementById('overlay').style.display = "block";
	    document.getElementById('videoexample').style.display = "block";
	    playExampleMovie(url);
	}
	function hideExample(url) 
	{
	    document.getElementById('overlay').style.display = "none";
	    document.getElementById('videoexample').style.display = "none";
	    
	    //need to actuallly stop playing the video here
	    document.getElementById("ytapiplayer").innerHTML = "";
	}
	function playExampleMovie(videoUrl)
    {             
    	var so = new SWFObject(videoUrl, "preloader", "736", "624", "8", "#FFFFFF");
	    so.useExpressInstall('_swf/expressinstall.swf');
		//so.addParam("wmode", "transparent");
		so.addParam("base", "uploadedimages/Work/Client_Projects/NIK/");
	    so.write("ytapiplayer");	    
     }
    function playVideo(videoUrl,ID)
    {             
        if (ID != null)
        {
            document.getElementById("current_video").innerHTML = document.getElementById(ID).innerHTML;
        }
        if (videoUrl.indexOf('youtube') != -1)
        {
            videoUrl = videoUrl.replace(/watch\?/,"").replace(/=/,"/");
        }
    	var so = new SWFObject(videoUrl, "preloader", "480", "360", "9", "#FFFFFF");
	    so.useExpressInstall('_swf/expressinstall.swf');
		so.addParam("wmode", "transparent");
	    so.write("ytapiplayer");	    
     }
     
     function playFeatureOld(videoUrl,ID)
     {
        var domain = "http://" + document.domain;
        
        if (ID != null)
        {
            document.getElementById("current-feature").innerHTML = document.getElementById(ID).innerHTML;
        }

	    var newUrl = videoUrl;
	    
	    if (videoUrl.toString().indexOf("?") != -1)
	    {
	       newUrl = videoUrl.toString().substring(0,videoUrl.indexOf("?"));
	    }
	    
	    var so = new SWFObject("/_swf/resource/resource_center.swf", "flashcontent", "480", "270", "9", "#FFFFFF");
	    so.useExpressInstall('/_swf/expressinstall.swf');
		so.addVariable("asset",newUrl);
	    so.addParam("wmode", "window");
		so.addParam("base",domain);
		so.addParam("allowscriptaccess", "always");
		so.write("flashcontent");	
  }
  
     function playFeature(videoUrl,ID,allLinkUrl,newTarget)
     {
        var domain = "http://" + document.domain;
        
        if (ID != null)
        {
            document.getElementById("current-feature").innerHTML = document.getElementById(ID).innerHTML;
        }
        
        if (allLinkUrl != null)
        {
           document.getElementById("seeAllLink").href = "/" + allLinkUrl + "/";
           document.getElementById("seeAllLink").innerHTML = "See all of our " + allLinkUrl;           
        }

        if (newTarget != null)
        { 
            document.getElementById("featurelink").href = newTarget + "&ReturnUrl=/resources/";
            document.getElementById("featureImage").src = videoUrl;
            document.getElementById("imagecontent").style.display = 'block';
            document.getElementById("flashcontent").style.display = 'none';
        } else {
            if (document.getElementById("imagecontent") != null)
            {
                document.getElementById("imagecontent").style.display = 'none';
            }
            document.getElementById("flashcontent").style.display = 'block';
             var params = {
		        quality: "high",
		        scale: "scale",
		        wmode: "window",
		        allowscriptaccess: "always",
		        bgcolor: "#FFFFFF",
		        base: domain
	        };
	        var flashvars = {
		        asset: videoUrl
	        };
	        var attributes = {id:"flashcontent"};
	        swfobject.embedSWF("/_swf/resource/resource_center.swf", "flashcontent", "480", "270", "9.0.124", "expressInstall.swf", flashvars, params, attributes);
        }
  }
    
     
    function setSelectedLink()
    {
         var currentUrl = location.href.substring(location.href.lastIndexOf("/"));
         var items = document.getElementsByTagName("a");
           for (i = 0; i < items.length; ++i)    
           {  
                if (items[i].href.indexOf(currentUrl) != -1)
                {   items[i].className = 'selected'; 
                } else {
                    items[i].className = '';
                }            
           };     
    }

    function playQuiz(quizUrl)
    {           
    	document.getElementById('overlay').style.display = "block";
	    document.getElementById('videoexample').style.display = "block";  
    	var so = new SWFObject(quizUrl, "preloader", "720", "540", "9", "#FFFFFF");
	    so.useExpressInstall('_swf/expressinstall.swf');
		so.addParam("wmode", "transparent");
	    so.write("ytapiplayer");	    
     }
    
   function addLoadEvent(func) {   
   var oldonload = window.onload;   
   if (typeof window.onload != 'function') {   
     window.onload = func;   
   } else {   
        window.onload = function() {   
       if (oldonload) {   
         oldonload();   
       }   
       func();   
     }   
   }   
 }   
