/**
 *
 */

var scientific = {
	
	init: function() {
		
		$(".username").val('Username').focus(function() {
			if( $(this).val() == 'Username' ) {
				$(this).val('');
			}
		}).blur(function() {
			if( $(this).val() == '' ) {
				$(this).val('Username');
			}
		});
		
		$(".password").val('Password').focus(function() {
			if( $(this).val() == 'Password' ) {
				$(this).val('');
			}
		}).blur(function() {
			if( $(this).val() == '' ) {
				$(this).val('Password');
			}
		});
		
		scientific.floatingPanel();
		
		$('.sliding-navigation a').click(function() {
			$('.sliding-navigation a').removeClass('selected');
			$(this).addClass('selected');
		});
		
		scientific.slideshow();
		
		scientific.enewsletter_form();
		
	}
	
	,floatingPanel: function() {
		var name = ".sliding-navigation";  
		var menuYloc = null;  
		var docOffset = null;
		
		if( $(name).attr('class') ) {
			menuYloc = parseInt( $(name).css("top").substring(0,$(name).css("top").indexOf("px")) );
			docOffset = $(name).offset();
			docOffset = docOffset.top;
			
			$(window).scroll(function () {
				var offset = ( $(document).scrollTop() - docOffset + 50) + "px";
				if( $(document).scrollTop() >= docOffset ) {
					$(name).animate({top:offset},{duration:500,queue:false});  
				} else {
					offset = menuYloc;
					$(name).animate({top:offset},{duration:500,queue:false});  
				}
			});  
		}
	}
	
	,submit_compliance_form: function( form ) {
		
		if(form.name.value == '') {
			alert('Please enter your name to continue');
			return false;
		}

		if(form.company.value == '') {
			alert('Please enter your company name to continue');
			return false;
		}

		if(form.telephone.value == '') {
			alert('Please enter your telephone number to continue');
			return false;
		}

		if(form.email.value == '') {
			alert('Please enter your email address to continue');
			return false;
		}
		
		/*
		if(form.question_1.value == '') {
			alert('Please answer Yes, No, or Not Sure to all questions to continue');
			return false;
		}

		if(form.question_2.value == '') {
			alert('Please answer Yes, No, or Not Sure to all questions to continue');
			return false;
		}

		if(form.question_3.value == '') {
			alert('Please answer Yes, No, or Not Sure to all questions to continue');
			return false;
		}

		if(form.question_4.value == '') {
			alert('Please answer Yes, No, or Not Sure to all questions to continue');
			return false;
		}

		if(form.question_5.value == '') {
			alert('Please answer Yes, No, or Not Sure to all questions to continue');
			return false;
		}
		*/

		return true;
		
	}

	,slideshow: function() {
		
		var len = $('.picture-frame img').length;
		
		if( len > 1 ) {
			$(window).load(function() {
				$('.picture-frame div').cycle({
					fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
				});
			});
		}
		
	}
	
	,enewsletter_form: function() {
		$('#e_firstname').focus(function() {
			if( $(this).val() == 'First name' ) {
				$(this).val('');
			}
		}).blur(function() {
			if( $(this).val() == '' ) {
				$(this).val('First name');
			}
		});

		$('#e_lastname').focus(function() {
			if( $(this).val() == 'Last name' ) {
				$(this).val('');
			}
		}).blur(function() {
			if( $(this).val() == '' ) {
				$(this).val('Last name');
			}
		});

		$('#e_companyname').focus(function() {
			if( $(this).val() == 'Company name' ) {
				$(this).val('');
			}
		}).blur(function() {
			if( $(this).val() == '' ) {
				$(this).val('Company name');
			}
		});

		$('#e_emailaddress').focus(function() {
			if( $(this).val() == 'Email address' ) {
				$(this).val('');
			}
		}).blur(function() {
			if( $(this).val() == '' ) {
				$(this).val('Email address');
			}
		});
	}
	
};

$(document).ready( scientific.init );
