jQuery.noConflict();
jQuery(document).ready(function() {
	jQuery('.lightbox').lightBox({
		imageBtnClose: mainDom+'/admin/template/images/lightbox/lightbox-btn-close.gif',
		imageLoading: mainDom+'/admin/template/images/lightbox/lightbox-ico-loading.gif',
		imageBtnPrev: mainDom+'/admin/template/images/lightbox/lightbox-btn-prev.gif',
		imageBtnNext: mainDom+'/admin/template/images/lightbox/lightbox-btn-next.gif',
		imageBlank: mainDom+'/admin/template/images/lightbox/lightbox-blank.gif'
	});
	jQuery("ul.pageme").quickPager({pageSize:"15",pagerLocation:"bottom"});
	oTable = jQuery('#tableSort').dataTable({
		"bJQueryUI": true,
		"bStateSave": true,
		"sPaginationType": "full_numbers",
		"aoColumns": [
			null,
			null,
			null,
			null
		]
	});
	jQuery(".tweet").tweet({
		username: "robotwelding",
		join_text: "auto",
		avatar_size: 0,
		count: 3,
		auto_join_text_default: "",
		auto_join_text_ed: "",
		auto_join_text_ing: "",
		auto_join_text_reply: "",
		auto_join_text_url: "",
		loading_text: "loading tweets..."
	});

		var contactBoxy = null;
		/* what to do when click on contact us link */
		jQuery('.quote_request').click(function(){
			var boxy_content;
			
			boxy_content += "<div style=\"width:300px; height:350px\"><form id=\"feedback\">";
			boxy_content += "<p class=\"infobox\">Part Number: <input readonly=\"readonly\" type=\"text\" name=\"partnumber\" value=\""+jQuery(this).attr('title')+"\" id=\"partnumber\" size=\"44\" /></p>";
			boxy_content += "<p class=\"infobox\">Controller Type: <input readonly=\"readonly\" type=\"text\" name=\"controller\" value=\""+jQuery(this).attr('rel')+"\" id=\"controller\" size=\"44\" /></p>";
			boxy_content += "<p class=\"infobox\">Robot Type: <input readonly=\"readonly\" type=\"text\" name=\"robot\" value=\""+jQuery(this).attr('rev')+"\" id=\"robot\" size=\"44\" /></p>";
			boxy_content += "<p class=\"startbox\">Name: <input type=\"text\" name=\"name\" id=\"name\" size=\"44\" /></p>";
			boxy_content += "<p>Phone: <br/><input type=\"text\" name=\"phone\" id=\"phone\" size=\"44\" /></p>";
			boxy_content += "<p>Email: <br/><input type=\"text\" name=\"email\" id=\"email\" size=\"44\" /></p>";
			boxy_content += "<p>Comment:<br /><textarea name=\"comment\" id=\"comment\" cols=\"34\" rows=\"4\"></textarea></p><p><input type=\"submit\" name=\"submit\" value=\"Send Quote\" /></p>";
			boxy_content += "</form></div>";
			contactBoxy = new Boxy(boxy_content, {
				title: "Quote Request",
				draggable: false,
				modal: true,
				behaviours: function(c) {
					c.find('#feedback').submit(function() {
						Boxy.get(this).setContent("<div style=\"width: 300px; height: 300px\">Sending...</div>");
						// submit form by ajax using post and send 3 values: subject, your_email, comment
						jQuery.post(mainDom+"/quote-request.php", { partnumber: c.find("input[name='partnumber']").val(), controller: c.find("input[name='controller']").val(), robot: c.find("input[name='robot']").val(), name: c.find("input[name='name']").val(), phone: c.find("input[name='phone']").val(), email: c.find("input[name='email']").val(), comment: c.find("#comment").val()},
						function(data){
							/*set boxy content to data from ajax call back*/
							contactBoxy.setContent("<div style=\"width: 300px; height: 300px\">"+data+"</div>");
						});
						return false;
					});
				}
			});
			return false;
		});

});
