
jQuery(function($) {
	$(document).ready(function() {
		
		//$("input[type=text]").addAttr('maxlength', '100');
		
		// Adjust height of content area
		/*
		if ($('#Menu').length > 0) {
			if ( parseInt($('#Menu').css('height').replace('px', '')) > parseInt($('#Content').css('height').replace('px', '')) ) {
				$("#Content").css('height', $('#Menu').css('height'));
			} else {
				$("#Menu").css('height', $('#Content').css('height'));
			}
		}
		*/
		
		if ($("#same").length > 0) {
			$('#same').click(function() {
				if ($(this).val()=='on') {
					$('#saddress1').val($('#address1').val());
					$('#saddress2').val($('#address2').val());
					$('#scity').val($('#city').val());
					$('#sstate').val($('#state').val());
					$('#szip').val($('#zip').val());
					$('#scountry').val($('#country').val());
					
				}
			});
		}
		
		if ($(".tips").length > 0) {
			$(".tips").simpletooltip($(this).attr("title"));
		}
		
		if ($(".submitBtn").length > 0) {
			$(".submitBtn").click(function() {
				$(this).addClass('disabledBtn').attr('disabled','disabled').attr('value', 'Please Wait...');
				this.form.submit();
			});
		}
		
		if ($("#upgradeTimer").length > 0) {
			$("#cntdwn").removeAttr('style');
		}
		
	});
});

function redirect(loc) {
	newwin.close();
	newwin2.close();
	if (loc!='') {
		self.location = loc;
	}
}

var newwin;
function openpop() {
	var h = screen.height;
	var w = screen.width;
	var popup_width = 450;
	
	newwin = window.open('upgrade.php', 'upgrade', 'width=450,height=480,top=200,left=450,scrollbars=1');
	//window.open('upgrade.php', '_blank');
}

var newwin2;
function openpop2() {
	var h = screen.height;
	var w = screen.width;
	var popup_width = 450;
	newwin2 = window.open('upgrade2.php', 'upgrade', 'width=450,height=480,top=200,left=450,scrollbars=1');
}


function formatPhoneNumber(t) {
	var op = '';
	var cp = '';
	var ds = ''
	
	//alert(t.value);
	var ret =  t.value.replace(/[^0-9]+/g,'');
	var area = ret.substring(0, 3);
	var prefix = ret.substring(3, 6);
	var route = ret.substring(6, 10);
	
	if(ret.length > 0) {
		op = '(';
	}
	if(ret.length > 3) {
		cp = ') ';
	}
	if(ret.length > 6) {
		ds = '-';
	}
	t.value = op + area + cp + prefix + ds + route + '';
}