
window.dhtmlHistory.create({
        toJSON: function(o) {
                return Object.toJSON(o);
        }
        , fromJSON: function(s) {
                return s.evalJSON();
        }
});

var history_change = function(newLocation, historyData) {
    if(newLocation == "")
    	newLocation = "homepage";
    
    linkLoader('/page.php?dynamicPage=' + newLocation, "main_content", newLocation);
}

window.onLoad = initAll();
function initAll(){
    ajaxLoader('/page.php?dynamicPage=floorplans','main_content');
    dhtmlHistory.initialize();
    dhtmlHistory.addListener(history_change);
} 
 
 
function ajaxLoader(url,id) {
	new Ajax.Request('/navigation.php', {method: 'get',
                                           onSuccess: function(transport){
                                                            var container = document.getElementById('navigation');
                                                            container.innerHTML = transport.responseText;                      			
                                                      }
                                          });    
    
    
    new Ajax.Request(url, {method: 'get',
    					   onSuccess: function(transport){
                           					var container = document.getElementById(id);
                							container.innerHTML = transport.responseText;
                                            
                                            if(url == '/page.php?dynamicPage=photos'){

                                             	var flashvars1 = {
                                                    xmlDataPath: "photo_gallery/gallery.xml"	
                                                };
                                                var params1 = {
                                                    wmode: "transparent"
                                                };
                                                var attributes1 = {};
                                                swfobject.embedSWF("/photo_gallery/viewer.swf", "flash_photo_gallery", "880", "500", "8.0.0", "/swfobject/expressInstall.swf", flashvars1, params1, attributes1);
                                            } 
                                            
                                            if(url == '/page.php?dynamicPage=floorplans'){	
                                            	var flashvars1 = {};
                                                var params1 = {
                                                    wmode: "transparent"
                                                };
                                                var attributes1 = {};
                                                swfobject.embedSWF("/Assets/floorplans/main_new.swf", "flash_floorplans", "740", "500", "8.0.0", "/swfobject/expressInstall.swf", flashvars1, params1, attributes1);
                                            }   
                                            
                                            if(url == '/page.php?dynamicPage=homepage'){	
                                            
                                            	var flashvars1 = {};
                                                var params1 = {
                                                    wmode: "transparent"
                                                };
                                                var attributes1 = {};
                                                swfobject.embedSWF("/Assets/headline/main_headline00.swf", "flash_headlines", "480", "330", "8.0.0", "/swfobject/expressInstall.swf", flashvars1, params1, attributes1);
                                            }      
                                            
                                            if(url == '/page.php?dynamicPage=socialphotos'){	
                                            
                                            	var flashvars1 = {
                                                	content_path: "http://www.flickr.com/photos/jonnieburtoft/",
                                                    color_path: "/Assets/flashgallery/default.xml"
                                                };
                                                var params1 = {
                                                    wmode: "transparent"
                                                };
                                                var attributes1 = {};
                                                swfobject.embedSWF("/Assets/flashgallery/flashgallery.swf", "gallery", "640", "480", "8.0.0", "/swfobject/expressInstall.swf", flashvars1, params1, attributes1);
                                            }    
                                            
                                            if(url == '/page.php?dynamicPage=video'){	
                                            
                                            	var flashvars1 = {
                                                	skinName: "Clear_Skin_2",
                                                    streamName: "Assets/master_vue_071610",
                                                    autoPlay: true,
                                                    autoRewind: false
                                                };
                                                var params1 = {
                                                    wmode: "transparent"
                                                };
                                                var attributes1 = {};
                                                swfobject.embedSWF("/FLVPlayer_Progressive.swf", "video_gallery", "640", "360", "8.0.0", "/swfobject/expressInstall.swf", flashvars1, params1, attributes1);
                                            }        
                                            
                                            if(url == '/page.php?dynamicPage=events'){	
                                            	document.body.background="/Assets/thevue-website_amenities.jpg";
                                            }
                                            else if(url == '/page.php?dynamicPage=amenities'){
                                            	document.body.background="/Assets/Vue-18.jpg";
                                            }
                                            else if(url == '/page.php?dynamicPage=residents'){
                                            	document.body.background="/Assets/Vue-64.jpg";
                                            }
                                            else if(url == '/page.php?dynamicPage=floorplans'){
                                            	document.body.background="/Assets/Vue-6.jpg";
                                            }
                                            else{
                                            	document.body.background="";
                                            }       			
                                      }
                            
    					  });
}


