
var $j = jQuery.noConflict();
     
// Use jQuery via $j(...)
$j(document).ready(function(){
     
      //ZEBRA STRIPE ROWS
       $j('tr.message_row:even').addClass('alt');
       $j('.messages_table tr:even').addClass('alt');
       $j('div.classifiedBit:even').addClass('alt');
       $j('#pendingSeller.tradesTable tr:odd td').addClass('alt');
       $j('#pendingBuyer.tradesTable tr:odd td').addClass('alt');
       $j('#clearedSeller.tradesTable tr:odd td').addClass('alt');
       $j('#clearedBuyer.tradesTable tr:odd td').addClass('alt');
       $j('#tradeHistory tr:odd td').addClass('alt');
   
       
       
       //AUTO CLEAR HEADER SEARCH
       $j( '#headerSearchBiz' ).focus( function(){
       		if( $j( '#headerSearchBiz' ).val() == 'Enter a business name or keyword' ){
       			$j( '#headerSearchBiz' ).val( '' );
       		}
       });
       $j( '#headerSearchBiz' ).blur( function(){
       		if( $j( '#headerSearchBiz' ).val() == '' ){
       			$j( '#headerSearchBiz' ).val( 'Enter a business name or keyword' );
       		}
       });
       
// show calendar

	$j(".datepicker").datepicker();
	

//show/hide ratings
		// hide all blocks that have class hide
  		//$('.hide').hide();
  		// toggle link 
  		// changing html of link
  		$j('#rateThis').toggle(function(){
  		  $j(this).next("form#rating").slideDown('slow').removeClass('hide').preventDefault;
  		    //$(this).html('Hide more filter options');
  		  },function(){
  		    $j(this).next("form#rating").slideUp('fast').addClass('hide').preventDefault;
  		    //$(this).html('Show more filter options');
  		});
  		
  		$j('#reject').toggle(function(){
  		$j(this).next("form#rejectTrade").slideDown('slow').removeClass('hide').preventDefault;

  		  },function(){
  		    $j(this).next("form#rejectTrade").slideUp('fast').addClass('hide').preventDefault;

  		});
  		
  		
  		

//add category
	//$j('.hide').hide();
	//$j('.add').toggle(function(){
	//	$j(this).parent().next('.categoryChoice').show();
//		},function(){
//		$j(this).parent().next('.categoryChoice').hide();
	
	
	
//	});
	

	   		var i = 2;

		   $j( '#addAnother' ).click( function(){
	   		
	   		$j('#cat-'+ i).removeClass('hide')
		   		i++;
		   		
		   	if (i==4){
		   	
		   		$j(this).hide();	
		   	
		   	}	
		   	return false;
		   	
	   	});
	   	
  	


  		
// star ratings  		
 function insert_dynamic_control(form){
					$j('div.controls',form).html(
						['<input type="radio" class="star" name="dynamic-control" value="1"/>',
							'<input type="radio" class="star" name="dynamic-control" value="2"/>',
							'<input type="radio" class="star" name="dynamic-control" value="3"/>',
							'<input type="radio" class="star" name="dynamic-control" value="4"/>',
							'<input type="radio" class="star" name="dynamic-control" value="5"/>'
						].join('')
					);
					$j('input[type=radio]',form).rating();
				};



 });
 
 //verify rating form has a comment
 function checkRatingComment(){
	
	var strLength = document.rateForm.notes.value.length;
	
	if( strLength < 5 ){
		alert( 'Please enter a description of your trading experience along with the rating.' );
		return false;
	}else{
		if( strLength > 400 ){
			alert( 'Please keep your description under 400 characters. It is currently ' + strLength + '.' );
			return false;
		}else{
			return true;
		}
	}
}
