// JavaScript Document

 google.load("jquery", "1.4.2");
 google.load("jqueryui", "1.8.2");

function initialize() {		

		$.getScript('include/js/jquery.validate.min.js', function(){
			$("#submitForm").validate({
				rules: {
					resume: {
					  required: true,
					  accept: "pdf|doc|docx|txt"
					}
				}
			 });
		})
		
		$.getScript('include/js/jquery.cycle.all.min.js', function(){
			//--------------Image rotator-----------------------------
			$('.flashleft').cycle({
				fx: 'fade' 
			});
		})
		
		$.getScript('include/js/jquery-color.js')		
		
		//----- Gets query string
		function getParameterByName( name )
		{
		  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		  var regexS = "[\\?&]"+name+"=([^&#]*)";
		  var regex = new RegExp( regexS );
		  var results = regex.exec( window.location.href );
		  if( results == null )
			return "";
		  else
			return results[1];
		}

		
		
		//--------------Scroll to function------------------------//
		function scrollWin(scrollToPoint){
			if(scrollToPoint.length != 0) {								
				$('html, body').animate({
					scrollTop: $("#"+scrollToPoint).offset().top
				},'slow');						
			}else{
				$('html, body').animate({
					scrollTop: $('#subContent').offset().top
				},'slow');		
			}			
		}
		$('.scrollTo').click(function(event){
			event.preventDefault();
			var scrollToPoint = $(this).attr('href');
			scrollWin(scrollToPoint);			
		});	
		
		
		
		//---------------Form functions--------------------------
		$('#subContent input:not([type=submit]), #subContent textarea, #subContent select ').focus(function(){
			$(this).closest('fieldset').animate({backgroundColor:'#FFF3D0'},'fast')				
			$(this).closest('fieldset').siblings('fieldset').animate({backgroundColor:'#FFFFFF'},'fast')
			$(this)
				.animate({backgroundColor:'#ffffff'},'fast')				
				.css('border','1px solid #41577E')
		});		
		
		$('#subContent input:not([type=submit]), #subContent textarea, #subContent select').blur(function(){
			$(this)
				.animate({backgroundColor:'#CCCCCC'},'fast')	
				.css('border','1px solid #ffffff')
			//$(this).closest('fieldset').animate({backgroundColor:'#FFFFFF'},'fast')
						
		});
		
		$('#subContent input:not([type=button]):not([type=submit])').one('focus',function(){
			$(this)
				.val("")
				.css('color','#000000')

		})
		
		$('#subContent input[type="submit"]:not(.nostyle),#subContent input[type="button"]').mouseenter(function(){
			$(this).css({
					backgroundColor: '#41577E',
					color:	'#ffffff'
				})
		})	
		
		$('#subContent input[type="submit"]:not(.nostyle),#subContent input[type="button"]').mouseleave(function(){
			$(this).css({
					backgroundColor: '#CCCCCC',
					color:	'#333333'
				})
		})								
		 
		 
		 if(getParameterByName('sentMessage').length > 0){
			 alert('Your message has been sent!');
			 scrollWin('submitForm')
		 }
		 	
		$('#date').datepicker()
		 	
			
		$('#photogallery img').click(function(){
				$('body').prepend('<div id="shadow"></div>');
				$('#shadow').css({
									backgroundColor:"#000000",
									position:"fixed",
									opacity:"0",
									width:"100%",
									height:"100%",
									zIndex:"150",
									marginTop:"-10px",
									paddingTop:"10px"
								})
				$('#shadow').animate({opacity:".5"},"fast")
				$('body').prepend('<div id="imageGalleryHolder"><img src="'+$(this).attr("src")+'" ></div>');
				$('#imageGalleryHolder').css({
											position:"fixed",
											margin:"0 auto",
											zIndex:"160",										
											width:"100%",
											textAlign:"center",
											top:"10%",																						
											opacity:"0"
											})
				$('#imageGalleryHolder img').css({border:"10px solid #ffffff", cursor:"pointer"})
				$('#imageGalleryHolder').animate({opacity:"1"},"slow")
		
			})
			
			$('#imageGalleryHolder, #shadow').live('click',function(){
					$('#imageGalleryHolder').animate({opacity:"0"},"fast", function(){$(this).remove()});
					$('#shadow').animate({opacity:"0"},"slow", function(){$(this).remove()});
				})	
				
			
			$('.userActive').click(function(){
				var ActiveData
				ActiveData= "UserID=" + $(this).attr('rel');
				if($(this).attr("checked")==true){
					ActiveData+= "&active=true";
					$.post("firm-news-admin-active.asp", ActiveData )	
				}else{
					ActiveData+= "&active=false";
					$.post("firm-news-	admin-active.asp", ActiveData )	
				}
			})
			
			$('#menu > li').mouseenter(function(){
				$(this).find('.submenu').show();
			});
			
			$('#menu > li').mouseleave(function(){
				$(this).find('.submenu').hide();
			});
						
			
			if ($(window.parent.frames[0].document).length)
			{		
				$('#subContent').addClass('cms')	
			}
	
}



google.setOnLoadCallback(initialize);



