  //--------------------------------------------------------------------------------------------------------
  //whenever click the categorised tab load navigation and data for default
  //--------------------------------------------------------------------------------------------------------
  $(function() {                    
	  $("#tabs li a").bind("click",function() {

		  //looking for tab index like the length of the tab is than the index is 0,1,2,3,4,5
		  // find out which tab is clicked 
		  // the length of the tab is 5 its in array like [0,1,2,3,4,5]
		  //$(this) means current index(clicked tab index);
		  var clickedTab = $("#tabs li a").index($(this));

          
		  //get the navigation to load in left side based on the tab index 
		  var naviList = getNavigationList(clickedTab);  //this function will look in siwtch statement which tab is clicked and return the result

          $("#navigation").html("").html(naviList);
		  $("#navigation").hide().slideDown("slow");
		  removeHightLightClass();
		  $(this).closest("li").addClass("active");
		  
		  
  });  
  });

  
 //--------------------------------------------------------------------------------------------------------
 //if the tab is  already highlight remove the class and add it to newly clicked tab
 //--------------------------------------------------------------------------------------------------------
  function removeHightLightClass() {
  $("#tabs li").each(function() { 
			      if ($(this).is(".active")) {
			             $(this).removeClass("active");
			        }

  });
  }

 //--------------------------------------------------------------------------------------------------------
 //when the page gets load ,load the default navigation
 //--------------------------------------------------------------------------------------------------------
  $(function() {
     $("#navigation").html(getNavigationList(0)).hide().slideDown("slow");
  });

 //--------------------------------------------------------------------------------------------------------
 //--------------------------------------------------------------------------------------------------------

function getNavigationList(clickTab) {
      var str;
	  switch(clickTab) {

		  case 0:
			    $("#MI1").nextAll().hide();
			    $("#MI1").show("slow");
			        
			    return str = "<li><a href='#' onclick=\"showinfo('MI1');\">MI Request</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('MI2');\">Requesting Party</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('MI3');\">Receiving Party</a></li>";
					  
					  
				break;


		  case 1:
			      $("#LP1").siblings().hide();
			      $("#LP1").show("slow");
						      
						      
			      return str = "<li><a href='#' onclick=\"showinfo('LP1');\">Loan Features</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('LP2');\">Loan Purpose</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('LP3');\">Mortgage Terms</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('LP4');\">Proposed Housing Expense</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('LP5');\">Transaction Detail</a></li>";
					  
			   break;


		 case 2:
			      $("#BR1").siblings().hide();
			      $("#BR1").show("slow");
						      
			      return str = "<li><a href='#' onclick=\"showinfo('BR1');\">Credit Score*</a></li>"
					  //+ "<li><a href='#' onclick=\"showinfo('BR2');\">Income*</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('BR2');\">Assets*</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('BR3');\">Liability*</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('BR4');\">Declarations</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('BR5');\">Employer</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('BR6');\">Government Monitoring</a></li>";
					  
			   break;


		 case 3:
			      $("#PR1").siblings().hide();
			      $("#PR1").show("slow")
						      
			      return str = "<li><a href='#' onclick=\"showinfo('PR1');\">Property Attributes</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('PR2');\">Valuation</a></li>"
					  + "<li><a href='#' onclick=\"showinfo('PR3');\">Project…</a></li>";
					  
					  
			   break;


		case 4:
			      $("#SU1").prevAll().hide();
			      $("#SU1").show("slow")
						      
			      return str = "<li><a href='#' onclick=\"showinfo('SU1');\">Summary</a></li>";
					 // + "<li><a href='#' onclick=\"showinfo('SU2');\">Disclosure Data</a></li>"
					  //+ "<li><a href='#' onclick=\"showinfo('SU3');\">Property Information</a></li>"
					  //+ "<li><a href='#' onclick=\"showinfo('SU4');\">Mi Information</a></li>"
					  //+ "<li><a href='#' onclick=\"showinfo('SU5');\">Borrower Information</a></li>";
					  
			   break;

	     
		 default:
			      
			      break;

			    

	  }
  }

 //--------------------------------------------------------------------------------------------------------
 //--------------------------------------------------------------------------------------------------------

 $(function() {
  $("#postSub").bind("click",function() {
      if($.trim($(":text").val()) == "") {
	     alert("Please provide a input");
		 return false;
	  } else {
         //remove xml form in the dom
		 //alert(printXML())
			 //return false;
		 $("#xmlform").detach();
		 //attach xml form in the dom and post the xmlstring
		 var str = "<form name=\"xmlform\" id=\"xmlform\" method=\"post\">"
		         + "<textarea style=\"display:none;\" name=\"xmlstr\" id=\"xmlstr\">" + printXML() + "</textarea>"
				 + "</form>";
		//alert (str);
		 $("body").append(str);
	     $("#xmlform")[0].action='action.aspx';
	     $("#xmlform")[0].submit();
		 return true;
	  }
 });
 });


