$(document).ready(function() {

		// Ajax Start & Stop Auto Functions...
		$("").ajaxStart(function() {
			$("#loading").show();
		});
		$("").ajaxStop(function() {
			$("#loading").hide();
		});
		
		function deleteNote(id) {
			
			$.ajax({
				url: "/_includes/_code/delete_customer_note.php",
				type: "post",
				data: "id="+id,
				success: function(html) {
						
					// determine where the note is...
					var noteDeleteParent = $("#note_"+id).parent().attr('id');
					var newFtrNote = "";
					var newFtrId = "";
					
					// remove the note from the page...
					$("#note_"+id).remove();
					
					switch(noteDeleteParent) {
						
						// here, we are deleting the feature note...
						// we need to get the last note added to the old div, and pull it out...
						
						case "cstFtrNote":
							newFtrId = $("#cstPstNotes div:first").attr('id');
							newFtrNote = "<div id='"+newFtrId+"' class='note'>";
							newFtrNote += $("#cstPstNotes div:first").html();
							newFtrNote += "</div>";
							
							$("#cstPstNotes div.note:first").remove();
							$("#cstFtrNote").html(newFtrNote);
							
							// unbind the original click listener, and reset so the new stuff is there as well...
							$(".noteslist div.delete").unbind("click");
							$(".noteslist div.delete").click(function() {
								var answer = confirm("Are you sure you want to delete this note?");
								if(answer) {
									var id = $(this).attr("id").replace("delete_","");
									deleteNote(id);
								}
							});
						
							// now, we need to unbind and rebind the same function... weird...
							break;
							
						case "mfgFtrNote":
							newFtrNote = $("#cstPstNotes div.note").html();
							break;
							
						case "cmpFtrNote":
							newFtrNote = $("#cstPstNotes div.note").html();
							break;
					}
					
					// remove the note from the page...
					
				}
			});
				
				
			// run ajax to delete item...
			
			// remove the item from the page...
			
			// now, if it's the feature note, we need to pull the first item
			// offf of the old stuff, and put it back into place... damn!
			
			//alert('deleting: ' + id + ' || parent: ' + noteDeleteParent);
			
			
		}

		// COMPONENT WRAP: this code will affect ALL components on the page...	
		$(".component_wrap").livequery(function() {

			//alert('works');
			
			$("tr").mouseover(function() {
			$("td",this).addClass("hover");
			}).mouseout(function() {
			$("td",this).removeClass("hover");
			});
			
			$("#cstNoteToggle").click(function() {
				// here, we need to do a few quick modifications...
				if($("#cstPstNotes").hasClass("hide")) {
					$("#cstPstNotes").removeClass("hide");
					$(this).html("Hide Notes");
					$("#cstNoteTitle").html("All Notes");
				} else {
					$("#cstPstNotes").addClass("hide");
					$(this).html("Show all Notes");
					$("#cstNoteTitle").html("Latest Note");
				}
			});
			
			$("#mfgNoteToggle").click(function() {
				// here, we need to do a few quick modifications...
				if($("#mfgPstNotes").hasClass("hide")) {
					$("#mfgPstNotes").removeClass("hide");
					$(this).html("Hide Notes");
					$("#mfgNoteTitle").html("All Notes");
				} else {
					$("#mfgPstNotes").addClass("hide");
					$(this).html("Show all Notes");
					$("#mfgNoteTitle").html("Latest Note");
				}
			});
			
			//$("div.noteslist div.delete").livequery("click",function() {
			$(".noteslist div.delete").click(function() {
				
				var answer = confirm("Are you sure you want to delete this note?");
				if(answer) {
					var id = $(this).attr("id").replace("delete_","");
					deleteNote(id);
				}
				//$(this).unbind("click");
			});
			
			// cst note add goes here...
			$("#cstNoteAdd").submit(function() {
				var formData = $(this).serialize();
				$.ajax({
					url: "/_includes/_code/add_customer_note.php",
					type: "post",
					data: formData,
					success: function(html) {
						
						// get the last note value...
						var lastNote = $("#cstFtrNote").html();
						
						// move the last note into the old notes area...
						$("#cstPstNotes").prepend(lastNote);
						$("#cstFtrNote").html(html);
						
						if($("#cstPstNotes").hasClass("hide")) {
							$("#cstNoteToggle").html("Show all Notes");
						} else {
							$("#cstNoteToggle").html("Hide Notes");
						}
						
						// we need to flash the new note...
						$( "#cstFtrNote" ).effect("highlight",{},5000);
						
						// we need to clear the form field...
						$("#noteText").val("");
						
						// unbind the original click listener, and reset so the new stuff is there as well...
						$(".noteslist div.delete").unbind("click");
						$(".noteslist div.delete").click(function() {
							var answer = confirm("Are you sure you want to delete this note?");
							if(answer) {
				
								var id = $(this).attr("id").replace("delete_","");
								deleteNote(id);
							}
						});
					}
				});
				return false;
			});
			
			
			// mfg note add goes here...
			$("#mfgNoteAdd").submit(function() {
				var formData = $(this).serialize();
				$.ajax({
					url: "/_includes/_code/add_manufacturer_note.php",
					type: "post",
					data: formData,
					success: function(html) {
						
						// get the last note value...
						var lastNote = $("#mfgFtrNote").html();
						
						// move the last note into the old notes area...
						$("#mfgPstNotes").prepend(lastNote);
						$("#mfgFtrNote").html(html);
						
						if($("#mfgPstNotes").hasClass("hide")) {
							$("#mfgNoteToggle").html("Show all Notes");
						} else {
							$("#mfgNoteToggle").html("Hide Notes");
						}
						
						// we need to flash the new note...
						$( "#mfgFtrNote" ).effect("highlight",{},5000);
						
						// we need to clear the form field...
						$("#mfgNoteText").val("");
						
						// unbind the original click listener, and reset so the new stuff is there as well...
						$(".noteslist div.delete").unbind("click");
						$(".noteslist div.delete").click(function() {
							var answer = confirm("Are you sure you want to delete this note?");
							if(answer) {
				
								var id = $(this).attr("id").replace("delete_","");
								deleteNote(id);
							}
						});
					}
				});
				return false;
			});
			
			// cst note add goes here...
			$("#cmpNoteAdd").submit(function() {
				var formData = $(this).serialize();
				$.ajax({
					url: "/_includes/_code/add_competitor_note.php",
					type: "post",
					data: formData,
					success: function(html) {
						
						// get the last note value...
						var lastNote = $("#cmpFtrNote").html();
						
						// move the last note into the old notes area...
						$("#cmpPstNotes").prepend(lastNote);
						$("#cmpFtrNote").html(html);
						
						if($("#cmpPstNotes").hasClass("hide")) {
							$("#cmpNoteToggle").html("Show all Notes");
						} else {
							$("#cmpNoteToggle").html("Hide Notes");
						}
						
						// we need to flash the new note...
						$( "#cmpFtrNote" ).effect("highlight",{},5000);
						
						// we need to clear the form field...
						$("#cmpNoteText").val("");
						
						// unbind the original click listener, and reset so the new stuff is there as well...
						$(".noteslist div.delete").unbind("click");
						$(".noteslist div.delete").click(function() {
							var answer = confirm("Are you sure you want to delete this note?");
							if(answer) {
				
								var id = $(this).attr("id").replace("delete_","");
								deleteNote(id);
							}
						});
					}
				});
				return false;
			});
			
			$("div.default_holder").mouseover(function() {
			$(this).addClass("default_hover");
			}).mouseout(function() {
			$(this).removeClass("default_hover");
			});
			
			// qtips...
			$("a[rel]").each(function(){
				var mdata = $(this).metadata();
				$(this).qtip({
					content: {url: mdata.url,title: {text: $(this).attr('title')},data: {id: $(this).attr('rel')},method: 'post'},
					position: {corner: {target: 'leftMiddle',tooltip: 'rightMiddle'},adjust: {screen: true}},
					show: {when: 'click',solo: true},
					hide: 'unfocus',
					style: {tip:true, border:{width:0, radius:4}, name:'dark', width:640, height:300}
				})
			});
			
			
			// excel download...
			$("div.excelxlsOLD").click(function() {
				var mdata = $(this).metadata();
				$.download('/_includes/_code/_exportXLS.php','id='+mdata.id+'&type='+mdata.type+'&owner_id='+mdata.owner_id
				+'&admin_id='+mdata.admin_id+'&customer_id='+mdata.customer_id+'&manufacturer_id='+mdata.manufacturer_id
				+'&project_id='+mdata.project_id+'&rfqs='+mdata.rfqs+'&samples='+mdata.samples+'&contact_id='+mdata.contact_id
				+'&status='+mdata.status+'&due='+mdata.due,'post');
			}).mouseover(function() {
				$(this).addClass("excelxls_over");
			}).mouseout(function() {
				$(this).removeClass("excelxls_over");
			});
			
			
			// View My Searches...
			$("div.mySearchTab").click(function() {
				var mdata = $(this).metadata();
				$("div#snv_window").load("/index.php", {is_ajax: true, itmid: mdata.itmid, owner_id: mdata.owner_id, 
				admin_id: mdata.admin_id, due: mdata.due, customer_id: mdata.customer_id, project_id: mdata.project_id, contact_id: mdata.contact_id, 
				manufacturer_id: mdata.manufacturer_id, status: mdata.status, rfqs: mdata.rfqs, 
				samples: mdata.samples});
			}).mouseover(function() {
				$(this).addClass("mySearchTab_over");
			}).mouseout(function() {
				$(this).removeClass("mySearchTab_over");
			});
			
			// Remove My Searches...
			$("div#mysearch_remove").click(function() {
				var mdata = $(this).metadata();
				$("<div id='adialog'>Loading...</div>").load(mdata.url, {
					itmid: mdata.itmid,
					owner_id: mdata.owner_id,
					admin_id: mdata.admin_id,
					due: mdata.due,
					customer_id: mdata.customer_id,
					project_id: mdata.project_id,
					contact_id: mdata.contact_id,
					manufacturer_id: mdata.manufacturer_id,
					status: mdata.status,
					rfqs: mdata.rfqs,
					samples: mdata.samples,
					_fid: mdata._fid
				}).dialog({
						bgiframe: true,
						modal: true,
						height: 220,
						width: 300,
						position: ['center','center'],
						title: mdata.title,
						buttons: {
							"Delete": function() {
								$("form#"+mdata._fid).ajaxSubmit({
									target: "#adialog",
									success: function(msg) {
										$("#" + mdata.itmid).remove();
										$("#mysearch_remove").hide();
										$(this).dialog("close");
									}
								});
							},
							"Cancel": function() {
								$(this).dialog("close");
							}
						},
						beforeclose: function() {
							$("form#"+mdata._fid).resetForm();
						},
						close: function() {
							$(this).dialog("destroy").remove();
						}
					});		
					return('adding...');
			}).mouseover(function() {
				$(this).addClass("mysearch_remove_over");
			}).mouseout(function() {
				$(this).removeClass("mysearch_remove_over");
			});
			
			// Excel Download (Updated)
			$("div.excelxls").click(function() {
				var mdata = $(this).metadata();
				$("<div id='adialog'>Loading...</div>").load("/_includes/_code/prepareXLSExport.php", {
						id: mdata.id,
						type: mdata.type,
						owner_id: mdata.owner_id,
						admin_id: mdata.admin_id,
						customer_id: mdata.customer_id,
						manufacturer_id: mdata.manufacturer_id,
						project_id: mdata.project_id,
						rfqs: mdata.rfqs,
						samples: mdata.samples,
						contact_id: mdata.contact_id,
						status: mdata.status,
						due: mdata.due
					}).dialog({
						bgiframe: true,
						modal: true,
						height: 280,
						width: 600,
						position: ['center','center'],
						title: "Select fields to include in excel export",
						buttons: {
							"Export File": function() {
							
								// display variables...
								var s_mfg = "0";
								var s_mstat = "0";
								var s_stat = "0";
								var s_mfgPN = "0";
								var s_pckg = "0";
								var s_moq = "0";
								var s_mfgAssign = "0";
								var s_mfgDeadline = "0";
								var s_samples = "0";
								var s_rfqStatus = "0";
								var s_partID = "0";
								var s_owner = "0";
								var s_assigned = "0";
								var s_customer = "0";
								var s_customerPN = "0";
								var s_deadline = "0";
								var s_tprice = "0";
								var s_contact = "0";
								var s_project = "0";
								var s_eau = "0";
								var s_pp = "0";
								
								if($("input#s_mfg").is(":checked")) {
									s_mfg = $("input#s_mfg").val();
								}
								if($("input#s_mstat").is(":checked")) {
									s_mstat = $("input#s_mstat").val();
								}
								if($("input#s_sstat").is(":checked")) {
									s_stat = $("input#s_sstat").val();
								}
								if($("input#s_mfgPN").is(":checked")) {
									s_mfgPN = $("input#s_mfgPN").val();
								}
								if($("input#s_pckg").is(":checked")) {
									s_pckg = $("input#s_pckg").val();
								}
								if($("input#s_moq").is(":checked")) {
									s_moq = $("input#s_moq").val();
								}
								if($("input#s_mfgAssign").is(":checked")) {
									s_mfgAssign = $("input#s_mfgAssign").val();
								}
								if($("input#s_mfgDeadline").is(":checked")) {
									s_mfgDeadline = $("input#s_mfgDeadline").val();
								}
								if($("input#s_samples").is(":checked")) {
									s_samples = $("input#s_samples").val();
								}
								if($("input#s_rfqStatus").is(":checked")) {
									s_rfqStatus = $("input#s_rfqStatus").val();
								}
								if($("input#s_partID").is(":checked")) {
									s_partID = $("input#s_partID").val();
								}
								if($("input#s_owner").is(":checked")) {
									s_owner = $("input#s_owner").val();
								}
								if($("input#s_assigned").is(":checked")) {
									s_assigned = $("input#s_assigned").val();
								}
								if($("input#s_customer").is(":checked")) {
									s_customer = $("input#s_customer").val();
								}
								if($("input#s_customerPN").is(":checked")) {
									s_customerPN = $("input#s_customerPN").val();
								}
								if($("input#s_deadline").is(":checked")) {
									s_deadline = $("input#s_deadline").val();
								}
								if($("input#s_tprice").is(":checked")) {
									s_tprice = $("input#s_tprice").val();
								}
								if($("input#s_contact").is(":checked")) {
									s_contact = $("input#s_contact").val();
								}
								if($("input#s_project").is(":checked")) {
									s_project = $("input#s_project").val();
								}
								if($("input#s_eau").is(":checked")) {
									s_eau = $("input#s_eau").val();
								}
								if($("input#s_pp").is(":checked")) {
									s_pp = $("input#s_pp").val();
								}
								// let's get the values of the checkboxes...
								
								
								// we'll need to add the additional fields to this call below
								// but let's see if we can get it to work.
								$.download('/_includes/_code/_exportXLS.php','id='+mdata.id+'&type='+mdata.type+'&owner_id='+mdata.owner_id
									+'&admin_id='+mdata.admin_id+'&customer_id='+mdata.customer_id+'&manufacturer_id='+mdata.manufacturer_id
									+'&project_id='+mdata.project_id+'&rfqs='+mdata.rfqs+'&samples='+mdata.samples+'&contact_id='+mdata.contact_id
									+'&status='+mdata.status+'&due='+mdata.due
									+'&s_mfg='+s_mfg+'&s_mstat='+s_mstat+'&s_stat='+s_stat+'&s_mfgPN='+s_mfgPN+'&s_pckg='+s_pckg+'&s_moq='+s_moq+'&s_mfgAssign='+s_mfgAssign
									+'&s_mfgDeadline='+s_mfgDeadline+'&s_samples='+s_samples+'&s_rfqStatus='+s_rfqStatus+'&s_partID='+s_partID+'&s_owner='+s_owner
									+'&s_assigned='+s_assigned+'&s_customer='+s_customer+'&s_customerPN='+s_customerPN+'&s_deadline='+s_deadline+'&s_tprice='+s_tprice
									+'&s_contact='+s_contact+'&s_project='+s_project+'&s_eau='+s_eau+'&s_pp='+s_pp,'post');
				
									$(this).dialog("close");
							
							},
							"Cancel": function() {
								$(this).dialog("close");
							}
						},
						beforeclose: function() {
							// we'll need to reset some type of form here...
							//$("form#"+mdata._fid).resetForm();
						},
						close: function() {
							$(this).dialog("destroy").remove();
						}
					});		
					return('adding...');
			}).mouseover(function() {
				$(this).addClass("excelxls_over");
			}).mouseout(function() {
				$(this).removeClass("excelxls_over");
			});
			
			
			// Add My Searches...
			$("div#mysearch_add").click(function() {
				var mdata = $(this).metadata();
				$("<div id='adialog'>Loading...</div>").load(mdata.url, {
						owner_id: mdata.owner_id,
						admin_id: mdata.admin_id,
						due: mdata.due,
						customer_id: mdata.customer_id,
						project_id: mdata.project_id,
						contact_id: mdata.contact_id,
						manufacturer_id: mdata.manufacturer_id,
						status: mdata.status,
						rfqs: mdata.rfqs,
						samples: mdata.samples,
						_fid: mdata._fid
					}).dialog({
						bgiframe: true,
						modal: true,
						height: mdata.dh,
						width: mdata.dw,
						position: ['center','center'],
						title: mdata.title,
						buttons: {
							"Add to My Searches": function() {
								//alert('working');
								$("form#"+mdata._fid).ajaxSubmit({
									target: "#adialog",
									success: function(msg) {
										$("div#snv_window").load("/index.php", {is_ajax: true, owner_id: mdata.owner_id, 
				admin_id: mdata.admin_id, due: mdata.due, customer_id: mdata.customer_id, 
				manufacturer_id: mdata.manufacturer_id, status: mdata.status, rfqs: mdata.rfqs, 
				samples: mdata.samples, _fid:mdata._fid});
				
									//	$("div#" + mdata._parent).load("/index.php", {is_ajax: true, id: mdata.part_id, display: 'detail'});
										$(this).dialog("close");
									}
								});
							},
							"Cancel": function() {
								$(this).dialog("close");
							}
						},
						beforeclose: function() {
							$("form#"+mdata._fid).resetForm();
						},
						close: function() {
							$(this).dialog("destroy").remove();
						}
					});		
					return('adding...');
			}).mouseover(function() {
				$(this).addClass("mysearch_add_over");
			}).mouseout(function() {
				$(this).removeClass("mysearch_add_over");
			});
			
			
			
			
			
				
			
			$("div.remove").click(function() {
				var mdata = $(this).metadata();
				$("<div id='adialog'>Loading...</div>").load(mdata.url, {
						part_id: mdata.part_id,
						_part_id: mdata._part_id,
						_id: mdata._id,
						_fid: mdata._fid
					}).dialog({
						bgiframe: true,
						modal: true,
						height: mdata.dh,
						width: mdata.dw,
						position: ['center','center'],
						title: mdata.title,
						buttons: {
							"Delete": function() {
								//alert('working');
								$("form#"+mdata._fid).ajaxSubmit({
									target: "#adialog",
									success: function(msg) {
										$("div#" + mdata._parent).load("/index.php", {is_ajax: true, id: mdata.part_id, display: 'detail'});
										$(this).dialog("close");
									}
								});
							},
							"Cancel": function() {
								$(this).dialog("close");
							}
						},
						beforeclose: function() {
							$("form#"+mdata._fid).resetForm();
						},
						close: function() {
							$(this).dialog("destroy").remove();
						}
					});		
					return('adding...');
			}).mouseover(function() {
				$(this).addClass("remove_hover");
			}).mouseout(function() {
				$(this).removeClass("remove_hover");
			});
			
			$("div.close_manufacturer_part").click(function() {
				var mdata = $(this).metadata();
				$("<div id='adialog'>Loading...</div>").load(mdata.url, {
						part_id: mdata.part_id,
						manufacturer_part_id: mdata.manufacturer_part_id,
						manufacturer_id: mdata.manufacturer_id,
						_fid: mdata._fid
					}).dialog({
						bgiframe: true,
						modal: true,
						height: mdata.dh,
						width: mdata.dw,
						position: ['center','center'],
						title: mdata.title,
						buttons: {
							"Close Part": function() {
								//alert('working');
								$("form#"+mdata._fid).ajaxSubmit({
									target: "#adialog",
									success: function(msg) {
										$("div#" + mdata._parent).load("/index.php", {is_ajax: true, id: mdata.part_id, display: 'detail'});
										$(this).dialog("close");
									}
								});
							},
							"Cancel": function() {
								$(this).dialog("close");
							}
						},
						beforeclose: function() {
							$("form#"+mdata._fid).resetForm();
						},
						close: function() {
							$(this).dialog("destroy").remove();
						}
					});		
					return('adding...');
			}).mouseover(function() {
				$(this).addClass("button_over");
			}).mouseout(function() {
				$(this).removeClass("button_over");
			});
			
		});
		// END COMPONENT WRAP...


		$(".dialog_body").livequery(function() {
			// datepicker
			// this needs to be updated to use the metadata plugin, to pass the value of the altField dynamically...
			$("input.datepick").datepicker({ altField: '#date', altFormat: 'yy-mm-dd', gotoCurrent: true});
			$("input.datepick_send").datepicker({ altField: '#shipdate', altFormat: 'yy-mm-dd', gotoCurrent: true});
			$("input.datepick_confirm").datepicker({ altField: '#confirmdate', altFormat: 'yy-mm-dd', gotoCurrent: true});
			$("input.datepick_receive").datepicker({ altField: '#receivedate', altFormat: 'yy-mm-dd', gotoCurrent: true});
			$("input.datepick_deliver").datepicker({ altField: '#deliverdate', altFormat: 'yy-mm-dd', gotoCurrent: true});
			
			// fckeditor
			//$("textarea.fckbasic").fck({toolbar:'Basic',height: 120});
			// qtips...
			$("a[rel]").each(function(){
				var mdata = $(this).metadata();
				$(this).qtip({
					content: {url: mdata.url,title: {text: $(this).attr('title')},data: {id: $(this).attr('rel')},method: 'post'},
					position: {corner: {target: 'leftMiddle',tooltip: 'rightTop'},adjust: {screen: true}},
					show: {when: 'click',solo: true},
					hide: 'unfocus',
					style: {tip: true,border: {width: 0,radius: 4},name: 'dark',width: 500}
				})
			});
			
			$("#pricing_sub_components").click(function() {
				$("#pricing_sub_components_form").slideDown('fast');
			}).mouseover(function() {
				$(this).addClass("remove_user_hover");
			}).mouseout(function() {
				$(this).removeClass("remove_user_hover");
			});
			
			$("#add_sub_components").click(function() {
				$.ajax({
				type: 'post',
				url: '/_includes/_code/add_sub_component.php',
				success: function(html){
				$("table#sub_components_table").append(html);
				}
				})
			}).mouseover(function() {
				$(this).addClass("remove_user_hover");
			}).mouseout(function() {
				$(this).removeClass("remove_user_hover");
			});
			
			
			$("div#edit_rfq").click(function() {
				var rfqdata = $(this).metadata();
				$("#rfq_form").slideDown('slow');
				$("#rfq_preview").slideUp('slow');
				$("#rfqdialog").dialog("option","buttons", {
					"Preview RFQ": function() {
						$("form#"+rfqdata._fid).ajaxSubmit({
							target: "#rfqdialog",
							beforeSubmit: function() {
								var v = $("form#"+rfqdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
								$("#rfqdialog").scrollTop(0);
								$(this).dialog("option","title","Review Manufacturer RFQ");
								$(this).dialog("option","buttons", {
									"Email RFQ": function() {
										$("input#action").val("add");
										$("#rfq_form").css('visibility','visible');
										$("#rfq_preview").slideUp('fast');
										$("form#"+rfqdata._fid).ajaxSubmit({
											target: "#rfqdialog",
											success: function() {
												$("div#snv_window").load("/index.php", {is_ajax: true, id: rfqdata.id, display: 'detail'});
												$(this).dialog("close");
											}
										});
									}
								});
							}
						});
					}
				});
			}).mouseover(function() {
				$(this).addClass("button_over");
			}).mouseout(function() {
				$(this).removeClass("button_over");
			});
			
			
			
			$("div#accept_rfq").click(function() {
				var rfqdata = $(this).metadata();	
				$.ajax({
					url: "/_includes/_code/closeRFQ.php",
					type: "post",
					data: "rfq_id=" + rfqdata.rfq_id + "&status=accepted",	// add debug call here...
					success: function () {
						$("div#snv_window").load("/index.php", {is_ajax: true, id: rfqdata.id, display: 'detail'});
						$("#rfqdialog").dialog("close");
					}
				});
			}).mouseover(function() {
				$(this).addClass("button_over");
			}).mouseout(function() {
				$(this).removeClass("button_over");
			});
			
			$("div#kill_rfq").click(function() {
				var rfqdata = $(this).metadata();	
				$.ajax({
					url: "/_includes/_code/closeRFQ.php",
					type: "post",
					data: "rfq_id=" + rfqdata.rfq_id + "&status=closed",	// add debug call here...
					success: function () {
						$("div#snv_window").load("/index.php", {is_ajax: true, id: rfqdata.id, display: 'detail'});
						$("#rfqdialog").dialog("close");
					}
				});
			}).mouseover(function() {
				$(this).addClass("button_over");
			}).mouseout(function() {
				$(this).removeClass("button_over");
			});
			
			
			$("div#edit_quote").click(function() {
				var mdata = $(this).metadata();
				$("#quote_form").css('visibility','visible');
				$("#quote_preview").slideUp('slow');
				$("#quotedialog").dialog("option","buttons", {
					"Preview Customer Quote": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#quotedialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
								$("#quotedialog").scrollTop(0);
								$(this).dialog("option","title","Review Customer Quote");
								$(this).dialog("option","buttons", {
									"Email Customer Quote": function() {
										$("input#action").val("save");
										$("#quote_form").css('visibility','visible');
										$("#quote_preview").slideUp('fast');
										$("form#"+mdata._fid).ajaxSubmit({
											target: "#quotedialog",
											success: function() {
												$("div#snv_window").load("/index.php", {is_ajax: true, id: mdata.id, display: 'detail'});
												//$(this).dialog("close");
											}
										});
									}
								});
							}
						});
					}
				});
			}).mouseover(function() {
				$(this).addClass("button_over");
			}).mouseout(function() {
				$(this).removeClass("button_over");
			});
			
			
			$("div#create_quote").click(function() {
				var mdata = $(this).metadata();
				
				
				// we need to load the appropriate page here...
				$("div#quotedialog").load(mdata.url, {
					id: mdata.id,
					customer_id: mdata.customer_id,
					customer_part_id: mdata.customer_part_id,
					customer_pn: mdata.customer_pn,
					eau: mdata.eau,
					target_price: mdata.target_price,
					manufacturer_id: mdata.manufacturer_id,
					manufacturer_part_id: mdata.manufacturer_part_id,
					title: mdata.title,
					_fid: mdata._fid,
					_parent: mdata._parent,
					quote_id: mdata.quote_id,
					revision: mdata.revision,
					action: mdata.action
				});
				
				$("#quotedialog").dialog("option","width", 660);
				$("#quotedialog").dialog("option","height", 500);
				$("#quotedialog").dialog("option","position", ['center','center']);
				$("#quotedialog").dialog("option","position", ['center','center']);
				$("#quotedialog").dialog("option","title", "Create Customer Quote");
				
				$("#quotedialog").dialog("option","buttons", {
					"Preview Customer Quote": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#quotedialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
								$("#quotedialog").scrollTop(0);
								$(this).dialog("option","title","Review Customer Quote");
								$(this).dialog("option","buttons", {
									"Email Customer Quote": function() {
										$("input#action").val("save");
										$("form#"+mdata._fid).ajaxSubmit({
											target: "#quotedialog",
											success: function() {
												$("div#snv_window").load("/index.php", {is_ajax: true, id: mdata.id, display: 'detail'});
												$(this).dialog("close");
											}
										});
									}
								});
							}
						});
					}
				});
			}).mouseover(function() {
				$(this).addClass("button_over");
			}).mouseout(function() {
				$(this).removeClass("button_over");
			});
			

			$("div#edit_pricing").click(function() {
				var mdata = $(this).metadata();
				$("#pricing_form").css('visibility','visible');
				$("#pricing_preview").slideUp('slow');
				$("#pricingdialog").dialog("option","buttons", {
					"Preview Pricing": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#pricingdialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
								$("#pricingdialog").scrollTop(0);
								$(this).dialog("option","title","Review Pricing");
								$(this).dialog("option","buttons", {
									"Set Pricing": function() {
										//$("input#action").val("add");
										$("#pricing_form").css('visibility','visible');
										$("#pricing_preview").slideUp('fast');
										$("form#priceform").ajaxSubmit({
											target: "#pricingdialog",
											success: function() {
												$("div#snv_window").load("/index.php", {is_ajax: true, id: mdata.id, display: 'detail'});
												$(this).dialog("close");
											}
										});
									}
								});
							}
						});
					}
				});
			}).mouseover(function() {
				$(this).addClass("button_over");
			}).mouseout(function() {
				$(this).removeClass("button_over");
			});
			
			
			$("div.remove_user").click(function() {
				var mdata = $(this).metadata();
				$("<div id='adialog'>Loading...</div>").load(mdata.url, {
					id: mdata.id,
					name: mdata.name,
					email: mdata.email,
					_fid: mdata._fid
				}).dialog({
						bgiframe: true,
						modal: true,
						height: mdata.dh,
						width: mdata.dw,
						position: ['center','center'],
						title: mdata.title,
						buttons: {
							"Delete": function() {
								//alert('working');
								$("form#"+mdata._fid).ajaxSubmit({
									target: "#adialog",
									success: function(msg) {
										$("#" + mdata.id).remove();	// remove item fom DOM...
										$(this).dialog("close");
									}
								});
							},
							"Cancel": function() {
								$(this).dialog("close");
							}
						},
						beforeclose: function() {
							$("form#"+mdata._fid).resetForm();
						},
						close: function() {
							$(this).dialog("destroy").remove();
						}
					});		
					return('adding...');
			}).mouseover(function() {
				$(this).addClass("remove_user_hover");
			}).mouseout(function() {
				$(this).removeClass("remove_user_hover");
			});
			
			
			// this button needs to load the price calculator...
			// since we already have most of the stuff in place, I wonder if we can just pull
			// the appropriate code over to complete the form...
			
			$("div#priceCalc").click(function() {
				//alert('calculator button');
				// we need to do the exact same set-up as the current pricing button
				// just determine the values from the current form, before we send it off...
				// it would be better to move that functionality into a function
				// and call from both places...
				
				// start here!
				var unit1 = $("form#set_status input:text[name=units[0]]").val();
				var unit2 = $("form#set_status input:text[name=units[1]]").val();
				var unit3 = $("form#set_status input:text[name=units[2]]").val();
				var cost1 = $("form#set_status input:text[name=cost[0]]").val();
				var cost2 = $("form#set_status input:text[name=cost[1]]").val();
				var cost3 = $("form#set_status input:text[name=cost[2]]").val();
				
				var partId = $("form#set_status input:hidden[name=id]").val();
				var customerId = $("form#set_status input:hidden[name=customer_id]").val();
				var customerPartId = $("form#set_status input:hidden[name=customer_part_id]").val();
				var customerPN = $("form#set_status input:hidden[name=customer_pn]").val();
				var eau = $("form#set_status input:hidden[name=eau]").val();
				var targetPrice = $("form#set_status input:hidden[name=target_price]").val();
				var manufacturerId = $("form#set_status input:hidden[name=manufacturer_id]").val();
				var manufacturerPartId = $("form#set_status input:hidden[name=manufacturer_part_id]").val();
				var fid = $("form#set_status input:hidden[name=_fid]").val();
				
			
				if(unit1 && cost1) {
					// we need to do a couple of things here...
					// 
					// 1) we need to create the manufacturer quote...
					// 
					// 2) we need to load the pricing calculator into this window...
					
					// 3) we need to redo the button options for the dialog...
					//		THIS IS THE FUNCTION...
					$.ajax({
						url: "/_includes/_components/set_pricing.php",
						type: "POST",
						data: "id="+partId+"&customer_id="+customerId+"&customer_part_id="+customerPartId+"&customer_pn="+customerPN+"&eau="+eau+"&target_price="+targetPrice+"&manufacturer_id="+manufacturerId+"&manufacturer_part_id="+manufacturerPartId+"&title=Price_Calculator&_fid="+fid+"&action=setCosts&u1="+unit1+"&u2="+unit2+"&u3="+unit3+"&c1="+cost1+"&c2="+cost2+"&c3="+cost3,
						success: function (html) {
							$("#pricingdialog").html(html);
							
							// now, we need to redo the options for the pricing dialog...
							$("#pricingdialog").dialog("option","title","Review Part Pricing");
							$("#pricingdialog").dialog("option","buttons", {
								"Preview Pricing": function() {
									$("form#"+fid).ajaxSubmit({
										target: "#pricingdialog",
										beforeSubmit: function() {
											var v = $("form#"+fid).validate({
												meta: "validate",
												errorPlacement: function(error, element) {
													error.appendTo(element.next());
												}
											}).form();
											if(v) { return true; } else { return false; }
										},
										success: function() {
											$("#pricingdialog").scrollTop(0);
											$(this).dialog("option","title","Review Part Pricing");
											$(this).dialog("option","buttons", {
												"Set Pricing": function() {
													$("form#priceform").ajaxSubmit({
														target: "#pricingdialog",
														beforeSubmit: function() {
															//$("#pricing_form").css('visibility','visible');
															$("#pricing_preview").slideUp('slow');
														},
														success: function() {
															$("div#snv_window").load("/index.php", {is_ajax: true, id: partId, display: 'detail'});
															$(this).dialog("close");
														}
													});
												}
											});
										}
									});
								}
							});
						}
					});
				} else {
					alert('Please enter the first row of manufacturer pricing data');
				}
			}).mouseover(function() {
				$(this).addClass("button_over");
			}).mouseout(function() {
				$(this).removeClass("button_over");
			});
			
			// rep button...
			$("div#priceRep").click(function() {
				$("#priceRepOption").removeClass("hide");
				$(this).addClass("disabled");
			}).mouseover(function() {
				$(this).addClass("button_over");
			}).mouseout(function() {
				$(this).removeClass("button_over");
			});
			
			// rep price button...
			$("div#setRepPrice").click(function() {
				// let's grab the values here, and output accordingly...
				var unit1 = $("form#set_status input:text[name=units[0]]").val();
				var unit2 = $("form#set_status input:text[name=units[1]]").val();
				var unit3 = $("form#set_status input:text[name=units[2]]").val();
				var cost1 = $("form#set_status input:text[name=cost[0]]").val();
				var cost2 = $("form#set_status input:text[name=cost[1]]").val();
				var cost3 = $("form#set_status input:text[name=cost[2]]").val();
				var partId = $("form#set_status input:hidden[name=id]").val();
				var mfgPartId = $("form#set_status input:hidden[name=manufacturer_part_id]").val();
				var mfgId = $("form#set_status input:hidden[name=manufacturer_id]").val();
				var cstPartId = $("form#set_status input:hidden[name=customer_part_id]").val();
				var repMarkUp = $("#repMarkUp").val();
				var ajaxMethod = "";
				if(unit1 && cost1 && partId && mfgPartId && cstPartId) {
					$.ajax({
						url: "/_includes/_components/set_status.php",
						type: "POST",
						data: "action=setPricing&partId="+partId+"&mfgPartId="+mfgPartId+"&cstPartId="+cstPartId+"&mfgId="+mfgId+"&unit1="+unit1+"&cost1="+cost1+"&unit2="+unit2+"&cost2="+cost2+"&unit3="+unit3+"&cost3="+cost3+"&repMarkUp="+repMarkUp,
						success: function (msg) {
							$("div#snv_window").load("/index.php", {is_ajax: true, id: partId, display: 'detail'});
							$("#pricingdialog").dialog("close");
						}
					});
				}
			}).mouseover(function() {
				$(this).addClass("button_over");
			}).mouseout(function() {
				$(this).removeClass("button_over");
			});

		});
		
		
		$("div.set_pricing").livequery("click", function() {
			var mdata = $(this).metadata();
			$("<div id='pricingdialog'>Loading...</div>").load(mdata.url, {
				is_ajax: true,					// set by default...
		//		_source: mdata._source,
		//		_parent: mdata._parent,
				_fid: mdata._fid,
				manufacturer_id: mdata.manufacturer_id,		// this will have to be passed... should be 'id'
				manufacturer_part_id: mdata.manufacturer_part_id,
				id: mdata.id,				// this will have to be passed... should be 'itmid'
				title: mdata.title,
				customer_id: mdata.customer_id,
				customer_part_id: mdata.customer_part_id,
				customer_pn: mdata.customer_pn,
				eau: mdata.eau,
				target_price: mdata.target_price,
				action: mdata.action
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 600,
				width: 680,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Preview Pricing": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#pricingdialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
								$("#pricingdialog").scrollTop(0);
								$(this).dialog("option","title","Review Part Pricing");
								$(this).dialog("option","buttons", {
									"Set Pricing": function() {
										$("form#priceform").ajaxSubmit({
											target: "#pricingdialog",
											beforeSubmit: function() {
												//$("#pricing_form").css('visibility','visible');
												$("#pricing_preview").slideUp('slow');
											},
											success: function() {
													$("div#snv_window").load("/index.php", {is_ajax: true, id: mdata.id, display: 'detail'});
												$(this).dialog("close");
											}
										});
									}
								});
							}
						});
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		$("div.remove_quote_quantity").livequery("click", function() {
				var mdata = $(this).metadata();
				//alert('id: ' + mdata.id);
				$("<div id='dialog_confirm'>Loading...</div>").load(mdata.url, {
					id: mdata.id,
					quantity: mdata.quantity,
					_fid: mdata._fid
				}).dialog({
						bgiframe: true,
						modal: true,
						height: mdata.dh,
						width: mdata.dw,
						position: ['center','center'],
						title: mdata.title,
						buttons: {
							"Delete": function() {
								//alert('working');
						//		$("form#"+mdata._fid).ajaxSubmit({
						//			target: "#dialog_confirm",
						//			success: function(msg) {
										$("#" + mdata.id).remove();	// remove item fom DOM... // will it work?
										$(this).dialog("close");
						//			}
						//		});
							},
							"Cancel": function() {
								$(this).dialog("close");
							}
						},
						beforeclose: function() {
							$("form#"+mdata._fid).resetForm();
						},
						close: function() {
							$(this).dialog("destroy").remove();
						}
					});		
					return('adding...');
			}).livequery("mouseover", function() {
				$(this).addClass("remove_user_hover");
			}).livequery("mouseout", function() {
				$(this).removeClass("remove_user_hover");
			});
			
		// add an internal part...
		// we need to modify this, to be a dialog popup.
		// this popup will ask the user to select a customer for the part.
		// the user will also have the option to 'create' a new customer via the part...
		/*
			$('#add_internal_part').livequery("click", function() {
			$.ajax({
				url: "/_includes/_code/add_internal_part.php",
				type: "post",
				success: function (stuff) {
						$("div#snv_window").load("/index.php", {is_ajax: true, id: stuff, display: 'detail'});
				}
			});
			});
		*/
		// can be in one single page...
		$("#add_internal_part").livequery("click", function() {
			var mdata = $(this).metadata();
			$("<div id='dialog'>Loading...</div>").load(mdata.url, {
				_parent: mdata._parent,
				_fid: mdata._fid,
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 300,
				width: 380,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Create New Part": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#dialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function(rtnhtml) {
								//$("#"+mdata._parent).append(rtnhtml);
									$("div#" + mdata._parent).load("/index.php", {is_ajax: true, id: rtnhtml, display: 'detail'});
								$(this).dialog("close");
							}
							
						});
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		
		
		
		
		
		

		// form submissions...
		$('#formsubmit').livequery("click", function() {
			//alert('working');
			$('form#standard').ajaxSubmit({
				target: "#snv_window",
				beforeSubmit: function() {
					var v = $('form#standard').validate({
						meta: 'validate',
						errorPlacement: function(error, element) {
							error.appendTo(element.next());
						}
					}).form();
					if(v) { return true; } else { return false; }
				},
					success: function() {
				//		alert('success');
					}
			});
		});
			
		$('#competitor_submit').livequery("click", function() {
			//alert('working');
			$('form#competitor').ajaxSubmit({
				target: "#snv_window",
				beforeSubmit: function() {
					var v = $('form#competitor').validate({
						meta: 'validate',
						errorPlacement: function(error, element) {
							error.appendTo(element.next());
						}
					}).form();
					if(v) { return true; } else { return false; }
				},
					success: function() {
				//		alert('success');
					}
			});
		});
			
		$('#customer_submit').livequery("click", function() {
			//alert('working');
			$('form#customer').ajaxSubmit({
				target: "#snv_window",
				beforeSubmit: function() {
					var v = $('form#customer').validate({
						meta: 'validate',
						errorPlacement: function(error, element) {
							error.appendTo(element.next());
						}
					}).form();
					if(v) { return true; } else { return false; }
				},
					success: function() {
				//		alert('success');
					}
			});
		});
	
		$('#formcancel').livequery("click", function() {
			$("#add_manufacturer_form").hide("normal ");
		});
		$('#competitor_cancel').livequery("click", function() {
			$("#add_competitor_form").hide("normal ");
		});
		$('#customer_cancel').livequery("click", function() {
			$("#add_customer_form").hide("normal ");
		});

		// showDetail
		$('.showDetail').livequery("click", function() {
			var mdata = $(this).metadata();
			$("div#snv_window").load("/index.php", {is_ajax: true, id: mdata.id, display: 'detail', fromSearch: true, searchPos: mdata.srchPos});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		// lastSearch
		$('#lastSearch').livequery("click", function() {
			var mdata = $(this).metadata();
			$("div#snv_window").load("/index.php", {is_ajax: true, display: 'list', goBack: true, startPos: mdata.srchPos});
		}).livequery("mouseover", function() {
			$(this).addClass("lastArrow_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("lastArrow_over");
		});
		
		
		
		
		// User Assigned Customer Search
		$('#usr_assigned_cst').livequery("click", function() {
			var mdata = $(this).metadata();
			$("div#snv_window").load("/index.php", {is_ajax: true, id: mdata.id, display: 'list', type: 'usr', stype: 'cst'});
		}).livequery("mouseover", function() {
			$(this).addClass("usr_search_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("usr_search_over");
		});
		
		// User Assigned Manufacturer Search
		$('#usr_assigned_mfg').livequery("click", function() {
			var mdata = $(this).metadata();
			$("div#snv_window").load("/index.php", {is_ajax: true, id: mdata.id, display: 'list', type: 'usr', stype: 'mfg', due: mdata.due});
		}).livequery("mouseover", function() {
			$(this).addClass("usr_search_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("usr_search_over");
		});
		
		// User Owned Part Search
		$('#usr_owned').livequery("click", function() {
			var mdata = $(this).metadata();
			$("div#snv_window").load("/index.php", {is_ajax: true, id: mdata.id, display: 'list', type: 'usr', stype: 'own', due: mdata.due});
		}).livequery("mouseover", function() {
			$(this).addClass("usr_search_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("usr_search_over");
		});
		
		

		// edit in place jquery...
		$(".edit_field").livequery(function() {
			var editdata = $(this).metadata();
			$(this).editable(editdata.url, {
				id: 'field',
				submitdata: {dbid: editdata.dbid},
				style: 'inherit',
				height: 'none',
				width: 'none',
				onblur: 'submit',
				placeholder: '<i>add</i>',
				data: function(value, settings) {
					var retval = value.replace(/\,/g,'');
					return retval;
				}
			});
		});
		
		$(".edit_area").livequery(function() {
			var editdata = $(this).metadata();
			$(this).editable(editdata.url, {
				type: 'textarea',
				id: 'field',
				submitdata: {dbid: editdata.dbid},
				style: 'inherit',
				height: editdata.dh,
				width: editdata.dw,
				onblur: 'submit',
				placeholder: '<i>add</i>',
				data: function(value, settings) {
					var retval = value.replace(/\,/g,'');
					return retval;
				}
			});
		});
		

		$(".edit_field_multi").livequery(function() {
			var mdata = $(this).metadata();
			$(this).editable(mdata.url, {
				id: 'field',
				submitdata: {dbida: mdata.dbida,dbidb: mdata.dbidb},
				style: 'inherit',
				height: 'none',
				width: 'none',
				onblur: 'submit',
				data: function(value, settings) {
					var retval = value.replace(/\,/g,'');
					return retval;
				}
			});
		});
	
	
	// NEWEST HERE...
		$(".edit_text").livequery(function() {
			var mdata = $(this).metadata();
			$(this).editable(mdata.url, {
				id: 'field',
				submitdata: {part_id: mdata.part_id, _part_id: mdata._part_id, _id: mdata._id},
				style: 'inherit',
				height: 'none',
				width: 'none',
				onblur: 'submit'
			});
		});
		
		$(".edit_numbers").livequery(function() {
			var mdata = $(this).metadata();
			$(this).editable(mdata.url, {
				id: 'field',
				submitdata: {part_id: mdata.part_id, _part_id: mdata._part_id, _id: mdata._id},
				style: 'inherit',
				height: 'none',
				width: 'none',
				onblur: 'submit',
				data: function(value, settings) {
					var retval = value.replace(/\,/g,'');
					return retval;
				}
			});
		});

		// edit in place jquery...
		$(".edit_select").livequery(function() {
			var editselectdata = $(this).metadata();
			$(this).editable(editselectdata.url, {
				loadurl: editselectdata.json_url,
				loadtype: 'POST',
				//loaddata: {customer_id: editselectdata.cid, part_id: editselectdata.pid, current: editselectdata.current},
				type: 'select',
				id: 'field',
				submitdata: {dbid: editselectdata.dbid, type: 'select', cpid: editselectdata.cpid, mid: editselectdata.mid},
				style: 'inherit',
				height: 'none',
				submit: 'ok',
				placeholder: '<i>select</i>'
			});
		});
		
		
		// let's do a custom jquery script...
		
		// what needs to happen...
		// 1) we need to
		
		// edit in place jquery...
		$(".edit_select_remove").livequery(function() {
			var editselectdata = $(this).metadata();
			$(this).editable(editselectdata.url, {
				data: {'remove':'Remove','selected':'remove'},
				type: 'select',
				id: 'field',
				submitdata: {dbida: editselectdata.dbida, dbidb: editselectdata.dbidb, action: 'remove', type: 'select'},
				style: 'inherit',
				height: 'none',
				submit: 'ok',
				placeholder: '<i>select</i>',
				callback: function(value, settings) {
						$("div#" + editselectdata._parent).load("/index.php", {is_ajax: true, id: editselectdata.pid, display: 'detail'});
				//	if($(this).attr('id') == 'project_id') {
					//	alert(value);
					//	if(value) {
						//	$("#toggle_twitter").attr({disabled: false})
					//	} else {
						//	$("#toggle_twitter").attr({checked: false});
						//	$("#toggle_twitter").attr({disabled: true})
					//	}
				//	}
				}
			});
		});
	
	
		$(".edit_internal_customers").livequery(function() {
			var mdata = $(this).metadata();
			$(this).editable(function(value, settings) {
				var stuff = this;
				var uid = value;
					$("<div id='adialog'>Loading...</div>").load("/_includes/_code/select_internal_user.php", {
						uid: uid,					// set by default...
						customer_part_id: mdata.customer_part_id,
						customer_id: mdata.customer_id,
						part_id: mdata.part_id,
						current: mdata.current,
						_fid: mdata._fid,
						dbfield: mdata.dbfield
					}).dialog({
						bgiframe: true,
						modal: true,
						height: mdata.dh,
						width: mdata.dw,
						position: ['center','center'],
						title: mdata.title,
						buttons: {
							"Assign User": function() {
								$("form#"+mdata._fid).ajaxSubmit({
									target: "#adialog",
									beforeSubmit: function() {
										var v = $("form#"+mdata._fid).validate({
											meta: "validate",
											errorPlacement: function(error, element) {
												error.appendTo(element.next());
											}
										}).form();
										if(v) { return true; } else { return false; }
									},
									success: function(msg) {
										$(stuff).html(msg);
										$(this).dialog("close");
									}
								});
							},
							"Create New User": function() {
								$("div#adialog").load("/_includes/_code/admin_add_dialog.php", {is_ajax: true, part_id: mdata.part_id, customer_id: mdata.customer_id, customer_part_id: mdata.customer_part_id, current_id: mdata.current, _fid: mdata._fid, dbfield: mdata.dbfield});
								$(this).dialog("option","title","Create A New Summitech User");
								$(this).dialog("option","buttons", {
									"Create User": function() {
										$("form#"+mdata._fid).ajaxSubmit({
											target: "#adialog",
											beforeSubmit: function() {
												var v = $("form#"+mdata._fid).validate({
													meta: "validate",
													errorPlacement: function(error, element) {
														error.appendTo(element.next());
													}
												}).form();
												if(v) { return true; } else { return false; }
											},
											success: function(msg) {
												$(stuff).html(msg);
												$(this).dialog("close");
											}
										});
									}
								});
							}
						},
						beforeclose: function() {
							$("form#"+mdata._fid).resetForm();
						},
						close: function() {
							$(this).dialog("destroy").remove();
						}
					});		
					return('adding...');
			}, {
				loadurl: mdata.json_url,
				loadtype: 'POST',
				loaddata: {customer_id: mdata.customer_id, part_id: mdata.part_id, current: mdata.current},
				type: 'select',
				id: 'field',
				submitdata: {customer_part_id: mdata.customer_part_id, type: 'select'},
				style: 'inherit',
				height: 'none',
				submit: 'ok',
				placeholder: '<i>select</i>'
			});
		});

		

		$("div.manufacturer_assign_admin").livequery("click", function() {
			var mdata = $(this).metadata();
			$("<div id='adialog'>Loading...</div>").load("/_includes/_code/select_manufacturer_user.php", {
				section: mdata.section,
				manufacturer_part_id: mdata.manufacturer_part_id,
				manufacturer_id: mdata.manufacturer_id,
				part_id: mdata.part_id,
				current: mdata.current,
				_fid: mdata._fid,
				dbfield: mdata.dbfield
			}).dialog({
				bgiframe: true,
				modal: true,
				height: mdata.dh,
				width: mdata.dw,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Assign User": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#adialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
									$("div#" + mdata._parent).load("/index.php", {is_ajax: true, id: mdata.part_id, display: 'detail'});
								$(this).dialog("close");
							}
						});
					},
					"Create New User": function() {
						$("div#adialog").load("/_includes/_code/admin_add_dialog.php", {is_ajax: true, part_id: mdata.part_id, manufacturer_id: mdata.manufacturer_id, manufacturer_part_id: mdata.manufacturer_part_id, current_id: mdata.current, _fid: mdata._fid, dbfield: mdata.dbfield, section: mdata.section});
						$(this).dialog("option","title","Create A New Summitech User");
						$(this).dialog("option","buttons", {
							"Create User": function() {
								$("form#"+mdata._fid).ajaxSubmit({
									target: "#adialog",
									beforeSubmit: function() {
										var v = $("form#"+mdata._fid).validate({
											meta: "validate",
											errorPlacement: function(error, element) {
												error.appendTo(element.next());
											}
										}).form();
										if(v) { return true; } else { return false; }
									},
									success: function() {
											$("div#" + mdata._parent).load("/index.php", {is_ajax: true, id: mdata.part_id, display: 'detail'});
										$(this).dialog("close");
									}
								});
							}
						});
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		$("div.customer_assign_admin").livequery("click", function() {
			var mdata = $(this).metadata();
			$("<div id='adialog'>Loading...</div>").load("/_includes/_code/select_customer_user.php", {
				section: mdata.section,
				customer_part_id: mdata.customer_part_id,
				manufacturer_id: mdata.manufacturer_id,
				customer_id: mdata.customer_id,
				part_id: mdata.part_id,
				current: mdata.current,
				_fid: mdata._fid,
				dbfield: mdata.dbfield
			}).dialog({
				bgiframe: true,
				modal: true,
				height: mdata.dh,
				width: mdata.dw,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Assign User": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#adialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
									$("div#" + mdata._parent).load("/index.php", {is_ajax: true, id: mdata.part_id, display: 'detail'});
								$(this).dialog("close");
							}
						});
					},
					"Create New User": function() {
						$("div#adialog").load("/_includes/_code/admin_add_dialog.php", {is_ajax: true, part_id: mdata.part_id, customer_id: mdata.customer_id, customer_part_id: mdata.customer_part_id, current_id: mdata.current, _fid: mdata._fid, dbfield: mdata.dbfield, section: mdata.section});
						$(this).dialog("option","title","Create A New Summitech User");
						$(this).dialog("option","buttons", {
							"Create User": function() {
								$("form#"+mdata._fid).ajaxSubmit({
									target: "#adialog",
									beforeSubmit: function() {
										var v = $("form#"+mdata._fid).validate({
											meta: "validate",
											async: false,
											errorPlacement: function(error, element) {
												error.appendTo(element.next());
											}
										}).form();
										if(v) { return true; } else { return false; }
									},
									success: function() {
											$("div#" + mdata._parent).load("/index.php", {is_ajax: true, id: mdata.part_id, display: 'detail'});
										$(this).dialog("close");
									}
								});
							}
						});
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		
		
		$(".edit_manufacturer_users").livequery(function() {
			var mdata = $(this).metadata();
			$(this).editable(function(value, settings) {
				var stuff = this;
				var uid = value;
					$("<div id='adialog'>Loading...</div>").load("/_includes/_code/select_manufacturer_user.php", {
						uid: uid,					// set by default...
						manufacturer_part_id: mdata.manufacturer_part_id,
						manufacturer_id: mdata.manufacturer_id,
						part_id: mdata.part_id,
						current: mdata.current,
						_fid: mdata._fid,
						dbfield: mdata.dbfield
					}).dialog({
						bgiframe: true,
						modal: true,
						height: mdata.dh,
						width: mdata.dw,
						position: ['center','center'],
						title: mdata.title,
						buttons: {
							"Assign User": function() {
								$("form#"+mdata._fid).ajaxSubmit({
									target: "#adialog",
									beforeSubmit: function() {
										var v = $("form#"+mdata._fid).validate({
											meta: "validate",
											errorPlacement: function(error, element) {
												error.appendTo(element.next());
											}
										}).form();
										if(v) { return true; } else { return false; }
									},
									success: function(msg) {
										$(stuff).html(msg);
										$(this).dialog("close");
									}
								});
							},
							"Create New User": function() {
								$("div#adialog").load("/_includes/_code/admin_add_dialog.php", {is_ajax: true, part_id: mdata.part_id, manufacturer_id: mdata.manufacturer_id, manufacturer_part_id: mdata.manufacturer_part_id, current_id: mdata.current, _fid: mdata._fid, dbfield: mdata.dbfield});
								$(this).dialog("option","title","Create A New Summitech User");
								$(this).dialog("option","buttons", {
									"Create User": function() {
										$("form#"+mdata._fid).ajaxSubmit({
											target: "#adialog",
											beforeSubmit: function() {
												var v = $("form#"+mdata._fid).validate({
													meta: "validate",
													errorPlacement: function(error, element) {
														error.appendTo(element.next());
													}
												}).form();
												if(v) { return true; } else { return false; }
											},
											success: function(msg) {
												$(stuff).html(msg);
												$(this).dialog("close");
											}
										});
									}
								});
							}
						},
						beforeclose: function() {
							$("form#"+mdata._fid).resetForm();
						},
						close: function() {
							$(this).dialog("destroy").remove();
						}
					});		
					return('adding...');
			}, {
				loadurl: mdata.json_url,
				loadtype: 'POST',
				loaddata: {manufacturer_id: mdata.manufacturer_id, part_id: mdata.part_id, current: mdata.current},
				type: 'select',
				id: 'field',
				submitdata: {manufacturer_part_id: mdata.manufacturer_part_id, type: 'select'},
				style: 'inherit',
				height: 'none',
				submit: 'ok',
				placeholder: '<i>select</i>'
			});
		});
		
		
		// add project...
		$(".edit_selectproject").livequery(function() {
			var mdata = $(this).metadata();
			$(this).editable(function(value, settings) {
				var stuff = this;
				if(value=='add') {
					$("<div id='adialog'>Loading...</div>").load(mdata.dlog_url, {
						url: mdata.url,					// set by default...
						_part_id: mdata._part_id,
						mfg_part_id: mdata.mfg_part_id,
						json_url: mdata.json_url,
						customer_id: mdata.customer_id,
						part_id: mdata.part_id,
						_id: mdata._id,
						_fid: mdata._fid,
						title: mdata.title,
						dbfield: mdata.dbfield,
						_parent: mdata._parent,
					}).dialog({
						bgiframe: true,
						modal: true,
						height: mdata.dh,
						width: mdata.dw,
						position: ['center','center'],
						title: mdata.title,
						buttons: {
							"Create": function() {
								$("form#"+mdata._fid).ajaxSubmit({
									target: "#adialog",
									beforeSubmit: function() {
										var v = $("form#"+mdata._fid).validate({
											meta: "validate",
											errorPlacement: function(error, element) {
												error.appendTo(element.next());
											}
										}).form();
										if(v) { return true; } else { return false; }
									},
									success: function(msg) {
											$("div#" + mdata._parent).load("/index.php", {is_ajax: true, id: mdata.part_id, display: 'detail'});
										$(this).dialog("close");
									}
								});
							},
							"Close Window": function() {
							$(this).dialog("close");
							}
						},
						beforeclose: function() {
							$("form#"+mdata._fid).resetForm();
						},
						close: function() {
							$(this).dialog("destroy").remove();
						}
					});		
					return('adding...');
				} else {
					$.ajax({
						url: mdata.url,
						type: "POST",
						data: "type=select&part_id=" + mdata.part_id + "&_part_id=" + mdata._part_id + "&mfg_part_id=" + mdata.mfg_part_id + "&field=" + mdata.dbfield + "&value=" + value + "&_id=" + mdata._id,	// add debug call here...
						success: function (msg) {
								$("div#" + mdata._parent).load("/index.php", {is_ajax: true, id: mdata.part_id, display: 'detail'});
						}
					});
					return('loading...');
				}
			}, {
				loadurl: mdata.json_url,
				loadtype: 'POST',
				loaddata: {part_id: mdata.part_id, _id: mdata._id, current: mdata.current, _part_id: mdata._part_id},
				type: 'select',
				id: 'field',
				submitdata: {part_id: mdata.part_id, _part_id: mdata._part_id, type: 'select'},
				style: 'inherit',
				height: 'none',
				submit: 'ok',
				placeholder: '<i>select</i>'
			});
		});
		
		// USER Search Options
		$("#users_by_scope").livequery(function() {
			$("#users_by_scope").change(function(){
				var selected_option = $("#users_by_scope option:selected");
				$("div#snv_window").load("/index.php", {is_ajax: true, nav: true, scope: selected_option.val(), display: 'users'});
			});
		});
		
		$("#users_by_customer").livequery(function() {
			$("#users_by_customer").change(function(){
				var selected_option = $("#users_by_customer option:selected");
				$("div#snv_window").load("/index.php", {is_ajax: true, nav: true, customer_id: selected_option.val(), display: 'users'});
			});
		});

		$("#users_by_manufacturer").livequery(function() {
			$("#users_by_manufacturer").change(function(){
				var selected_option = $("#users_by_manufacturer option:selected");
				$("div#snv_window").load("/index.php", {is_ajax: true, nav: true, manufacturer_id: selected_option.val(), display: 'users'});
			});
		});

		// parts search filters...
//		$(".filter_option").livequery(function() {
//			$(".filter_option").change(function (){
//				// here, we need to submit the ajax form...
//				// that's it...
//				$("form#filter").ajaxSubmit({
//				target: "#snv_window"
//				});
//			});
//		});
		
		
		// manufacturer select options...
		$("#manufacturer_select_options").livequery(function() {
			var dyndata = $(this).metadata();
			$("#manufacturer_select_options").change(function (){
				var selected_option = $("#manufacturer_select_options option:selected");
				if(selected_option.val() == 'add') {
					$("#add_manufacturer_form").show("normal ");
				} else {
					$("div#snv_window").load("/index.php", {is_ajax: true, nav: true, mid: selected_option.val(), id: dyndata.part_id, display: 'detail', dest: 'manufacturers'});
				}
			});
		});
		
		
		// competitor select options...
		$("#competitor_select_options").livequery(function() {
			var dyndata = $(this).metadata();
			$("#competitor_select_options").change(function (){
				var selected_option = $("#competitor_select_options option:selected");
				if(selected_option.val() == 'add') {
					$("#add_competitor_form").show("normal ");
				} else {
					$("div#snv_window").load("/index.php", {is_ajax: true, nav: true, mid: selected_option.val(), id: dyndata.part_id, display: 'detail', dest: 'competitors'});
				}
			});
		});
		
		
		// customer select options...
		$("#customer_select_options").livequery(function() {
			var dyndata = $(this).metadata();
			$("#customer_select_options").change(function (){
				var selected_option = $("#customer_select_options option:selected");
				if(selected_option.val() == 'add') {
					$("#add_customer_form").show("normal ");
				} else {
					$("div#snv_window").load("/index.php", {is_ajax: true, nav: true, mid: selected_option.val(), id: dyndata.part_id, display: 'detail', dest: 'customers'});
				}
			});
		});
		
		
		$("#rfq_customer_id").livequery(function() {
			$(this).change(function(){
				var rfq_customer_selected = $("#rfq_customer_id option:selected").val();
				//alert(rfq_customer_selected);
				//alert(rfq_customer_selected);
				if(rfq_customer_selected) {
					$("#customer_display_options").slideDown('normal');
					$("div.project_group :checkbox").attr('checked',false);	// uncheck all project groups...
					$("div.project_group").slideUp('normal');	// hide all project_groups
					$("#projects_" + rfq_customer_selected).slideDown('normal');	// show the selected customers project group...
					$("div.spec_group :checkbox").attr('checked',false);	// uncheck all project groups...
					$("div.spec_group").slideUp('normal');	// hide all project_groups
					$("#spec_" + rfq_customer_selected).slideDown('normal');	// show the selected customers project group...
				} else {
					$("div.project_group :checkbox").attr('checked',false);
					$("div.project_group").slideUp('normal');
					$("#customer_display_options").slideUp('normal');
					$("div.spec_group :checkbox").attr('checked',false);	// uncheck all project groups...
					$("div.spec_group").slideUp('normal');	// hide all project_groups
				}
			});
		});

	
		// manufacturer upload...
		$("#manufacturer_spec_upload").livequery(function() {
			var mspec = $(this).metadata();
			$(this).fileUpload({
				'uploader': '/images/uploader.swf',
				'script': '/_includes/_code/file_upload.php',
				'folder': '/specs/manufacturers',
				'cancelImg': '/images/cancel.png',
				'wmode': 'transparent',
				'scriptData': {'id': mspec.id,'manufacturer_id': mspec.manufacturer_id,'manufacturer_part': mspec.manufacturer_part,'_parent': mspec._parent,'_admin': mspec._admin},
				'auto': true,
				'fileExt': '*.jpg;*.gif;*.png;*.doc;*.xls;*.zip;',
				'displayData': 'percentage',
				onError: function (event, queueID, fileObj, errorObj) {
					var msg;
					if (errorObj.status == 404) {
						alert('Could not find upload script. Use a path relative to: '+'".getcwd()."');
						msg = 'Could not find upload script.';
					} else if (errorObj.type === "HTTP") {
						msg = errorObj.type+": "+errorObj.status;
					} else if (errorObj.type ==="File Size") {
						msg = fileObj.name+'<br>'+errorObj.type+' Limit: '+Math.round(errorObj.sizeLimit/1024)+'KB';
					} else {
						msg = errorObj.type+": "+errorObj.text;
					}
				},
				onComplete: function (a, b, c, d, e) {
					$("div#manufacturer_spec_list").load("/_includes/_components/manufacturer_spec_list.php", {mpid: mspec.manufacturer_part});
				}
			});
		});
	
		// competitor upload...
		$("#competitor_spec_upload").livequery(function() {
			var cspec = $(this).metadata();
			$(this).fileUpload({
				'uploader': '/images/uploader.swf',
				'script': '/_includes/_code/file_upload.php',
				'folder': '/specs/competitors',
				'cancelImg': '/images/cancel.png',
				'wmode': 'transparent',
				'scriptData': {'id': cspec.id,'competitor_id': cspec.competitor_id,'competitor_part': cspec.competitor_part,'_parent': cspec._parent,'_admin': cspec._admin},
				'auto': true,
				'fileExt': '*.jpg;*.gif;*.png;*.doc;*.xls;*.zip;',
				'displayData': 'percentage',
				onError: function (event, queueID, fileObj, errorObj) {
					var msg;
					if (errorObj.status == 404) {
						alert('Could not find upload script. Use a path relative to: '+'".getcwd()."');
						msg = 'Could not find upload script.';
					} else if (errorObj.type === "HTTP") {
						msg = errorObj.type+": "+errorObj.status;
					} else if (errorObj.type ==="File Size") {
						msg = fileObj.name+'<br>'+errorObj.type+' Limit: '+Math.round(errorObj.sizeLimit/1024)+'KB';
					} else {
						msg = errorObj.type+": "+errorObj.text;
					}
				},
				onComplete: function (a, b, c, d, e) {
					$("div#competitor_spec_list").load("/_includes/_components/competitor_spec_list.php", {mpid: cspec.competitor_part});
				}
			});
		});
	
		// customer upload...
		$("#customer_spec_upload").livequery(function() {
			var cspec = $(this).metadata();
			$(this).fileUpload({
				'uploader': '/images/uploader.swf',
				'script': '/_includes/_code/file_upload.php',
				'folder': '/specs/customers',
				'cancelImg': '/images/cancel.png',
				'wmode': 'transparent',
				'scriptData': {'id': cspec.id,'customer_id': cspec.customer_id,'customer_part': cspec.customer_part,'_parent': cspec._parent,'_admin': cspec._admin},
				'auto': true,
				'fileExt': '*.jpg;*.gif;*.png;*.doc;*.xls;*.zip;',
				'displayData': 'percentage',
				onError: function (event, queueID, fileObj, errorObj) {
					var msg;
					if (errorObj.status == 404) {
						alert('Could not find upload script. Use a path relative to: '+'".getcwd()."');
						msg = 'Could not find upload script.';
					} else if (errorObj.type === "HTTP") {
						msg = errorObj.type+": "+errorObj.status;
					} else if (errorObj.type ==="File Size") {
						msg = fileObj.name+'<br>'+errorObj.type+' Limit: '+Math.round(errorObj.sizeLimit/1024)+'KB';
					} else {
						msg = errorObj.type+": "+errorObj.text;
					}
				},
				onComplete: function (a, b, c, d, e) {
					$("div#customer_spec_list").load("/_includes/_components/customer_spec_list.php", {mpid: cspec.customer_part});
				}
			});
		});
	
		// customer upload...
		$("#customer_file_upload").livequery(function() {
			var cspec = $(this).metadata();
			$(this).fileUpload({
				'uploader': '/images/uploader.swf',
				'script': '/_includes/_code/file_upload.php',
				'folder': '/files/customers',
				'cancelImg': '/images/cancel.png',
				'wmode': 'transparent',
				'scriptData': {'id': cspec.id,'_parent': cspec._parent,'_admin': cspec._admin,'customerFile': true},
				'auto': true,
				'fileExt': '*.jpg;*.gif;*.png;*.doc;*.xls;*.zip;',
				'displayData': 'percentage',
				onError: function (event, queueID, fileObj, errorObj) {
					var msg;
					if (errorObj.status == 404) {
						alert('Could not find upload script. Use a path relative to: '+'".getcwd()."');
						msg = 'Could not find upload script.';
					} else if (errorObj.type === "HTTP") {
						msg = errorObj.type+": "+errorObj.status;
					} else if (errorObj.type ==="File Size") {
						msg = fileObj.name+'<br>'+errorObj.type+' Limit: '+Math.round(errorObj.sizeLimit/1024)+'KB';
					} else {
						msg = errorObj.type+": "+errorObj.text;
					}
				},
				onComplete: function (a, b, c, d, e) {
					$("div#customer_files_list").load("/_includes/_components/customer_files_list.php", {id: cspec.id});
				}
			});
		});
	

	// manufacturer upload remove...
		$(".configure_manufacturer_spec").livequery("click", function() {
			var mspec = $(this).metadata();
			$("div#manufacturer_spec_list").load("/_includes/_components/manufacturer_spec_list.php", {mpid: mspec.mpid, itmid: mspec.itmid, action: mspec.action});
		}).livequery("mouseover", function() {
			$(this).addClass("remove_itm_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("remove_itm_over");
		});
		
	// competitor upload remove...
		$(".configure_competitor_spec").livequery("click", function() {
			var mspec = $(this).metadata();
			$("div#competitor_spec_list").load("/_includes/_components/competitor_spec_list.php", {mpid: mspec.mpid, itmid: mspec.itmid, action: mspec.action});
		}).livequery("mouseover", function() {
			$(this).addClass("remove_itm_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("remove_itm_over");
		});
		
	// customer upload remove...
		$(".configure_customer_spec").livequery("click", function() {
			var mspec = $(this).metadata();
			$("div#customer_spec_list").load("/_includes/_components/customer_spec_list.php", {mpid: mspec.mpid, itmid: mspec.itmid, action: mspec.action});
		}).livequery("mouseover", function() {
			$(this).addClass("remove_itm_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("remove_itm_over");
		});
		
	// customer file remove...
		$(".configure_customer_file").livequery("click", function() {
			var mspec = $(this).metadata();
			$("div#customer_files_list").load("/_includes/_components/customer_files_list.php", {id: mspec.id, itmid: mspec.itmid, action: mspec.action});
		}).livequery("mouseover", function() {
			$(this).addClass("remove_itm_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("remove_itm_over");
		});
		
	// form button - ???
		
		
		$("div.manufacturer_rfq_num").livequery("click", function() {
			var rfqdata = $(this).metadata();
			$("<div id='rfqdialog'>Loading...</div>").load(rfqdata.url, {
				is_ajax: true,					// set by default...
		//		_source: rfqdata._source,
		//		_parent: rfqdata._parent,
				_fid: rfqdata._fid,
				mid: rfqdata.mid,		// this will have to be passed... should be 'id'
				mpid: rfqdata.mpid,
				id: rfqdata.id,				// this will have to be passed... should be 'itmid'
				title: rfqdata.title,
				rfqid: rfqdata.rfqid,
				action: rfqdata.action
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 600,
				width: 680,
				position: ['center','center'],
				title: rfqdata.title,
				buttons: {
					"Preview RFQ": function() {
						$("form#"+rfqdata._fid).ajaxSubmit({
							target: "#rfqdialog",
							beforeSubmit: function() {
								var v = $("form#"+rfqdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
								$("#rfqdialog").scrollTop(0);
								$(this).dialog("option","title","Review Manufacturer RFQ");
								$(this).dialog("option","buttons", {
									"Email RFQ": function() {
										$("input#action").val("add");
										$("form#"+rfqdata._fid).ajaxSubmit({
											target: "#rfqdialog",
											beforeSubmit: function() {
												$("#rfq_form").css('visibility','visible');
												$("#rfq_preview").slideUp('slow');
											},
											success: function() {
													$("div#snv_window").load("/index.php", {is_ajax: true, id: rfqdata.id, display: 'detail'});
												$(this).dialog("close");
											}
										});
									}
								});
							}
						});
					}
				},
				beforeclose: function() {
					$("form#"+rfqdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		// sample request... 
		$("div.manufacturer_sample_request").livequery("click", function() {
			var mdata = $(this).metadata();
			$("<div id='rfqdialog'>Loading...</div>").load(mdata.url, {
				is_ajax: true,					// set by default...
		//		_source: mdata._source,
				_parent: mdata._parent,
				_fid: mdata._fid,
				mid: mdata.mid,		// this will have to be passed... should be 'id'
				mpid: mdata.mpid,
				cid: mdata.cid,
				cpid: mdata.cpid,
				id: mdata.id,				// this will have to be passed... should be 'itmid'
				title: mdata.title,
				rfqid: mdata.rfqid,
				action: mdata.action
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 600,
				width: 680,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Submit Sample Request": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#rfqdialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
								$(this).dialog("close");
								// update the window behind...
									$("div#" + mdata._parent).load('/index.php', {is_ajax: true, id: mdata.id, display: 'detail'});
							}
						});
					},
					"Samples Order History": function() {
						$("#rfqdialog").scrollTop(0);
						// slide up the form
						$("#samples_request_form_wrapper").slideUp('fast');
						// slide down the sample request history...
						$("#sample_history").slideDown('fast');
						
						
						$(this).dialog("option","title","Manufacturer Parts Samples Request History");
						$(this).dialog("option","buttons", {
						// no buttons on the reload...
						});
					}
					
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
					// we could reload the parent window here...
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		
		$("#hide_samples_request_history").livequery("click", function() {
			var mdata = $(this).metadata();
			$("#sample_history").slideUp('fast');
			$("#samples_request_form_wrapper").slideDown('fast');
			
			$("#rfqdialog").dialog("option","title","Manufacturer Parts Samples Request History");
			$("#rfqdialog").dialog("option","buttons", {
					"Submit Sample Request": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#rfqdialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
								$(this).dialog("close");
								// update the window behind...
									$("div#" + mdata._parent).load('/index.php', {is_ajax: true, id: mdata.id, display: 'detail'});
							}
						});
					},
					"Sample Order History": function() {
						$(this).scrollTop(0);
						// slide up the form
						$("#samples_request_form_wrapper").slideUp('fast');
						// slide down the sample request history...
						$("#sample_history").slideDown('fast');
						
						
						$(this).dialog("option","title","Manufacturer Parts Samples Request History");
						$(this).dialog("option","buttons", {
						// no buttons on the reload...
						});
					}
			});		
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		// add_rfq_quote_quantity
		$("#add_rfq_quote_quantity").livequery("click", function() {
			var mdata = $(this).metadata();
			$(this).remove();
			$("<div id='admindialog'>Loading...</div>").load(mdata.url, {
				_parent: mdata._parent,
				_fid: mdata._fid,
				mid: mdata.mid,		// this will have to be passed... should be 'id'
				id: mdata.id,				// this will have to be passed... should be 'itmid'
				keyid: mdata.keyid
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 300,
				width: 380,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Add Quote Quantity": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#admindialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function(rtnhtml) {
								$("#"+mdata._parent).append(rtnhtml);
								$(this).dialog("close");
							}
							
						});
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		// RESET PASSWORD...
		// this jquery function opens a jquery UI dialog box and populates it with the
		// url that is sent to jquery via the metadata plugin...
		// -----------------------------------------------------------------------
		// This function expects the form on the resulting url to be presented in a specific fashion
		// check the resulting file for details...
		// -----------------------------------------------------------------------
		// the triggering item is immediately removed form the dom
		// the DOM data is replaced with the results returned by the requested URL...
		
		$(".resetpswd").livequery("click", function() {
			var mdata = $(this).metadata();
			$(this).html("processing");
			$("<div id='admindialog'>Loading...</div>").load(mdata.url, {
				_parent: mdata._parent,
				_fid: mdata._fid,
				admid: mdata.admid
			}).dialog({
				bgiframe: true,
				modal: true,
				height: mdata.dh,
				width: mdata.dw,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Reset Password": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#admindialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function(rtnhtml) {
								$("#"+mdata._parent).html(rtnhtml);
								$(this).dialog("close");
							}
						});
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		// delete a user...
		$(".deleteuser").livequery("click", function() {
			var mdata = $(this).metadata();
			$(this).html("processing");
			$("<div id='admindialog'>Loading...</div>").load(mdata.url, {
				_parent: mdata._parent,
				_fid: mdata._fid,
				admid: mdata.admid
			}).dialog({
				bgiframe: true,
				modal: true,
				height: mdata.dh,
				width: mdata.dw,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Yes, Delete": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#admindialog",
							success: function(rtnhtml) {
								$("#"+mdata._parent).html(rtnhtml);
								$(this).dialog("close");
							}
						});
					},
					"Cancel": function() {
						$(this).dialog("close");
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
					$("div#snv_window").load("/index.php", {is_ajax: true, display: 'users'});
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		
		
		// PRE-DEFINE PART...
		$("div.set_status").livequery("click", function() {
			var mdata = $(this).metadata();
			$("<div id='pricingdialog'>Loading...</div>").load(mdata.url, {
				is_ajax: true,					// set by default...
		//		_source: mdata._source,
		//		_parent: mdata._parent,
				_fid: mdata._fid,
				manufacturer_id: mdata.manufacturer_id,		// this will have to be passed... should be 'id'
				manufacturer_part_id: mdata.manufacturer_part_id,
				id: mdata.id,				// this will have to be passed... should be 'itmid'
				title: mdata.title,
				customer_id: mdata.customer_id,
				customer_part_id: mdata.customer_part_id,
				customer_pn: mdata.customer_pn,
				eau: mdata.eau,
				target_price: mdata.target_price,
				action: mdata.action
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 600,
				width: 680,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Update Part Status": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#pricingdialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
								$("div#snv_window").load("/index.php", {is_ajax: true, id: mdata.id, display: 'detail'});
								$(this).dialog("close");
							}
						});
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		// SCOPE ALERT
		$("div.alert_scope").livequery("click", function() {
			var mdata = $(this).metadata();
			$("<div id='pricingdialog'>Loading...</div>").load(mdata.url, {
				is_ajax: true					// set by default...
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 140,
				width: 300,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Close Window": function() {
						$(this).dialog("close");
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		// Review Summitech Pricing...
		$("div.review_pricing").livequery("click", function() {
			var mdata = $(this).metadata();
			$("<div id='quotedialog'>Loading...</div>").load(mdata.url, {
				is_ajax: true,					// set by default...
		//		_source: mdata._source,
		//		_parent: mdata._parent,
				_fid: mdata._fid,
				manufacturer_id: mdata.manufacturer_id,		// this will have to be passed... should be 'id'
				manufacturer_part_id: mdata.manufacturer_part_id,
				id: mdata.id,				// this will have to be passed... should be 'itmid'
				title: mdata.title,
				customer_id: mdata.customer_id,
				customer_part_id: mdata.customer_part_id,
				customer_pn: mdata.customer_pn,
				eau: mdata.eau,
				target_price: mdata.target_price,
				action: mdata.action
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 460,
				width: 390,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Request New Pricing": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#quotedialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
								if(mdata._parent) {
									$("div#" + mdata._parent).load('/index.php', {is_ajax: true, id: mdata.id, display: 'detail'});
								}
								$(this).dialog("close");
							}
						});
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		
		// Review Summitech Pricing...
		$("div.quote_status").livequery("click", function() {
			var mdata = $(this).metadata();
			$("<div id='quotedialog'>Loading...</div>").load(mdata.url, {
				is_ajax: true,					// set by default...
		//		_source: mdata._source,
		//		_parent: mdata._parent,
				_fid: mdata._fid,
				manufacturer_id: mdata.manufacturer_id,		// this will have to be passed... should be 'id'
				manufacturer_part_id: mdata.manufacturer_part_id,
				id: mdata.id,				// this will have to be passed... should be 'itmid'
				title: mdata.title,
				customer_id: mdata.customer_id,
				customer_part_id: mdata.customer_part_id,
				customer_pn: mdata.customer_pn,
				eau: mdata.eau,
				target_price: mdata.target_price,
				quote_id: mdata.quote_id,
				revision: mdata.revision,
				action: mdata.action
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 460,
				width: 390,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Close Quote": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#quotedialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function() {
								if(mdata._parent) {
									$("div#" + mdata._parent).load('/index.php', {is_ajax: true, id: mdata.id, display: 'detail'});
								}
								$(this).dialog("close");
							}
						});
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		
		// what this needs to do...
		// it needs to append some data to the system...
		//
		// We can use this exactly as it's show...
		// the resulting form, will give the quantity amount to be quoted...
		
		// it will then return the data to the dialog, and it will be appended to the wrapper window...
		
		
		// Add Manufacturer User Dialog...
		$("#create_user").livequery("click", function() {
			var mdata = $(this).metadata();
			$("<div id='admindialog'>Loading...</div>").load(mdata.url, {
				_parent: mdata._parent,
				_fid: mdata._fid,
				mid: mdata.mid,		// this will have to be passed... should be 'id'
				id: mdata.id				// this will have to be passed... should be 'itmid'
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 300,
				width: 380,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Create User": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#admindialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function(rtnhtml) {
								$("#"+mdata._parent).append(rtnhtml);
								$(this).dialog("close");
							}
						});
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});
		
		


		$("div.rfq_quote_quantity").livequery("click", function() {
			var mdata = $(this).metadata();
			
			// load the data via ajax
			$("<div id='quotedialog'>Loading...</div>").load(mdata.url, {
				_parent: mdata._parent,
				_fid: mdata._fid,
				mid: mdata.mid,		// this will have to be passed... should be 'id'
				mpid: mdata.mpid,
				id: mdata.id,				// this will have to be passed... should be 'itmid'

			// initialize the dialog
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 350,
				width: 550,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Submit Price Quote": function() {
						$("form#"+mdata._fid).ajaxSubmit({
							target: "#quotedialog",
							beforeSubmit: function() {
								var v = $("form#"+mdata._fid).validate({
									meta: "validate",
									errorPlacement: function(error, element) {
										error.appendTo(element.next());
									}
								}).form();
								if(v) { return true; } else { return false; }
							},
							success: function(rtnhtml) {
								if(mdata._parent) {
									$("div#" + mdata._parent).load('/index.php', {is_ajax: true, id: mdata.id, display: 'detail'});
								}
								$(this).dialog("close");
							}
						});
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});



























		// Dialog Box...
		// these probably all need to be done separately...
		// we might need to do away with the ajax stuff on the MAIN page loads, and load custom jquery for each individual page, and each dialog has it's own form, prerendered on the page...
		
		$("div.dialog_button").livequery("click", function() {
			var mdata = $(this).metadata();
			
			// load the data via ajax
			$("<div id='adialog'>Loading...</div>").load(mdata.url, {
				is_ajax: true,					// set by default...
				_parent: mdata._parent,
				_fid: mdata._fid,
				mid: mdata.mid,		// this will have to be passed... should be 'id'
				mpid: mdata.mpid,
				id: mdata.id,				// this will have to be passed... should be 'itmid'
				title: mdata.title

			// initialize the dialog
			}).dialog({
				bgiframe: true,
				modal: true,
				height: 450,
				width: 550,
				position: ['center','center'],
				title: mdata.title,
				buttons: {
					"Close Window": function() {
					$(this).dialog("close");
					}
				},
				beforeclose: function() {
					$("form#"+mdata._fid).resetForm();
				},
				close: function() {
					$(this).dialog("destroy").remove();
					if(mdata._parent) {
						$("div#" + mdata._parent).load("/index.php", {is_ajax: true, id: mdata.id, display: mdata.display});
					}
				}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("button_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("button_over");
		});


		// logout...
		$("div.logout").click(function() {
			$("div#snv_window").load("/index.php", {is_ajax: true, channel: true, logout: true});
		}).mouseover(function() {
			$(this).addClass("logout_over");
		}).mouseout(function() {
			$(this).removeClass("logout_over");
		});
	
	
		// parts opportunities search...
		$("div#tnav_opportunities").click(function() {
			$("div#snv_window").load("/index.php", {is_ajax: true, display: 'list'});
		}).mouseover(function() {
			$(this).addClass("search_over");
		}).mouseout(function() {
			$(this).removeClass("search_over");
		});
		
		// user search...
		$("div#tnav_users").click(function() {
			$("div#snv_window").load("/index.php", {is_ajax: true, display: 'users'});
		}).mouseover(function() {
			$(this).addClass("search_over");
		}).mouseout(function() {
			$(this).removeClass("search_over");
		});
		
		// user search...
		$("div#tnav_customers").click(function() {
			$("div#snv_window").load("/index.php", {is_ajax: true, display: 'customers'});
		}).mouseover(function() {
			$(this).addClass("search_over");
		}).mouseout(function() {
			$(this).removeClass("search_over");
		});
		
		// login...
		// ----------------------
		$("#login_submit").live("click", function() {
			var email = $("input#email").val();
			var pswd = $("input#pswd").val();
			$.ajax({
				url: "/index.php",
				type: "post",
				data: "is_ajax=true&channel=true&email=" + email + "&pswd=" + pswd,	// add debug call here...
				success: function (stuff) {
					$("#snv_window").html(stuff);
				}
			});
				event.preventDefault();
		});
	
	
		// PARTS --> Autocomplete...
		$("#parts_search").livequery(function() {
			$(this).autocomplete("/_includes/_code/find_parts.php", {
				width: 700,
				selectFirst: false,
				cacheLength: 1,
				mustMatch: true,
				extraParams: {
					limit: function() { return $("#limit").val(); }
				}
			});
			$(this).result(function(event, data, formatted) {
				$("div#snv_window").load("/index.php", {is_ajax: true, id: data[1], display: data[2], type: data[3]});
			});
				return false;
		});
		
		
		// FILTERS --> Manufacturer Page
		$('#filtersubmit').livequery("click", function() {
			//alert('working');
			$('form#filter').ajaxSubmit({
				target: "#snv_window",
					success: function() {
				//		alert('success');
					}
			});
		}).livequery("mouseover", function() {
			$(this).addClass("filtersubmit_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("filtersubmit_over");
		});
		
		$('#filterreset').livequery("click", function() {
			//alert('working');
			$("div#snv_window").load("/index.php", {is_ajax: true, display: 'list'});
		}).livequery("mouseover", function() {
			$(this).addClass("filterreset_over");
		}).livequery("mouseout", function() {
			$(this).removeClass("filterreset_over");
		});
		
		
		$('.navButton, .navPage').livequery("click", function() {
			var mdata = $(this).metadata();
			$("div#snv_window").load("/index.php", {is_ajax: true, display: 'list', startPos: mdata.pos, goBack: 'true'});
		});

		
	});
