/* Author: 
	Danny
*/

JQ(document).ready(function() {
	
	// *****
	// Validation of Sign Up Form
	JQ("#UserSignupForm").validate({
		rules: {
			cardnum: {
				creditcard2: function(){ 
					return JQ('#cardType').val();
				}
			}
		}
	});
	
	// helper function to fire validation on field2 when cardType changes
	JQ('#cardType').change(function(){
		JQ("#UserSignupForm").validate().element('#cardnum');
	});
	
	JQ('.submit').click(function(ev) {
	ev.preventDefault();
		JQ('#UserCheckpass').attr('value', JQ('#password').val()) ;
		//alert(JQ('#UserCheckpass').val());
		//JQ(this).parent().submit();
		JQ('#UserSignupForm').submit();
		
	});

	// *****
	// Clears Input on Focus
	
	//JQ(".clearme").clearMe();
	
	// *****
	// Position Zoom Thumbnail

	JQ(".t_zoom").each(function(index) {

		// Get data from attributes
		var left = JQ(this).attr('left');
		var top = JQ(this).attr('top');
		
		// Set position with offset width
		JQ(this).css({'left' : left + 'px', 'top' : top + 'px'});
	});

	// *****
	// Position tooltip

	JQ(".t_zoom span").each(function(index) {

		// Get calculated width of tooltip
		var width = JQ(this).parent().width()+10;
		
		// Get calculated height of tooltip and divide by 2 (rounded)
		var height = Math.round(JQ(this).height()/2+10);

		// Set position with offset width
		JQ(this).css({'left' : width + 'px', 'margin-top' : '-' + height + 'px'});
	});

});

