
var minus = function(minVal){
		if(parseFloat($("#pti").val()) > minVal)
		$("#pti").val((parseInt($("#pti").val())-1));
	}
var plus = function(maxVal){
	if(parseFloat($("#pti").val()) < maxVal)
	$("#pti").val((parseInt($("#pti").val())+1));
}
$(document).ready(function() {
	
		$("#menublock").find('td').mouseenter(function(){
			$(this).css("background", "#fa1d25") ;
		}) ;
		$("#menublock").find('td').not(".act").mouseleave(function(){
			$(this).css("background", "#8694a5") ;
		}) ;
		//document.getElementById('contentstart').scrollIntoView();
		$(".has-sub").mouseenter(function(){
			$(this).children('div').show();
		}) ;
		$(".has-sub").mouseleave(function(){
			$(this).children('div').hide();
		}) ;
		
		$(".ajax-link").click(function(){
			if($(this).hasClass('ajax-has-sub') || $(this).hasClass('ajax-has-no-sub'))
			{
				$('.ajax-has-sub').not(this).next().slideUp();
			}
			if($(this).hasClass('ajax-has-sub') && $(this).next().is(':hidden')){
				$(this).next().slideDown();
			}
			if($(this).parent().prev().hasClass('ajax-has-sub') && $(this).parent().is(':hidden') ){
				$(this).parent().slideDown();
			}
			
		$('#ajax-content').html('<div style="width:500px;"><center><br /><br /><br /><br /><img src="/images/loading.gif" /></center></div>');
		var thislink = $(this) ;
		var url = $(this).attr('href') ;
		
			$.ajax( {
				url : url,
				type: "POST",
				data: "action=menu",
				dataType: "json",
				error:function()
				{
					$('#ajax-content').html( 'Internal Server Error' );	
				},
				success : function(data) 
				{

					location.hash = thislink.attr('id') ;
					document.getElementById('contentstart').scrollIntoView();
					$('#ajax-content').html(data.content) ;
					$("#footer").removeClass("footer");
					$("#footer").addClass("footer_other");
					//var height = $('#ajax-content').innerHeight() ;
					//$('.cont-right').height(height) ;
					$('#page-title').html(data.title) ;
					$(".ajax-link").css("text-decoration", "none") ;
					thislink.css("text-decoration", "underline") ;
	
				}
			});
			return false;	
	}) ;
		if ( location.hash.slice(1) )
		{
			
			$("#" + location.hash.slice(1) ).trigger('click') ;
		}
//	$(".calc").click(
//			function(){
//				$("#homeCalc").slideDown();
//			}
//	);
//	
	$("#login_link").click(			
			
			function ()    { 
				var _loginDialog = document.createElement('div');
				$(_loginDialog).attr("id","dialog");
				var _loaderImage = new Image();
				_loaderImage.src = "/images/loading.gif";
				$(_loginDialog).html(_loaderImage);
			var ahref=$(this).attr("href");
			//var tit=$(this).attr("title");
        $(_loginDialog).dialog({
            modal: true,
            open: function ()
            {
			
                $(this).load(ahref);
				
            },    
           
            
            width: 250,
            resizable: false,
            //title: tit,
			close: function(e, i) { $(this).remove(); }
        });
        $(".ui-dialog-titlebar").hide();
        return false;
}
			
);
	
	$(".numeric").numeric(",");
	
	    //$(".numeric").numeric({negative : false, decimal: false});
	
	
	
	if($.browser.msie && $.browser.version=="6.0")
	{
		DD_belatedPNG.fix('.contbg,.accordionWrapper div.content,img');
		DD_roundies.addRule('.rounds3', '3px');
	}
	
	
	$('marquee').marquee();	
	

	$('#slideshow img:first').fadeIn(100, function() {
		$('#slideshow').cycle({
		speed:  800, 
		timeout:5000
		});
	});
	
	$("#accordion4").msAccordion({defaultid:-1, vertical:true, event:'mouseover'});
	

});

var calculate = function (){
	var url = "/calculators.html" ;
	var html = $("#calcbutdiv").html() ;
	$("#calcbutdiv").html( '<img src="/images/loading.gif" class="fl" />' ); 
//	d = "pti=" + $("#pti").val() + "&income=" + $("#income").val() + "&members=" + $("#members").val() + "&term=" + $("#term").val() + "&annualPercentageRate=" + $("#annualPercentageRate").val();
//	alert( url ) ;

	$.ajax( {
		url : url,
		type: "POST",
		dataType: "json",
		data: "pti=" + $("#pti").val() + "&income=" + $("#income").val() + "&members=" + $("#members").val() + "&term=" + $("#term").val() + "&annualPercentageRate=" + $("#annualPercentageRate").val(),
		
		error:function()
		{
			$('#size').val( 'Internal Server Error' );	
		},
		success : function(data) 
		{	
			
			$("#calcbutdiv").html(html);
			
			$('#size').val(data.loansize) ;
		}
	});
	return false;
}

function reloadCaptcha(path)
{
	$("#captImage").attr('src','/kcaptcha/index.php?chk='+Math.random(150000));
}


function _closeDialog()
{
	$("#dialog").dialog("close");
}


