Cufon.replace('h1');
Cufon.replace('h3');

var $j = jQuery;
	$j('#content').height($j('#sidebar').height()-45)
	
	$j(document).ready(function($) {
		
		// forces the content box to be the same height as the sidebar
		$j('#content').height($j('#sidebar').height()-45)
        //$j('#content').attr('class'=langVar);
        var langVar;
        langVar = $j('#container').attr('class');        
		// Disable the enter button, replace with a pop-up instead
		$j('.enter').attr('href', '#');
		$j('.enter').click(function() {
			var windowHeight;
			var windowWidth;
			if (screen.height < 1024) {
				windowWidth = 1024;
				windowHeight = 660;
			} else {
				windowWidth = 1280;
				windowHeight = 800;
			};
			
			// windowWidth = 1024;
			// windowHeight = 640;
			
			// windowWidth = 1280;
			// windowHeight = 800;
			
			
			window.open(langVar+"/slideshow/index.html", "Us_Generation", "menubar = false,resizable = false,status = true,toolbar = false,scrollbars = false, location = no, fullscreen = false, width="+windowWidth+", height="+windowHeight+"")
		});
		$j('#content').height($j('#sidebar').height()-45)
		
		// Disable the enter button, replace with a pop-up instead
		$j('.view').attr('href', '#');
		$j('.view').click(function() {
			var windowHeight;
			var windowWidth;
			if (screen.height < 1024) {
				windowWidth = 1024;
				windowHeight = 660;
			} else {
				windowWidth = 1280;
				windowHeight = 800;
			};
			
			// windowWidth = 1024;
			// windowHeight = 640;
			
			// windowWidth = 1280;
			// windowHeight = 800;
			
			window.open("en-us/poster_slideshow/index.html", "Us_Generation", "menubar = false,resizable = false,status = true,toolbar = false,scrollbars = false, location = no, fullscreen = false, width="+windowWidth+", height="+windowHeight+"")
		});
		
		// If you pass along the get variables "slideshow" or "pslideshow" the page will pop up the requred slideshow
		
		// get variables
		var vars = {};
		var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
			vars[key] = value;
		});
		
		// This will most likely trigger their pop-up blocker.
		// This is probably a waste of time.
		if (vars.slideshow) {
			$j('.enter').trigger('click');
		};
		if (vars.pslideshow) {
			$j('.view').trigger('click');
		};

		
		// Really basic for validation due to the fact that the form validation plugin is broken in this environment.
		// It really only checks to see if the form is empty, nothing more.
		
		// Stops IE from being an idiot.
		$j('#submitButton').click(function() {
			$j('#aspnetForm').trigger('submit')
		});
		
		$j('#aspnetForm').submit(function() {
			// alert("runn")
			if ($j('#name').val() === "" || $j('#email').val() === "") {
				if ( $j('#name').val() === "") {
					$j('#name').addClass('error');
					if ($j('#nameError').length == 0) {$j('#errors ul').append('<li id="nameError">Please enter your name.</li>')};
				} else {
					$j('#name').removeClass('error')
					$j('#errors #nameError').remove();
				}
				if ($j('#email').val() === "") {
					$j('#email').addClass('error')
					if ($j('#emailError').length == 0) {$j('#errors ul').append('<li id="emailError">Please enter a valid e-mail address (yourname@domain.com)</li>')};
				} else {
					$j('#email').removeClass('error')
					$j('#errors #emailError').remove();
				}
				
				$j('#errors').fadeIn('fast');
				
				return false
			};
			$j('#submitButton').attr('disabled', 'disabled');
			$j('#errors').fadeOut('fast')
		});
		
	});
	

