var $j = jQuery.noConflict();

$j.fn.equalHeight = function () {
    var height        = 0;
    var maxHeight    = 0;

    // Store the tallest element's height
    this.each(function () {
        height        = $j(this).outerHeight();
        maxHeight    = (height > maxHeight) ? height : maxHeight;
    });

    // Set element's min-height to tallest element's height
    return this.each(function () {
        var t            = $j(this);
        var minHeight    = maxHeight - (t.outerHeight() - t.height());
        var property    = $j.browser.msie && $j.browser.version < 7 ? 'height' : 'min-height';

        t.css(property, minHeight + 'px');
    });
};


// menu animation effect, it's not perfect, so uncomment only if you're sure ;) don't forgeyt about initMenu(); 4 lines down
 //function initMenu() {$('#sidebar ul ul').hide();$('#sidebar ul li a').hover(function() {$(this).next().slideToggle('normal');});}

$j(function () {

 //initMenu(); 
$j('div#portfolio ul li').quickpaginate({perpage: 6, showcounter: true, pager : $j("#pf_counter") });
$j('#container > div').equalHeight();
	$j("#dropmenu ul").css({display: "none"}); // Opera Fix
		$j("#dropmenu li").hover(
		function(){$j(this).find('ul:first').css({visibility: "visible",display: "none"}).show(268);},function(){
			$j(this).find('ul:first').css({visibility: "hidden"});
		});
	elementy = $j('#menutop').children().find('li');
	$j(elementy).each( function() 
	{
		if( $j(this).find('ul').size() !=0 ){
				$j(this).contents('a').append(' &rsaquo;');
			}
	});

	elementy2 = $j('#sidebar').children().find('li');
		$j(elementy2).each( function() 
		{
			if( $j(this).find('ul').size() !=0 ){
					$j(this).contents('a').prepend('&lsaquo; ');
				}
		});

	$j('.slides').cycle({
		fx: 'blindY', timeout: 6000
	});
	$j('.slides_texts').cycle({
		fx: 'scrollUp', timeout: 6000
	});

	var options = { 	
	target:        '#alert',
	beforeSubmit:  showRequest,
	success:       showResponse
}; 
$j('#contactForm').ajaxForm(options); 

$j("div#portfolio ul li div h3").hover(function() {
	$j(this).stop().animate({ paddingBottom: "20px", opacity: "0.9" }, 250 );
   		},function(){
   	$j(this).stop().animate({ paddingBottom: "0px", opacity: "1" }, 250);
});


});

function showRequest(formData, jqForm, options) { 
var queryString = $j.param(formData); 
return true; 
} 
function showResponse(responseText, statusText)  {  
} 
$j.fn.clearForm = function() {
  return this.each(function() {
	var type = this.type, tag = this.tagName.toLowerCase();
	if (tag == 'form')
	  return $j(':input',this).clearForm();
	if (type == 'text' || type == 'password' || tag == 'textarea')
	  this.value = '';
	else if (type == 'checkbox' || type == 'radio')
	  this.checked = false;
	else if (tag == 'select')
	  this.selectedIndex = -1;
  });
};