/*$(function() {
 $("#postSub").bind("click",function() {
	 $.post("Ajaxcalls.aspx",{xmlstr:printXML()},function(res,action) {
		 if(action == "success") {
			window.location = "action.aspx";
		}
    });
});
});*/
 


 //--------------------------------------------------------------------------------------------------------
 //--------------------------------------------------------------------------------------------------------

$(function() {
$("#clear").bind("click",function() {
      document.forms[0].reset();
	  return false;

  });
});

 //--------------------------------------------------------------------------------------------------------
 //--------------------------------------------------------------------------------------------------------

$(function() {
$.fn.extend({
     slideLeft: function() {
         return this.each(function() {
         $(this).animate({width:'hide'},"slow");
    });
  },

  slideRight: function() {
    return this.each(function() {
      jQuery(this).animate({width: 'show'});
    });
  }
});
});


//-------------------------------------------------------------------------------------------------------
//whenever click continue it will hide current td and show next one 
//--------------------------------------------------------------------------------------------------------
$(function(){
$('.continue:button').bind("click",function() {
	//looking for continue button index
	//ex MI Application contains 3 button so index is 0,1,2 if its 2 higlight the next tab and automatically
	//call click event to load navigation in the left side bar and data in the right side bar
    var btnindx = $('.continue:button').index($(this))
	
    switch(btnindx) {
		  case 2:
			  $("#tabs li a:eq(1)").trigger("click");   //fire click event when the continue end for the tab to hightlight next tab
		      break;

		  case 7:
			  $("#tabs li a:eq(2)").trigger("click");
		      break;

		  case 13:
			  $("#tabs li a:eq(3)").trigger("click");
		      break;


		   case 16:
			  $("#tabs li a:eq(4)").trigger("click");
		      break;

			default :
				break;

           }
			  		 
		
     			 
					 
					 
					 
					 // Get the DIV ID of the container div, which holds the form elements.			
				divID = $(this).parent().prev().attr("id");
				updateXML(divID);

				     // this piece of code look closer td of the input button 
	 //for ex <td><div>some name</div><input type='button' value ='continue'/></td> so if u click continue 
	 //button it look for closet td and it will hide it and it will make visible for  next td in the dom
         /*$(this).closest("td").slideLeft("slow")           //sideLeft function is used to hide the element
		                  .end().closest("td")
		                  .next().show("slow");*/	

		 $(this).parents("td").slideLeft("slow").end()
		 			.parents("td").next().show("slow");
         
		
});
});

//-----------------------------------------------------------------------------------------------------------
function showinfo(elmid) {
		$("#"+ elmid).siblings().hide();
        $("#"+ elmid).show("slow") ;
}

//-----------------------------------------------------------------------------------------------------------

$(function() {
 $(window).load(function() {
   $.ajax({
            url:"ajaxmethods.aspx?action=getIds",
		     cache: false,
		     success: function(result) {
		     $("#listbatch").html(result)
			 popup();

		  }
      });
});
});

//-----------------------------------------------------------------------------------------------------------

 function popup() {
     $.blockUI.defaults.css = {      
			padding:        0,
			margin:         0,
			width:          '50%', 
			top:            '22%', 
			left:           '25%', 
			textAlign:      'center', 
			color:          '#000', 
			backgroundColor:'#fff',
			cursor:         ''
      };
      $.blockUI({message:$('#popupdiv').fadeIn("slow")}); 

}

//-----------------------------------------------------------------------------------------------------------
$(function() {
	$(".go:button").bind("click",function() {
		 $(":radio:checked").each(function() {
			 ($(this).val() == "created") ? $.unblockUI({message:$('#popupdiv').fadeOut("slow")}):"";

	});
	});
});

//-----------------------------------------------------------------------------------------------------------
$(function() {
    $("#popupdiv input:radio").bind("click",function() {
	    if($(this).is(":checked")) {
		    ($(this).val() == "manage") ? $("#listbatch").slideDown("slow") : $("#listbatch").slideUp("slow");
	   }
});
});


//-----------------------------------------------------------------------------------------------------------

$(function() {
$("#popup").mouseover(function() {
 $(this).css({"cursor":"text"});
});
});
//-----------------------------------------------------------------------------------------------------------




		