function linkLoader(url,id,image) {
	//BUG FIX: Reset application page
    panel1_show = true;
    panel2_show = false;
    panel3_show = false;
    panel4_show = false;
    is_hold = false;

	document.title = image;
   	dhtmlHistory.add(image, image);

	new Ajax.Request('/navigation.php', {method: 'get',
                                           onSuccess: function(transport){
                                                            var container = document.getElementById('navigation');
                                                            container.innerHTML = transport.responseText;                        			
                                                      }
                                          });

	new Effect.Fade(id, {duration:0.2,
    					 afterFinish:function(){
                                                new Ajax.Request(url, {method: 'get',
                                                                       onSuccess: function(transport){
                                                                       					
                                                                                        var container = document.getElementById(id);
                                                                                        container.innerHTML = transport.responseText;     
                                                                                        new Effect.Appear(id, { duration:0.2,
                                                                                        						afterFinish:function(){
                                                                                                                	
                                                                                                                	if(image=='photos'){
                                                      
                                                                                                                        var flashvars1 = {
                                                                                                                            xmlDataPath: "photo_gallery/gallery.xml"	
                                                                                                                        };
                                                                                                                        var params1 = {
                                                                                                                            wmode: "transparent"
                                                                                                                        };
                                                                                                                        var attributes1 = {};
                                                                                                                        swfobject.embedSWF("/photo_gallery/viewer.swf", "flash_photo_gallery", "880", "500", "8.0.0", "/swfobject/expressInstall.swf", flashvars1, params1, attributes1);
                                                                                                                    }
                                                                                                                    
                                                                                                                    if(image=='floorplans'){
                                                                                                                    	var flashvars1 = {};
                                                                                                                        var params1 = {
                                                                                                                            wmode: "transparent"
                                                                                                                        };
                                                                                                                        var attributes1 = {};
                                                                                                                        swfobject.embedSWF("/Assets/floorplans/main_new.swf", "flash_floorplans", "740", "500", "8.0.0", "/swfobject/expressInstall.swf", flashvars1, params1, attributes1);
                                                                                                                    }
                                                                                                                    
                                                                                                                    if(image=='homepage'){
                                                                                                                    	var flashvars1 = {};
                                                                                                                        var params1 = {
                                                                                                                            wmode: "transparent"
                                                                                                                        };
                                                                                                                        var attributes1 = {};
                                                                                                                        swfobject.embedSWF("/Assets/headline/main_headline00.swf", "flash_headlines", "480", "330", "8.0.0", "/swfobject/expressInstall.swf", flashvars1, params1, attributes1);
                                                                                                                    }
                                                                                                                    
                                                                                                                    if(image=='socialphotos'){
                                                                                                                    
                                                                                                                    	var flashvars1 = {
                                                                                                                            content_path: "http://www.flickr.com/photos/jonnieburtoft/",
                                                                                                                            color_path: "/Assets/flashgallery/default.xml"
                                                                                                                        };
                                                                                                                        var params1 = {
                                                                                                                            wmode: "transparent"
                                                                                                                        };
                                                                                                                        var attributes1 = {};
                                                                                                                        swfobject.embedSWF("/Assets/flashgallery/flashgallery.swf", "gallery", "640", "480", "8.0.0", "/swfobject/expressInstall.swf", flashvars1, params1, attributes1);
                                            
                                                                                                                    } 
                                                                                                                    
                                                                                                                    if(image=='video'){
                                                                                                                    
                                                                                                                    	var flashvars1 = {
                                                                                                                            skinName: "Clear_Skin_2",
                                                                                                                            streamName: "Assets/master_vue_071610",
                                                                                                                            autoPlay: true,
                                                                                                                            autoRewind: false
                                                                                                                        };
                                                                                                                        var params1 = {
                                                                                                                            wmode: "transparent"
                                                                                                                        };
                                                                                                                        var attributes1 = {};
                                                                                                                        swfobject.embedSWF("/FLVPlayer_Progressive.swf", "video_gallery", "640", "360", "8.0.0", "/swfobject/expressInstall.swf", flashvars1, params1, attributes1);
                                                                                                                    }                                                                                                                       
                                                                                                                    
                                                                                                                    if(image=='events'){
                                                                                                                    	document.body.background="/Assets/thevue-website_amenities.jpg";
                                                                                                                    }else if(image=='amenities'){
                                                                                                                    	document.body.background="/Assets/Vue-18.jpg";
                                                                                                                    }else if(image=='residents'){
                                                                                                                    	document.body.background="/Assets/Vue-64.jpg";
                                                                                                                    }else if(image=='floorplans'){
                                                                                                                    	document.body.background="/Assets/Vue-6.jpg";
                                                                                                                    }else{
                                                                                                                    	document.body.background="";
                                                                                                                    }
                                                                                                                }
                                                                                                               });
                                                                                                           			
                                                                                  }
                                                                        
                                                                      });
                                               }
                           });
}