	
$(document).ready(function(){
						   
	
	//TABS

	if ( $(".detailTabs").length > 0 ) { $(".detailTabs > ul").tabs(); }
	if ( $(".activityTabs").length > 0 ) { $(".activityTabs > ul").tabs(); }
	
	
	$("#itemContainer").load("/buy/items/");
 	
							
	//Details
	
		//Place Bid
		
		$(".bid").click(
						
					 function(){
	
						 bid_id = $(this).attr('id');
						 buttons = "#buttons"+bid_id;
						 highBidCon = "#highBidCon"+bid_id;
						 placebidform = "#form"+bid_id;
						 $(buttons).animate({ marginLeft: -443}, 500 );
						 newbid = "#nbid"+bid_id;
						 newbider = "#nbider"+bid_id;
						 newbidfield = $("#nbid"+bid_id).attr('class');
					 });
		$(".cancelBidButton").click(
						
					 function(){
	
						 cancelbid_id = $(this).attr('id');
						 buttons = "#buttons"+bid_id;
						 
						 $(buttons).animate({ marginLeft: 0}, 300 );
						 
					 });
		
		
				$(".bidWide").click(
						
					 function(){
	
						 bid_id = $(this).attr('id');
						 buttons = "#buttons"+bid_id;
						 highBidCon = "#highBidConWide"+bid_id;
						 placebidform = "#form"+bid_id;
						 $(buttons).animate({ marginLeft: -632}, 500 );
						 newbid = "#nbid"+bid_id;
						 newbidfield = $("#nbid"+bid_id).attr('class');
					 });
		$(".cancelBidButtonWide").click(
						
					 function(){
	
						 cancelbid_id = $(this).attr('id');
						 buttons = "#buttons"+bid_id;
						 
						 $(buttons).animate({ marginLeft: 0}, 300 );
						 
					 });
		
	
		
	
	
	
		//Send Message
		
	   $(".sendMessage").toggle(
						function(){
								current_id = $(this).attr('id');
								formname = "#form"+current_id;
								cancelMessage = "#cancelMessage"+current_id;
								cancelDiv = "#cancelDiv"+current_id;
								mButton = "#mButton"+current_id;
								message_status = "#message_status"+current_id;
								message_action = "/account/send/";
								
								$(formname).animate({ top: "0px"}, 750 );
								$(cancelMessage).fadeIn("slow");
								$(cancelDiv).animate({ height: "153px"}, 750 );
									},
						function(){
								current_id = $(this).attr('id');
								formname = "#form"+current_id;
								cancelMessage = "#cancelMessage"+current_id;
								cancelDiv = "#cancelDiv"+current_id;
								message_status = "#message_status"+current_id;
								message_action = "/account/send/";
								
								$(formname).animate({ top: "-153px"}, 550 );
								$(cancelMessage).fadeOut("fast");
								$(cancelDiv).animate({ height: "5px"}, 550 );
									}
							);
	   
	    
			//Add Comment $(this).parent()

	
	
	   $(".addComment").toggle(
						function(){
								current_id = $(this).attr('id');
								formname = "#form"+current_id;
								cancelMessage = "#cancelComment"+current_id;
								cancelDiv = "#cancelDiv"+current_id;
								cButton = "#cButton"+current_id;
								message_status = "#cmessage_status"+current_id;
								message_action = "/buy/comment/";
								
								$(formname).animate({ top: "0px"}, 750 );
								$(cancelMessage).fadeIn("slow");
								$(cancelDiv).animate({ height: "153px"}, 750 );
									},
						function(){
								current_id = $(this).attr('id');
								formname = "#form"+current_id;
								cancelMessage = "#cancelComment"+current_id;
								cancelDiv = "#cancelDiv"+current_id;
								message_status = "#cmessage_status"+current_id;
								message_action = "/buy/comment/";
								
								$(formname).animate({ top: "-153px"}, 550 )
								$(cancelMessage).fadeOut("fast");
								$(cancelDiv).animate({ height: "5px"}, 550 );
									}
							);
	   
	          
			
			
			
			$(".dropdownform").submit(function() {
											  thisform = $(this).attr('id');
										//$(formname).trigger('submit');
          // now we're going to capture *all* the fields in the
          // form and submit it via ajax.
          
          // :input is a macro that grabs all input types, select boxes
          // textarea, etc.  Then I'm using the context of the form from 
          // the initial '#contactForm' to narrow down our selector
          var inputs = [];
          $(':input', this).each(function() {
            inputs.push(this.name + '=' + escape(this.value));
			run = inputs.join('&');
          })
          
          // now if I join our inputs using '&' we'll have a query string
          jQuery.ajax({
            type: "POST",
            data: run,
            url: this.action,
            timeout: 2000,
            error: function() {
              //console.log("Failed to submit");
            },
            success: function(r) { 
				//alert(thisform);
				$(message_status).replaceWith(r);
			  	$(formname).animate({ top: "-153px"}, 550 )
				$(cancelMessage).fadeOut("fast");
				$(cancelDiv).animate({ height: "5px"}, 550 );
				
            }
          }) // checkout http://jquery.com/api for more syntax and options on this method.
          
          // re-test...
          // by default - we'll always return false so it doesn't redirect the user.
          return false;
        })
			
			
						$(".rdropdownform").submit(function() {
										//$(formname).trigger('submit');
          // now we're going to capture *all* the fields in the
          // form and submit it via ajax.
          
          // :input is a macro that grabs all input types, select boxes
          // textarea, etc.  Then I'm using the context of the form from 
          // the initial '#contactForm' to narrow down our selector
          var inputs = [];
          $(':input', this).each(function() {
            inputs.push(this.name + '=' + escape(this.value));
			run = inputs.join('&');
          })
          
          // now if I join our inputs using '&' we'll have a query string
          jQuery.ajax({
            type: "POST",
            data: run,
            url: this.action,
            timeout: 2000,
            error: function() {
              //console.log("Failed to submit");
            },
            success: function(r) { 
              //alert(r);
			  $(message_status).replaceWith(r);
			  $(replyMessage).animate({ top: "-155px"}, 750 );
				$(replyContainer).animate({ height: "0px"}, 750 );
            }
          }) // checkout http://jquery.com/api for more syntax and options on this method.
          
          // re-test...
          // by default - we'll always return false so it doesn't redirect the user.
          return false;
        })
						
						
												$("#messagesendform").submit(function() {
										//$(formname).trigger('submit');
          // now we're going to capture *all* the fields in the
          // form and submit it via ajax.
          
          // :input is a macro that grabs all input types, select boxes
          // textarea, etc.  Then I'm using the context of the form from 
          // the initial '#contactForm' to narrow down our selector
          var inputs = [];
          $(':input', this).each(function() {
            inputs.push(this.name + '=' + escape(this.value));
			run = inputs.join('&');
          })
          
          // now if I join our inputs using '&' we'll have a query string
          jQuery.ajax({
            type: "POST",
            data: run,
            url: this.action,
            timeout: 2000,
            error: function() {
              //console.log("Failed to submit");
            },
            success: function(r) { 
              //alert(r);
			  $("#message_status").replaceWith(r);
            }
          }) // checkout http://jquery.com/api for more syntax and options on this method.
          
          // re-test...
          // by default - we'll always return false so it doesn't redirect the user.
          return false;
        })
												
												
			$("#feedbackForm").submit(function() {
										//$(formname).trigger('submit');
          // now we're going to capture *all* the fields in the
          // form and submit it via ajax.
          
          // :input is a macro that grabs all input types, select boxes
          // textarea, etc.  Then I'm using the context of the form from 
          // the initial '#contactForm' to narrow down our selector
          var inputs = [];
          $(':input', this).each(function() {
            inputs.push(this.name + '=' + escape(this.value));
			run = inputs.join('&');
          })
          
          // now if I join our inputs using '&' we'll have a query string
          jQuery.ajax({
            type: "POST",
            data: run,
            url: this.action,
            timeout: 2000,
            error: function() {
              //console.log("Failed to submit");
            },
            success: function(r) { 
              //alert(r);
			  $("#messageContainer").replaceWith(r);
            }
          }) // checkout http://jquery.com/api for more syntax and options on this method.
          
          // re-test...
          // by default - we'll always return false so it doesn't redirect the user.
		  
          return false;
        })
			
			
			
			$("#feedbackForm2").submit(function() {
										//$(formname).trigger('submit');
          // now we're going to capture *all* the fields in the
          // form and submit it via ajax.
          
          // :input is a macro that grabs all input types, select boxes
          // textarea, etc.  Then I'm using the context of the form from 
          // the initial '#contactForm' to narrow down our selector
          var inputs = [];
          $(':input', this).each(function() {
            inputs.push(this.name + '=' + escape(this.value));
			run = inputs.join('&');
          })
          
          // now if I join our inputs using '&' we'll have a query string
          jQuery.ajax({
            type: "POST",
            data: run,
            url: this.action,
            timeout: 2000,
            error: function() {
              //console.log("Failed to submit");
            },
            success: function(r) { 
             // alert(r);
			  $("#messageContainer2").replaceWith(r);
			  //$("#message_status").load("/account/sendfeedback/");
            }
          }) // checkout http://jquery.com/api for more syntax and options on this method.
          
          // re-test...
          // by default - we'll always return false so it doesn't redirect the user.
          return false;
        })
			
						
						
						
	
			
			
			
			$(".placebidform").submit(function() {
											   
											   
	
											   
										//$(formname).trigger('submit');
          // now we're going to capture *all* the fields in the
          // form and submit it via ajax.
          
          // :input is a macro that grabs all input types, select boxes
          // textarea, etc.  Then I'm using the context of the form from 
          // the initial '#contactForm' to narrow down our selector
          var inputs = [];
          $(':input', this).each(function() {
            inputs.push(this.name + '=' + escape(this.value));
			run = inputs.join('&');
          })
          
          // now if I join our inputs using '&' we'll have a query string
          jQuery.ajax({
            type: "POST",
            data: run,
            url: this.action,
            timeout: 2000,
            error: function() {
              //console.log("Failed to submit");
            },
            success: function(r) { 
				
				$(highBidCon).html(r);
			  	$(highBidCon).fadeIn("slow");
				$("#itemContainer").load("/buy/items/"+Math.random()*99999);
				$(newbid).load("/buy/newbid/"+newbidfield);
				$(newbider).load("/buy/newbider/"+newbidfield);

            }
          }) // checkout http://jquery.com/api for more syntax and options on this method.
          
          // re-test...
          // by default - we'll always return false so it doesn't redirect the user.
          return false;
        })
			
			
			
			
						$(".placebidformWide").submit(function() {
											   
											   
	
											   
										//$(formname).trigger('submit');
          // now we're going to capture *all* the fields in the
          // form and submit it via ajax.
          
          // :input is a macro that grabs all input types, select boxes
          // textarea, etc.  Then I'm using the context of the form from 
          // the initial '#contactForm' to narrow down our selector
          var inputs = [];
          $(':input', this).each(function() {
            inputs.push(this.name + '=' + escape(this.value));
			run = inputs.join('&');
          })
          
          // now if I join our inputs using '&' we'll have a query string
          jQuery.ajax({
            type: "POST",
            data: run,
            url: this.action,
            timeout: 2000,
            error: function() {
              //console.log("Failed to submit");
            },
            success: function(r) { 
				
				$(highBidCon).html(r);
			  	$(highBidCon).fadeIn("slow");
				$("#itemContainer").load("/buy/items/"+Math.random()*99999);
				$(newbid).load("/buy/newbid/"+newbidfield);

            }
          }) // checkout http://jquery.com/api for more syntax and options on this method.
          
          // re-test...
          // by default - we'll always return false so it doesn't redirect the user.
          return false;
        })
			
			
			
			
			
			
			
			
			
			
					$(".placewatchform").submit(function() {
											   
											   
	
											   
										//$(formname).trigger('submit');
          // now we're going to capture *all* the fields in the
          // form and submit it via ajax.
          
          // :input is a macro that grabs all input types, select boxes
          // textarea, etc.  Then I'm using the context of the form from 
          // the initial '#contactForm' to narrow down our selector
          var inputs = [];
          $(':input', this).each(function() {
            inputs.push(this.name + '=' + escape(this.value));
			run = inputs.join('&');
          })
          
          // now if I join our inputs using '&' we'll have a query string
          jQuery.ajax({
            type: "POST",
            data: run,
            url: this.action,
            timeout: 2000,
            error: function() {
              //console.log("Failed to submit");
            },
            success: function(r) { 
				
				$("#itemContainer").load("/buy/items/"+Math.random()*99999);
				

            }
          }) // checkout http://jquery.com/api for more syntax and options on this method.
          
          // re-test...
          // by default - we'll always return false so it doesn't redirect the user.
          return false;
        })
					
					
					
					
					
												
					
					
					
					
								$(".itemListForm").submit(function() {
											   
											   
	
											   
										//$(formname).trigger('submit');
          // now we're going to capture *all* the fields in the
          // form and submit it via ajax.
          
          // :input is a macro that grabs all input types, select boxes
          // textarea, etc.  Then I'm using the context of the form from 
          // the initial '#contactForm' to narrow down our selector
          var inputs = [];
          $(':input', this).each(function() {
            inputs.push(this.name + '=' + escape(this.value));
			run = inputs.join('&');
          })
          
          // now if I join our inputs using '&' we'll have a query string
          jQuery.ajax({
            type: "POST",
            data: run,
            url: this.action,
            timeout: 2000,
            error: function() {
              console.log("Failed to submit");
            },
            success: function(r) { 

				$("#itemContainer").load("/buy/items/"+Math.random()*99999);
				

            }
          }) // checkout http://jquery.com/api for more syntax and options on this method.
          
          // re-test...
          // by default - we'll always return false so it doesn't redirect the user.
          return false;
        })
								
								
								
								
			
			
			
			
			// Send Reply
			
			
			
					 $(".replyButton").toggle(
									  
						function(){
								reply_id = $(this).attr('id');
								replyContainer = "#replyContainer"+reply_id;
								replyMessage = "#replyMessage"+reply_id;
								message_status = "#message_status"+reply_id;
								$(replyMessage).animate({ top: "0px"}, 750 );
								$(replyContainer).animate({ height: "155px"}, 750 );
									},
									
						function(){

								reply_id = $(this).attr('id');
								replyContainer = "#replyContainer"+reply_id;
								replyMessage = "#replyMessage"+reply_id;
								message_status = "#message_status"+reply_id;
								$(replyMessage).animate({ top: "-155px"}, 750 );
								$(replyContainer).animate({ height: "0px"}, 750 );
									}
							);// JavaScript Document
					 
					 
					 


	
	

	//Buttons
	
	$(".highBidContainer").click(function(){
		itemnumber = $(this).attr('rel'); 
		window.location = "/buy/details/"+itemnumber;
										  });
	
	$(".commentupdate").click(function(){
		itemnumber = $(this).attr('rel'); 
		$("#fragment-2").load("/buy/commentupdate/"+itemnumber+"/"+Math.random()*99999);
									   });
	
	$("#pubMessage").click(function(){
	$("#pubMessageForm").trigger('submit');
	$("#messageContainer").load("/account/send/");
										});
	
	$(".rePostLink").click(function(e){
		repostform = '#'+$(this).attr('rel');
		$(repostform).trigger('submit');
		e.preventDefault();
										});									
	
	$(".contactSeller").click(function(){
	$("#contactSeller").trigger('submit');									
										});
	
  $("#inviteFriendsButton").click(function(){
	$("#inviteFriendsForm").trigger('submit');									
										});
	
	
  $("#itemSubmitButton").click(function(e){
	$("#submitItem").trigger('submit');	
	e.preventDefault();
										});
  
    $("#editButton").click(function(){
	$("#editItem").trigger('submit');									
										});
	
	    $("#editButton2").click(function(e){
	$("#editItem2").trigger('submit');	
	e.preventDefault();
										});
	
	    $("#editProfileButton").click(function(){
	$("#editProfile").trigger('submit');									
										});
		
		    $("#updateProfile").click(function(){
	$("#submitProfile").trigger('submit');									
										});
			
				
		    $("#saveButton").click(function(){
	$("#saveform").trigger('submit');									
										});
			
				
		    $("#replyButton").click(function(){
	$("#replyform").trigger('submit');									
										});
			 
			 $("#messagesend").click(function(){
	$("#messagesendform").trigger('submit');									
										});
			
				
		    $("#deleteButton").click(function(){
	$("#deleteform").trigger('submit');									
										});
			
			$("#feedbackMessage").click(function(){
	  $("#feedbackForm").trigger('submit');
	  									});
			
			$("#feedbackMessage2").click(function(){
	  $("#feedbackForm2").trigger('submit');
	  									});
										
			
			    
				
				$("#contentSearchField").focus(function() {
	if( this.value == this.defaultValue ) {
		this.value = "";
	}
}).blur(function() {
	if( !this.value.length ) {
		this.value = this.defaultValue;
	}
});


$(".dam").change(function(){
								 
								
				
				v = $(".dam").val();
				v = v.replace(/[^0-9.\-]/g, ""); 
				$(".dam").val(v);
        }); 

$(".dam1").change(function(){
								 
								
				
				v = $(".dam1").val();
				v = v.replace(/[^0-9.\-]/g, ""); 
				$(".dam1").val(v);
        }); 
							

	 
	 
			
			
			
					//Login 
		if($.browser.msie){
		$(".loginNow").click(
									
									function(){
										alert("Please login before placing a bid");
									});
		} else {
					
					
		$(".loginNow").click(
									function(e){
										left = e.pageX - 300;
										top = e.pageY - 340;
										$("#loginBubble").load("/auth/loginRaw/"+(new Date()).getTime());
										$("#loginBubble").css({'top' : top, 'left' : left});
										$("#loginBubble").fadeIn("slow");
										e.preventDefault();
									});
		}
		
		
		if($.browser.msie){
		$(".loginNow2").click(
									
									function(){
										alert("Please login before watching an item");
									});
		} else {
		
		
		$(".loginNow2").click(
									function(e){
										left = e.pageX - 300;
										top = e.pageY - 340;
										$("#loginBubble").load("/auth/loginRaw/");
										$("#loginBubble").css({'top' : top, 'left' : left});
										$("#loginBubble").fadeIn("slow");
										e.preventDefault();
									});
		}
		
	
	
	
$("#searchButtonClick").click( 
							  function(){
						
						v = $("#searchFieldClick").val().length;
						if(v < 3){
						alert("please enter at least 3 characters");
						return false;
						}
						   });

$("#contentSearchButton").click( 
							  function(){
						
						v = $("#contentSearchField").val().length;
						if(v < 3){
						alert("please enter at least 3 characters");
						return false;
						}
						   });
	
		
		
		
		
			
			
			
  });
