// JavaScript Document

function getSize() {
  var myWidth = 0, myHeight = 0;
  var specs = new Array();
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
	myScroll = window.pageYOffset;
	
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
	myScroll = document.documentElement.scrollTop;

  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
	myScroll = document.body.scrollTop;

  }
  specs[0] = myWidth;
  specs[1] = myHeight;
  specs[2] = myScroll;
  return specs;
}


$(document).ready(function() 
{
   // Match all link elements with href attributes within the content div
   $('#forgotPasswdLink').click(function () {
	  $('#forgotPass').slideToggle("fast");
	  $('#ajaxreply').html('');
    });
   
   $('#cxi_se').click(function() {
		$('#cxi_se_desc').slideToggle("fast");
		return false;
	});
   
   $('.buttonGreen').click(function () { 
      	useremail = $('#login_e_mail').val();
		//alert(useremail);
		$('#ajaxreply').load("ajax.php",{email:useremail});
    });
   
   $('.error').qtip({
      content: {
         text: false // Use each elements title attribute
      },
	  position: {
                  corner: {
                     tooltip: 'bottomMiddle', // Use the corner...
                     target: 'topMiddle' // ...and opposite corner
                  }
               },
      style: 'red' // Give it some style
   });
   
   $(".productWrapper").click(function () { 
     // alert($(this).attr("id"));
	  var winsize = new Array();
	  winsize = getSize();
	  $(".regContainer").find("#productImage").attr("src",$(this).find("img").attr("src"));
	  $(".regContainer").find(".name").text($(this).find("span").text());
	  $(".regContainer").find("#productID").attr("value",$(this).attr("id"));

	  //alert(winsize[0] + ' - ' + winsize[1] + ' - ' + winsize[2]);
	  //$("#apDiv1").hide();
	  $("#apDiv1").width(winsize[0]);
	  $("#apDiv1").height(winsize[1]);
	  $("#apDiv1").css("top",winsize[2] + "px");
	  $("#apDiv1").fadeIn(350, function () {
        $(this).find(".regContainer").fadeIn(200);
      });

	  
    });
   
   $("#regclose").click(function () {
		$(".regContainer").fadeOut(200, function () {
        $("#apDiv1").fadeOut(200);
		$('#error').html('&nbsp;');
                $('#productID').val('');
                $('#serial_number').val('');
      });						  
	});
   
   $('#regSubmitButton').click(function () { 
      	var serialNumber = $('#serial_number').val();
		var productID = $('#productID').val();
		//alert(serialNumber);
		$('#error').load("ajax.php",{serial:serialNumber, product:productID});
    });




});

