var xmlhttp


        function GetXmlHttpObject()
        {
        if (window.XMLHttpRequest)
          {
          // code for IE7+, Firefox, Chrome, Opera, Safari
          return new XMLHttpRequest();
          
          }
        if (window.ActiveXObject)
          {
          // code for IE6, IE5
          return new ActiveXObject("Microsoft.XMLHTTP");
          }
        return null;
        }




function screen_measure()
    {
           screen_width=screen.availWidth;
           screen_height=screen.height;
           screen_availheight=screen.availHeight;
           screen_availwidth=screen.availWidth;
           
           window.location="/default.aspx?w=" + screen_width + "&h=" + screen_height + ""
     }    



/*j slider*/
    jslider_rotate_delay = 3000; // delay in milliseconds (3000 = 3 seconds)
    jslider_current = 0;
    thumb_adder=0;
    slideshow = 'play';


    function jslider_start(img_list,thumb_img_list,thumbs_shown,img_list_description,img_list_id) {
    window.setTimeout("jslider_rotate()", jslider_rotate_delay);
    jslider_array = img_list.split(",");
    jslider_thumb_array = thumb_img_list.split(",");
    jslider_description_array = img_list_description.split(",");
    jslider_id_array = img_list_id.split(",");
    thumb_count = thumbs_shown;
       }   
       
    function jslider_rotate() 
        {
            if (slideshow == 'play') 
            {
                
                if (jslider_current < jslider_array.length-1)
                   {
                    jslider_current = jslider_current + 1 
                   } else {
                    jslider_current = 0
                    
                   }
                   
                   if (document.images.jslider_img.filters)
                    document.images.jslider_img.filters[0].apply()
                   
                   jslider_go()
                   
                   
                if (document.images.jslider_img.filters)
                document.images.jslider_img.filters[0].play()
                
                if (document.images.jslider_img.filters)
                    {
                    window.setTimeout("jslider_rotate()", jslider_rotate_delay + jslider_rotate_delay)
                    } else {
                    window.setTimeout("jslider_rotate()", jslider_rotate_delay + jslider_rotate_delay)
                    }
             }       
                
        }
     
     function jslider_go()
        {
            
            
            document.images.jslider_img.src = jslider_array[jslider_current];
            document.getElementById("jslider_img_id").value = jslider_id_array[jslider_current];
            //document.getElementById("jslider_img_zoom_link").href = '/gallery/gallery.aspx?img=' + jslider_id_array[jslider_current];
            
            if (jslider_current > (thumb_count-1)+thumb_adder)
            {
                thumb_adder=jslider_current-(thumb_count-1)
                 for (i=0;i<=thumb_count-1;i++)
                    {
                       document.getElementById("thumb_" + i).src = jslider_thumb_array[i+thumb_adder];
                    }
                
            }
            if (jslider_current < thumb_adder)
            {
                thumb_adder = jslider_current
                for (i=0;i<=thumb_count-1;i++)
                    {
                       document.getElementById("thumb_" + i).src = jslider_thumb_array[i+thumb_adder];
                    }
            }
            
                clear_thumb_selection_border();
                document.getElementById("thumb_" + (jslider_current-thumb_adder)).className = "thumb_selected";
            
           
            
        }    
    
        function jslider_moveto(thumb_number)
        {
            jslider_current = thumb_number+thumb_adder
            jslider_go()
            
            document.getElementById("jslider_img").src = jslider_array[jslider_current];
            document.getElementById("jslider_img_id").value = jslider_id_array[jslider_current];
            
            
        }
        
        function jslider_next()
        {
            if (jslider_current < jslider_array.length-1)
               {
                jslider_current = jslider_current + 1 
               } else {
                jslider_current = 0
                
               }
            
            jslider_go()
            
            document.getElementById("jslider_img").src = jslider_array[jslider_current];
            document.getElementById("jslider_img_id").value = jslider_id_array[jslider_current];
            
        }

        function jslider_prev()
        {
             if (jslider_current != 0)
               {
                jslider_current = jslider_current - 1 
               } else {
                jslider_current = jslider_array.length-1
                
               }
            
            jslider_go()
            
            document.getElementById("jslider_img").src = jslider_array[jslider_current];
            document.getElementById("jslider_img_id").value = jslider_array[jslider_current];
            
        }

        function jslider_start_stop()
        {
           
           if (slideshow == 'play') 
              {
                slideshow = 'stop';
                document.getElementById("start_stop_img").src = "/i/icons/play_slideshow_button.gif";
           } else {
                slideshow = 'play';
                document.getElementById("start_stop_img").src = "/i/icons/stop_slideshow_button.gif";
                jslider_rotate()
           }   
           
            
        }
        




     
