$(document).ready(function() {
	//$('div#htop').hide();
		// placed here to avoid error on inner pages
		var msie6 = $.browser == 'msie' && $.browser.version < 7;
		if (!msie6) {			
			var top = $('#htop').offset().top - parseFloat($('#htop').css('margin-top').replace(/auto/, 0));
			$(window).scroll(function (event) {			  
			// what the y position of the scroll is
			var y = $(this).scrollTop();
			// whether that's below the form
			if (y >= top) {				
				// if so, ad the fixed class
				$('#htop').addClass('fixed-bar');
			} else {				
			// otherwise remove it
				$('#htop').removeClass('fixed-bar');
				}			
			});		  
		}		
//	$("a#single_1").fancybox();
//		
//	$("a#single_2").fancybox({
//		'zoomOpacity'			: true,
//		'overlayShow'			: false,
//		'zoomSpeedIn'			: 500,
//		'zoomSpeedOut'			: 500
//	});
//	
//	$("a#single_3").fancybox({
//		'hideOnContentClick'	: false,
//		'overlayShow'			: true,
//		'zoomSpeedIn'			: 600,
//		'zoomSpeedOut'			: 500,
//		'easingIn'				: 'easeOutBack',
//		'easingOut'				: 'easeInBack',
//		'overlayOpacity'		: 0.8,
//		'padding'				: 0
//	});
//
//	$("a#single_4").fancybox({
//		'hideOnContentClick'	: true,
//		'easingIn'				: 'easeOutBack',
//		'padding'				: 0,
//		'overlayShow'			: true,
//		'overlayOpacity'		: 0.5
//	});
//
//	
//	$("a.group").fancybox({
//		'hideOnContentClick'	: true,
//		'easingIn'				: 'easeOutBack',
//		'padding'				: 0,
//		'overlayShow'			: true,
//		'overlayOpacity'		: 0.5,
//		'imageScale'			: true
//	});
//
//	$("a#inline").fancybox({
//		'hideOnContentClick'	: true,
//		'zoomOpacity'			: true,
//		'overlayShow'			: true,
//		'overlayOpacity'		: 0.5,
//		'zoomSpeedIn'			: 500,
//		'zoomSpeedOut'			: 500,
//		'overlayOpacity'		: 0.7
//	});
});


//change status message for user
function changeStatusMessage(user_id, str) {
	/*if (str=="")   {
		document.getElementById("txtStatus").innerHTML="";
		return;
	}
	*/
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	} else {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			document.getElementById("txtStatus").innerHTML=xmlhttp.responseText;
			document.getElementById("editForm").style.display = "none";
			document.getElementById("editButton").style.display = "block";
		}
	}
	xmlhttp.open("GET","/getStatus.php?q="+str+"&user_id="+user_id,true);
	xmlhttp.send();
}

//show/hide forms
function showEditForm(){
	document.getElementById("editButton").style.display = "none";
	$("#editForm").fadeIn();
}


//browse photos for user
function browseUserPhotos(user_id, gid, pid, path) {
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	} else {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
			manageComments(user_id, pid, '','','' );
		}
	}
	xmlhttp.open("GET","/showPhoto.php?user_id="+user_id+"&gid="+gid+"&pid="+pid+"&path="+path,true);
	xmlhttp.send();
}

//comments
function manageComments(user_id, pid, txtNumber, comment_author, comment_content ) {
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	} else {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			document.getElementById("commentHint").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","/getComments.php?profile_id="+user_id+"&pid="+pid+"&txtNumber="+txtNumber+"&comment_author="+comment_author+"&comment_content="+comment_content,true);
	xmlhttp.send();
}

//like under photo
function manageLiked(pid) {
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	} else {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			document.getElementById("likedNumber").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","/showLiked.php?pid="+pid,true);
	xmlhttp.send();
}

//manageVote(<?php echo $user_id;?>)
function manageVote(profile_id) {
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	} else {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			//document.getElementById("voteContest").innerHTML=xmlhttp.responseText;
			document.getElementById("dialog-message").innerHTML=xmlhttp.responseText;
			$( "#dialog-message" ).dialog( "open" );
		}
	}
	xmlhttp.open("GET","/getVote.php?profile_id="+profile_id,true);
	xmlhttp.send();
}

//slider functions
	function roundit(which){
		return Math.round(which*100)/100
	}

	function getFeetInches(centimeters) {
		var realFeet = centimeters*0.03280839895;//to feets
		var feet = Math.floor(realFeet);
		var inches = Math.round((realFeet - feet) * 12);
		var text = feet + "'" + inches + '"';
		return text;
	}

	function getInches(centimeters) {
		var realFeet = centimeters*0.03280839895*12;//to inches
		var inches = Math.round(realFeet*100)/100;
		var text = inches + 'inches';
		return text;
	}

	function getWeight(kilo) {
		var realLb = kilo*2.2046;//to pounds
		
		var pounds = Math.round(realLb*100)/100;
		var text = pounds + 'lb';
		return text;
	}
