
$(document).ready(function() {  
	$(".trail_image_view").click(function() {
		$(".trail_image_close").click();
	
		$(this).parent().children(".trail_image_img_div").show();
		$(this).parent().children(".trail_image_close").show();
		$(this).hide();
		
		$(this).parent().css("padding-top", "10px");
		$(this).parent().css("padding-bottom", "10px");
		
		parent_height = $(this).parent().height() + 20;
		//parent_width = $(this).parent().width() + 39;
		parent_width = $(this).parent().children(".trail_image_img_div").children(".trail_image_img").width() + 29;
		
		console.log(parent_width);
		console.log($(this).parent().width());
		
		$(this).parent().children(".trail_highlight").show();
		$(this).parent().children(".trail_highlight").css("height", parent_height + "px");
		$(this).parent().children(".trail_highlight").css("width", parent_width + "px");
	
	});
	
	$(".trail_image_close").click(function() {
		$(this).parent().children(".trail_image_img_div").hide();
		$(this).parent().children(".trail_image_view").show();
		$(this).parent().children(".trail_highlight").hide();

		$(this).parent().css("padding-top", "0px");
		$(this).parent().css("padding-bottom", "0px");

		$(this).hide();
	
	});
	
	$(".tenyear_more").click(function() {
		if ($(this).parent().children(".tenyear_rest").css("display")=="none") {
			$(this).parent().children(".tenyear_rest").show();
			$(this).css("background-image", "url(images/click_arrow_down.gif)");
			$(this).css("background-position", "0px 1px");
			$(this).html("less");
		
		} else {
			$(this).parent().children(".tenyear_rest").hide();
			$(this).css("background-image", "url(images/click_arrow_up.gif)");
			$(this).css("background-position", "0px 3px");
			$(this).html("more");
		
		}	
	});

});

function staff_bio_switch(elm) {
 	elm_parent = elm.parentNode;
 	
 	i=0;
 	
 	while ((elm_parent.className != "staff_bio") && (i < 10) ) {
		elm_parent = elm_parent.parentNode;
		
		i=i+1;
		
 	}
 	
 	current_height = elm_parent.offsetHeight;
 	
 	if (current_height==20) {
 		elm_parent.style.height = "auto";
 		elm.className = "staff_click_a-open";
 	
 	} else {
 		elm_parent.style.height = "20px";
 		elm.className = "staff_click_a-closed";
  	}

 	position_background();
}

function staff_bio_start_expanded() {
	atag = document.getElementById(show_bio);
	
	if (atag != null) {
		staff_bio_switch(atag);
	}
}


function pr_switch(elm) {
	
	nav_id = elm.parentNode.id;
	
	copy_id = "text_copy_" + nav_id.substring(14);
	
	nav_div = document.getElementById(nav_id);
	copy_div = document.getElementById(copy_id);
	
	if (nav_div.className=="text_copy-collapse_nav-closed") {
		nav_div.className = "text_copy-collapse_nav-open";
	
	} else {
		nav_div.className = "text_copy-collapse_nav-closed";
	
	}
	
	if (copy_div.className=="text_copy-collapse") {
		copy_div.className = "text_copy";
		
	} else {
		copy_div.className = "text_copy-collapse"
	
	}
	
	
}


function video_open(mov) {
	var so = new SWFObject("flash/mediaplayer/player.swf", "ply", "640", "500", "9", "#FFFFFF");
	so.addParam("allowfullscreen","true");
	so.addParam("allowscriptaccess","always");
	so.addParam("flashvars","file="+mov+"&autostart=true");
	so.addParam("wmode", "transparent");
	so.write("popup_main");
	
	$("#popup_main").mouseover(function() {
		$("#popup_close").show();
		
		$("#popup_close").mouseover(function() {
			$("#popup_close").show();
		});
	
	});
	
	$("#popup_main").mouseout(function() {
		$("#popup_close").hide();
	});
	
	

}


function gallery_open(content_id) {

	popup_div = document.getElementById('popup-gallery');
	fade_div = document.getElementById('popup-page_fade');
	
	photo = document.getElementById('popup_main_photo');

	if (photo != null) {
		photo.src = null;
		photo.style.display = "none";
	}
	
	var view1 = new Viewport();
	
	if (popup_div != null) {
		popup_div.style.top = (((view1.windowY - 508) / 2) + view1.scrollY) + "px";
		popup_div.style.left = ((view1.windowX - 648) / 2) + "px";

		popup_div.style.display = "block";
	}

	if (fade_div != null) {
		fade_div.style.height = view1.pageY + "px";
		fade_div.style.width = view1.pageX + "px";
		fade_div.style.display = "block";
	}
	
	url_var = "content_id=" + content_id;
	if (content_id == 'all') {
		playlist_open('video/asx.xml.php');
	} else {
		video_open(content_id);
	}
}





function gallery_close() {
	popup_div = document.getElementById('popup-gallery');
	fade_div = document.getElementById('popup-page_fade');
	
	photo = document.getElementById('popup_main_photo');
	caption = document.getElementById('popup_main_caption');
	
	items_div = document.getElementById('popup_thumbs_items');

	if (photo != null) {
		photo.src = null;
		photo.style.display = "none";
	}
	
	if (caption != null) {
		caption.innerHTML = null;
	}
	
	if (items_div != null) {
		items_div.style.top = "0px";
		items_div.innerHTML = null;
	}

	if (popup_div != null) {
		popup_div.style.display = "none";
	}

	if (fade_div != null) {
		fade_div.style.display = "none";
	}
}



$(document).ready(function() { 

	$("#style2_signup_email").focus(function() {
		if ($(this).val()=="eMail Address") {
			$(this).val("");
			$(this).css("color", "#000000");
		}
	});
	
	$("#style2_signup_email").blur(function() {
		field_value = $(this).val()
		field_value = $.trim(field_value);
		
		if (field_value.length==0) {
			$(this).val("eMail Address");
			$(this).css("color", "#c8c8c8");
		}
	
	});
	
	$("#style2_signup_name").focus(function() {
		if ($(this).val()=="Name") {
			$(this).val("");
			$(this).css("color", "#000000");
		}
	
	});
	
	$("#style2_signup_name").blur(function() {
		field_value = $(this).val()
		field_value = $.trim(field_value);
		
		if (field_value.length==0) {
			$(this).val("Name");
			$(this).css("color", "#c8c8c8");
		}
	
	});
	
	$("#style2_signup_org").focus(function() {
		if ($(this).val()=="Organization") {
			$(this).val("");
			$(this).css("color", "#000000");
		}
	
	});
	
	$("#style2_signup_org").blur(function() {
		field_value = $(this).val()
		field_value = $.trim(field_value);
		
		if (field_value.length==0) {
			$(this).val("Organization");
			$(this).css("color", "#c8c8c8");
		}
	
	});


});
