// Javascript Document for nav bar funtionality
var current_page_obj;
var timmer;
var okay_to_show_current_nav = true;
$(document).ready(function(){
//Add arrow dig to each nav li element
$('#nav-bar li').append('
');
//Add rollover effect for arrow
$('#nav-bar li.nav_top').mouseenter(function() {
$(this).data('mouse_in', true);
do_rollover($(this));
}).mouseleave(function() {
$(this).data('mouse_in', false);
rev_rollover($(this));
});
$('#nav-bar li').each(function(index) {
//console.log('Page name: ' + window.location.pathname + " Object href: " + $(this).children('a').attr('href'));
if($(this).children('a').attr('href') == window.location.pathname){
trueobj = null;
if($(this).parent().parent('li').hasClass('nav_top')){
//console.log('is child');
trueobj = $(this).parent().parent('li');
$(this).children('a').addClass('current');
} else {
trueobj = $(this);
}
make_current(trueobj);
trueobj.unbind('mouseenter');
trueobj.unbind('mouseleave');
current_page_obj = trueobj;
} else {
}
});
//Initialize click event for AJAX content swap
$('#' + _sub + ' li a ').click(function(){
//alert($(this).attr('href'));
swap_content($(this).attr('href'));
$('#' + _sub + ' li a.current').removeClass('current');
$(this).addClass('current');
return false;
});
//console.log('Page name: ' + window.location.pathname);
});
function swap_content(new_content_url){
$('#container').fadeOut(400,function(){
if($('.container_place_holder').html() == null){
$(this).after('
');
}
get_new_data(new_content_url);
});
}
function get_new_data(new_content_url){
$.post(new_content_url,
function(data) {
//alert("Data Loaded: " + data);
show_new_content(data);
});
}
function show_new_content(new_content){
var $new_content = $('').append(new_content);
var $new_slider_content = $new_content.find('.sliderv');
var $new_container_content = $new_content.find('#container').html();
$('.sliderv').sliderv({transitionlength: '1000'},$new_slider_content);
//console.log($new_content);
$('#container').html($new_container_content);
$('#container').fadeIn(400);
$('.container_place_holder').detach();
//$('#submit_design_req_exp').expando({inital_opacity: 1, end_opacity: 1, expand_height: '50px', float: true, onclick_redirect_url: '/design_request'});
setup_site();
setup_exhibit_main();
setup_form();
}
//Function the controls the rollover effect fro the main navigation
function do_rollover(obj){
obj.stop();
okay_to_show_current_nav = false;
hide_current_sub_nav();
var width = obj.innerWidth();
var height = obj.innerHeight();
var arrow = obj.children('.arrow');
//console.log(width + "|" + height);
var position = obj.position();
var left_set = position.left;
//console.log(width / 2);
//console.log(position);
arrow.css('width', width);
arrow.css('left', left_set);
arrow.css('top', height - 10);
arrow.css('opacity', 0);
arrow.css('display', 'block');
arrow.animate({
opacity: 0.5,
top: '19'
}, 300, function() {
// Animation complete.
});
setTimeout(function(){fade_in_child(obj)},100);
}
function fade_in_child(obj){
if(obj.data('mouse_in')){
obj.children('ul').fadeIn(300);
}
}
function rev_rollover(obj){
obj.stop();
var arrow = obj.children('.arrow');
arrow.stop(true, true);
arrow.fadeOut('200');
obj.children('ul').fadeOut(200);
okay_to_show_current_nav = true;
timmer = setTimeout("show_current_sub_nav()",2000);
//show_current_sub_nav();
}
function make_current(obj){
var width = obj.innerWidth();
var height = obj.innerHeight();
var arrow = obj.children('.arrow');
var objlink = obj.children('a');
var position = obj.position();
var left_set = position.left;
objlink.addClass('current');
arrow.addClass( 'arrow-current');
arrow.removeClass( 'arrow');
//console.log(width + "|" + height);
arrow.css('width', width);
arrow.css('left', left_set);
arrow.css('top', height - 10);
arrow.css('opacity', 0);
arrow.css('display', 'block');
arrow.animate({
opacity: 1,
top: '19'
}, 2000, function() {
// Animation complete.
show_current_sub_nav();
});
}
function show_current_sub_nav(){
//var okay_to_show = true;
//
// $('#nav-bar li ul').each(function(index) {
//console.log($(this).css('display'));
// if($(this).css('display') != 'none'){
// if($(this).css('display') != undefined){
//
// if(okay_to_show != false){ okay_to_show = false };
//
// }
// }
// });
//console.log('okay to show? ' + okay_to_show_current_nav);
if(current_page_obj != null && okay_to_show_current_nav == true){
current_page_obj.children('ul').fadeIn(300);
}
}
function hide_current_sub_nav(){
if(current_page_obj != null){
current_page_obj.children('ul').fadeOut(300);
}
}
function check_page(){
//alert('Where you going?');
}