$(document).ready(function()
	{	
		//bounce an object
		$(".gcatitem").hover(function(){	$(this).children('.gcatleft').children('.gcattitle').animate({top:"-=15px"},250).animate({top:"+=15px"},250); });
		
		$(".nextimage, .previmage").hover(function(){
			$(this).css('filter','alpha(opacity=35)');
			$(this).css('opacity','0.35');
		},
		function(){
			$(this).css('filter','alpha(opacity=0)');
			$(this).css('opacity','0');
		});
		
	});
	
	
	$(function() {
		$('.gimage a').tooltip({
			track: true,
			delay: 0,
			showURL: false,
			showBody: " - ",
			fade: 250
		});
	});

	$(function() {
			$(".catselect .option").click(function() {
				var pick = "";
				$(this).toggleClass("active");
				$(".catselect .active").each(function() {
					pick += $(this).attr("value") + ", ";
				});
				$(".pick2").val(pick);
			 });
		});
		
	function validateform(aForm) {  //phone settings form validation
		var reason = "";

		reason += validateTitle(aForm.title);		
		reason += validateCategories(aForm.categories);
		reason += validateFile(aForm.uploadedfile);		
	      
		if (reason.length > 0) {
			alert("Some fields need correction:\n" + reason);
			return false;
		}

		return true;
	}
	
	function validateTitle(fld) {
	    var error = "";
	    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    

		if (fld.value == "") {
	        error = "You didn't enter Title.\n";
	        fld.style.background = '#f9bfbf';	    	    
	    } else {
	        fld.style.background = 'White';
	    }
	    return error;
	}
	
	function validateCategories(fld) {
	    var error = "";
	    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    

		if (fld.value == "") {
	        error = "You didn't select any Categories.\n";	            	   
	    } 
	    return error;
	}
	
	function validateFile(fld) {
	    var error = "";
	    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    
		if (fld.value == "") {
	        error = "You didn't select a file.\n";	            	   
	    } 
		else {
			var aval = fld.value.split(".");
			if((aval[aval.length-1]!='jpg')&&(aval[aval.length-1]!='jpeg')){
				error = 'Only jpg files are accepted.\n';
			}
	    }
	    return error;
	}
