// JavaScript Document
$(document).ready(function(){ // This sets the opacity of the thumbs to fade down to 0% when the page loads
	$(".opaque").fadeTo("slow", 0.2);
	/*$(".field_bg").fadeTo("slow", 0.7);
	$(".field_ta").fadeTo("slow", 0.7);
	$(".submit_btn").fadeTo("slow", 0.9);*/
	$("label").inFieldLabels({/*fadeOpacity:0.4*/});
	$(".1star").tipsy({
				html: true,
				gravity: 's',
				fade: true				
	});
	$(".2star").tipsy({
				html: true,
				gravity: 's',
				fade: true				
	});
	$(".3star").tipsy({
				html: true,
				gravity: 's',
				fade: true				
	});
	

	$(".opaque").hover(function(){
		$(this).fadeTo("slow", 1.0); // This sets the opacity to 100% on hover
	},function(){
   		$(this).fadeTo("slow", 0.2); // This sets the opacity back to 0% on mouseout
	});
	
	/*$(".field_bg").hover(function(){
		$(this).fadeTo("fast", 1.0); // This sets the opacity to 100% on hover
	},function(){
   		$(this).fadeTo("slow", 0.7); // This sets the opacity back to 0% on mouseout
	});
	
	$(".field_ta").hover(function(){
		$(this).fadeTo("fast", 1.0); // This sets the opacity to 100% on hover
	},function(){
   		$(this).fadeTo("slow", 0.7); // This sets the opacity back to 0% on mouseout
	});
	
	$(".submit_btn").hover(function(){
		$(this).fadeTo("fast", 0.9); // This sets the opacity to 70% on hover
	},function(){
   		$(this).fadeTo("slow", 0.7); // This sets the opacity back to 0% on mouseout
	});*/
});
$(document).ready(function(){
	
	$.localScroll.hash({
		target: '#right_content', // Could be a selector or a jQuery object too.
		queue:true,
		duration:500,
		reset:true
	});
						   
	$.localScroll({
		
			target:'#wrapper',
			axis:'y',
			queue:true
		
	});
	
	$("#contact").submit(function(){

	// 'this' refers to the current submitted form
	var str = $(this).serialize();

	   $.ajax({
	   type: "POST",
	   url: "php/contact.php",
	   data: str,
	   success: function(msg){
	
	$("#note").ajaxComplete(function(event, request, settings){
	
	if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
	{
	result = '<div class="notification_ok">Thanks for your email. I\'ll be in touch shortly.</div>';
	$("#fields").hide();
	}
	else
	{
	result = msg;
	}
	
	$(this).html(result);
	
	});
	
	}
	
	 });
	
	return false;
	
	});
	
	
	$("#port_login").submit(function(){

	// 'this' refers to the current submitted form
	var str = $(this).serialize();

	   $.ajax({
	   type: "POST",
	   url: "php/checklogin.php",
	   data: str,
	   success: function(msg){
	
	$("#diditwrong").ajaxComplete(function(event, request, settings){
	
	if(msg == 'OK') // Display Error message.
	{
	result = '<div class="notification_error">Something\'s not right. Try again.</div>';
	}
	else
	{
	result = msg;
	window.location = 'portfolio.php';
	}
	
	$(this).html(result);
	
	});
	
	}
	
	 });
	
	return false;
	
	});
	
	
	$('input.btnhover').each(function(){
		var t=$(this);
		var src1= t.attr('src'); // initial src
		var newSrc = src1.substring(src1.lastIndexOf('img/'), src1.lastIndexOf('.')); // let's get file name without extension
		t.hover(function(){
			$(this).attr('src', newSrc+ '-over.' + /[^.]+$/.exec(src1)); //last part is for extension       
		}, function(){
			$(this).attr('src', newSrc + '.' + /[^.]+$/.exec(src1)); //removing '-over' from the name
			});
	});

});