/*tour changer (on tour_area.aspx) */
tour_current = 0;
    function tour_start(floorplan_img_list, floorplan_img_list_description, floorplan_list_id, floorplan_list_pdf, area_section_title_list, area_section_description_list)
    {
        floorplan_img_start(floorplan_img_list, floorplan_img_list_description, floorplan_list_id, floorplan_list_pdf)
        area_section_start(area_section_title_list, area_section_description_list)
        window.setTimeout("tour_rotate()", jslider_rotate_delay);
    }
    
    
    
    
    function tour_rotate() 
        {
            if (slideshow == 'play') 
            {
                floorplan_img_change()
                area_section_change()
                
                
                window.setTimeout("tour_rotate()", jslider_rotate_delay + jslider_rotate_delay)
             }       
                
        }
    
    function tour_start_stop()
        {
           
           if (slideshow == 'play') 
              {
                //do nothing
           } else {
               tour_rotate()
           }   
        }
        
        
     function tour_moveto(thumb_number)
    {
        floorplan_img_moveto(thumb_number)
        area_section_moveto(thumb_number)
        
    }   
            
     function tour_change()
        {   
            floorplan_img_change()
            area_section_change()
        }             
    
    //area section changing
    function area_section_start(area_section_title_list, area_section_description_list)
    {
        area_section_title_array = area_section_title_list.split(",");
        area_section_description_array = area_section_description_list.split(",");
    }
    
     function area_section_moveto(thumb_number)
    {
        //area_section_current = thumb_number + thumb_adder;
        //set the area_section_title text
        //area_section_title = area_section_title_array[area_section_current];
        //document.getElementById("area_section_title").innerHTML = area_section_title;
        
        //set the area_section_description text
        //area_section_description = area_section_description_array[area_section_current];
        //document.getElementById("area_section_description").innerHTML = area_section_description;
        
        area_section_current = jslider_current;
        
        document.getElementById("area_section_title").innerHTML = area_section_title_array[area_section_current];
        
        var area_section_description = area_section_description_array[area_section_current];
       area_section_description = area_section_description.replace(/&##/g, "&#");
        
        document.getElementById("area_section_description").innerHTML = area_section_description;
        
        
    }   
    
    function area_section_change()
    {
        area_section_current = jslider_current;
        
        document.getElementById("area_section_title").innerHTML = area_section_title_array[area_section_current];
       
        var area_section_description = area_section_description_array[area_section_current];
       area_section_description = area_section_description.replace(/&##/g, "&#");
       area_section_description = area_section_description.replace(/!comma!/g, ",");
        
        document.getElementById("area_section_description").innerHTML = area_section_description;
        
        //alert(area_section_description);
    }      


    //floorplan changing
    function floorplan_img_start(floorplan_img_list,floorplan_img_list_description, floorplan_list_id, floorplan_list_pdf) 
    {
        floorplan_img_array = floorplan_img_list.split(",");
        floorplan_img_description_array = floorplan_img_list_description.split(",");
        floorplan_id_array = floorplan_list_id.split(",");
        floorplan_pdf_array = floorplan_list_pdf.split(",");
        
        
    }

    

    function floorplan_img_moveto(thumb_number)
            {
                floorplan_img_current = thumb_number + thumb_adder;
               
                floorplan_img_loc = floorplan_img_array[floorplan_img_current];
                document.getElementById("floorplan_img").src = floorplan_img_loc;
               
                floorplan_pdf = floorplan_pdf_array[floorplan_img_current];
                if (floorplan_pdf == ''){
                        document.getElementById("floorplan_pdf_span").style.visibility = 'hidden';
                        
                        
                    } else {
                        document.getElementById("floorplan_pdf_span").style.visibility = 'visible';
                        document.getElementById("floorplan_pdf_link").href = floorplan_pdf;
                    }
               
               floorplan_id = floorplan_id_array[floorplan_img_current];
               document.getElementById("floorplan_page_link").href = '/plans/plan.aspx?id=' + floorplan_id;
               
            }   
            
     function floorplan_img_change()
        {
            floorplan_img_current = jslider_current;
            document.getElementById("floorplan_img").src = floorplan_img_array[floorplan_img_current];
            
            floorplan_pdf = floorplan_pdf_array[floorplan_img_current];
                if (floorplan_pdf == ''){
                        document.getElementById("floorplan_pdf_span").style.visibility = 'hidden';
                        
                        
                    } else {
                        document.getElementById("floorplan_pdf_span").style.visibility = 'visible';
                        document.getElementById("floorplan_pdf_link").href = floorplan_pdf;
                    }
               
               floorplan_id = floorplan_id_array[floorplan_img_current];
               document.getElementById("floorplan_page_link").href = '/plans/plan.aspx?id=' + floorplan_id;
               
        }          
 


        
        
        
        
        
        

function Setvars(thumb_counter,thumb_list)
{
   thumb_count = thumb_counter
   
   first_img = 0
  
  
   thumb_array = thumb_list.split(",");
   
  
}


function clear_thumb_selection_border()
{
    
    //alert(thumb_count);
    for (i=0;i<=thumb_count-1;i++)
    {
       document.getElementById("thumb_" + i).className = "thumb_not_selected"
    }
}



function thumb_arrow_down()
{
    first_img = first_img + 1;
    for (i=0;i<=thumb_count-1;i++)
        {
         var i_next = i + 1
            if (i < thumb_count-1)
            {
                document.getElementById("thumb_" + i).src = document.getElementById("thumb_" + i_next).src;
            } else {
                document.getElementById("thumb_" + i).src = thumb_array[i + first_img];
            }
        }
    
    
    clear_thumb_selection_border();   
    //document.getElementById("thumb_" + thumb_count-1).className = "thumb_selected"
    document.Oneslideform.Oneslide.selectedIndex = thumb_count-2+first_img;
    alert(first_img);
    Onechange()
}


function thumb_arrow_up()
{
    first_img = first_img - 1;
    for (i=0;i<=thumb_count-1;i++)
        {    document.getElementById("thumb_" + i).src = thumb_array[i + first_img];
                
           
        }
        
    clear_thumb_selection_border();   
    document.getElementById("thumb_0").className = "thumb_selected"
    document.Oneslideform.Oneslide.selectedIndex = first_img;
    Onechange()
    
}

function go_to_img(img_id)
           {
                document.getElementById("Oneslide").value = img_id;
                Onechange();
           }
        
    
    
function switch_img(img_id, img_location)
       {
            document.getElementById(img_id).src = img_location;
       } 
       

function chg_class(this_id, new_class)
       {
            document.getElementById(this_id).className = new_class;
       } 
	   
	   
	   
	   
function showPlanImage(plan_image_id) {
	
	 xmlHttp = GetXmlHttpObject();
            if (xmlHttp == null) {
                alert("Your browser does not support AJAX!");
                return;
            }

			
			

            var url = "/projects/plan_image_ajax.aspx";
			url = url + "?id=" + plan_image_id ;
            url = url + "&sid=" + Math.random();
            //alert(url)


            xmlHttp.open("GET", url, true);
            xmlHttp.send(null);
            xmlHttp.onreadystatechange = showPlanImage_response;
		}

        



		

        function showPlanImage_response() {
            if (xmlHttp.readyState == 4) {
                
				results_html = xmlHttp.responseText;
				

                document.getElementById("plan_image").innerHTML = results_html

				
            }

        }
		
		
		
		
function showElevImage(elev_id) {
	
	 xmlHttp = GetXmlHttpObject();
            if (xmlHttp == null) {
                alert("Your browser does not support AJAX!");
                return;
            }

			
			

            var url = "/projects/elev_image_ajax.aspx";
			url = url + "?id=" + elev_id ;
            url = url + "&sid=" + Math.random();
            //alert(url)


            xmlHttp.open("GET", url, true);
            xmlHttp.send(null);
            xmlHttp.onreadystatechange = showElevImage_response;
		}

        



		

        function showElevImage_response() {
            if (xmlHttp.readyState == 4) {
                
				results_html = xmlHttp.responseText;
				

                document.getElementById("plan_image").innerHTML = results_html

				
            }

        }
       
