$(document).ready(function() {

	$(document).pngFix(); 
	
	$(".recent_project_item").hover(
	  function () {
		$("div.recent_project_item_description",this).show();
	  },
	  function () {
		$("div.recent_project_item_description",this).hide();
	  }
	);

//	$(".recent_project_item").each(function(){
//		$(this).hover(
//			function() {
//				//alert('in');	
//				$('div.recent_project_item_description', this).show();
//				
//			},
//			function() {
//				// alert('out');
//				$('div.recent_project_item_description', this).hide();
//			}
//		);
//		
//	});
		
	$("#make_enquiry").click(
		function(){
			if($("#enquiry_popup").is(":visible")){
				$("#enquiry_toggler").html("(+)");
				$("#enquiry_popup").slideUp();
				$("#enquiry_popup").css("z-index",500);
				
			}else{
				$("#enquiry_toggler").html("(-)");
				$("#enquiry_popup").css("z-index",1000);
				$("#enquiry_popup").slideDown();
			}

		}
	);
	
	$("#jquery_slide_arrow_right").hover(
	  function () {
		$("img",this).attr('src','images/right_arrow_hover.png');
		var filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/right_arrow_hover.png\', sizingMethod=\'scale\')';
		$('SPAN',this).css('filter',filter);
	  },
	  function () {
		$("img",this).attr('src','images/right_arrow.png');
		var filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/right_arrow.png\', sizingMethod=\'scale\')';
		$('SPAN',this).css('filter',filter);
	  }
	);
	
	$("#jquery_slide_arrow_left").hover(
	  function () {
		$("img",this).attr('src','images/left_arrow_hover.png');
		var filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/left_arrow_hover.png\', sizingMethod=\'scale\')';
		$('SPAN',this).css('filter',filter);
	  },
	  function () {
		$("img",this).attr('src','images/left_arrow.png');
		var filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/left_arrow.png\', sizingMethod=\'scale\')';
		$('SPAN',this).css('filter',filter);
	  }
	);

        // add class "last"
        $(".sf-menu li:last-child a").addClass('last');

        // image change and paging script
        $("#pagination a").click(function() {
            $('a[id*="java_"]').removeClass('current');
            $(this).addClass("current");
            $('img[name="screenshot"]').attr('src', $(this).attr('name'));
        });
        

        //limit characters in texarea
        $("#message").keyup(function() {
            if(this.value.length >= 1000)
                this.value = this.value.substr(0,1000);
        });


        // ajax form submit
        var options = {
            target:        '#outputForm'   // target element(s) to be updated with server response
//        beforeSubmit:  showRequest,  // pre-submit callback
//        success:       showResponse  // post-submit callback

            // other available options:
            //url:       url         // override for form's 'action' attribute
            //type:      type        // 'get' or 'post', override for form's 'method' attribute
            //dataType:  null        // 'xml', 'script', or 'json' (expected server response type)
            //clearForm: true        // clear all form fields after successful submit
            //resetForm: true        // reset the form after successful submit

            // $.ajax options can be used here too, for example:
            //timeout:   3000
        };

        // bind form using 'ajaxForm'
        $('#talkForm').ajaxForm(options);


});

// pre-submit callback
function showRequest(formData, jqForm, options) {
    // formData is an array; here we use $.param to convert it to a string to display it
    // but the form plugin does this for you automatically when it submits the data
//    var queryString = $.param(formData);

    // jqForm is a jQuery object encapsulating the form element.  To access the
    // DOM element for the form do this:
    // var formElement = jqForm[0];

//    alert('About to submit: \n\n' + queryString);

    // here we could return false to prevent the form from being submitted;
    // returning anything other than false will allow the form submit to continue
    return true;
}

// post-submit callback
function showResponse(responseText, statusText, xhr, $form)  {
    // for normal html responses, the first argument to the success callback
    // is the XMLHttpRequest object's responseText property

    // if the ajaxForm method was passed an Options Object with the dataType
    // property set to 'xml' then the first argument to the success callback
    // is the XMLHttpRequest object's responseXML property

    // if the ajaxForm method was passed an Options Object with the dataType
    // property set to 'json' then the first argument to the success callback
    // is the json data object returned by the server

//    alert(responseText);
}
