$(document).ready(function() {


/*$(".printtable").click(function() {
w=window.open();
w.document.write($('head').html());
w.document.write($('.Products').html());
//w.print();
//w.close();
});*/

$(".showprices").click(function() {

var accountnumber = $('.accountnumber').val();
var password = $('.password').val();
	$.ajax({
		type: "GET",
  		url: "proxy.cgi",
		data: "Reference="+accountnumber+"&Password="+password,
		dataType: "xml",
		cache: false,
		success: function(xml) {
			$(xml).find('row').each(function(){
				Account = $(this).attr('Account');
				Name = $(this).attr('Name');
			});
			if (typeof Account === 'undefined') {
				alert ('Sorry, that Account and Password is not recognised.\nTry again or contact us!');
			} else {
				alert ("Welcome " + Name);
				$('.Retail').show();
				$('.VATExc').show();
				$('.Buy').show();
				$('.showprices').hide();
				$('.asklogin').hide();
			}
		}
	});



//$.get('http://onet.sinclairoptical.co.uk/sos/accountcheck.cgi', { Account: "A3095S", Password: "merrymakers637" }, 
//function(res) { 
//alert(res);
//var serializer = new XMLSerializer();
//var xml = serializer.serializeToString(res);
//alert(xml);
//});







//$.ajax({
//  type: "POST",
//  url: "http://onet.sinclairoptical.co.uk/sos/accountcheck.cgi",
//  data: "Account=A3095S&Password=merrymakers637",
//  success: function(data){
//    alert('done');
//    $('.Retail').show();
//  }
//});



});
oddeven();
 //Declare the custom selector 'containsIgnoreCase'.
      $.expr[':'].containsIgnoreCase = function(n,i,m){
          return jQuery(n).text().toUpperCase().indexOf(m[3].toUpperCase())>=0;
      };
  
      $(".filter").keyup(function(){

          $(".filterable").find("tr").hide();
          var data = this.value.split(" ");
          var shaun = $(".filterable").find("tr");
          $.each(data, function(i, v){

               //Use the new containsIgnoreCase function instead
               shaun = shaun.filter("*:containsIgnoreCase('"+v+"')");
          });

          shaun.show();
oddeven();

      }).focus(function(){
          this.value="";
          $(this).css({"color":"black"});
          $(this).unbind('focus');
      }).css({"color":"#C0C0C0"});
  });

function oddeven() {
  $(".filterable tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
  $(".filterable tr:even").addClass("even");
  $(".oddeven tr:even").addClass("even");
}

