// JavaScript Document
var ERROR_ON_PAGE = false;
	function ajax_LoadTestemonials()
	{
		$.ajax({
				  url: "testimonials-3.php",
				  cache: false,
				  success: function(ajax){
					$("#div_Testemonials").html(ajax);
				  }
				});
	
	}

	//ajax_LoadTestemonials();
	//setTimeout('ajax_ListGraphs3()',1000);
	//setInterval('ajax_LoadTestemonials()', 15000);
						/*
								setTimeout(function()
													{
															$('#xFORM').cycle({
																				fx:     'fade',
																				prev:   '.prev',
																				//next:   '.next',
																				timeout: 0,
																				cleartype:  1
																			});
															$('#tnc').load('signup-terms.php?SID=' + Math.random());
													},500);
						*/
								$('#tnc').load('signup-terms.php?SID=' + Math.random());
								$("#tnc").dialog({ 
													  height: $(window).height()-300,
													  width: 600,
													  show: 'blind',
													  hide: 'blind',
													  modal: true,
													  position: 'center',
													  autoOpen: false,
													  title:'Terms and Conditions',
													  overlay: { 
																  opacity: 0.5, 
																  background: "red" 
															  } 
												});

								$("#upload-testimonial").dialog({ 
													  height: 250,
													  width:  500,
													  show: 'blind',
													  hide: 'blind',
													  modal: true,
													  position: 'center',
													  autoOpen: false,
													  title:'Upload Testimonial',
													  overlay: { 
																  opacity: 0.5, 
																  background: "red" 
															  } 
												});

								$("#divMORE").dialog({ 
													  show: 'blind',
													  hide: 'blind',
													  modal: true,
													  position: 'center',
													  autoOpen: false,
													  overlay: { 
																  opacity: 0.5, 
																  background: "red" 
															  } 
												});

								$("#divUPLOAD").dialog({ 
													  height: 475,
													  width: 860,
													  show: 'blind',
													  hide: 'blind',
													  modal: true,
													  position: 'center',
													  autoOpen: false,
													  resizable: false,
													  title: 'Attach Photo or Document',
													  overlay: { 
																  opacity: 0.5, 
																  background: "red" 
															  } 
												});


								$(".msg").dialog({ 
													  height: 100,
													  width:  400,
													  show: 'blind',
													  hide: 'blind',
													  modal: true,
													  position: 'center',
													  autoOpen: false,
													  title:'Error',
													  overlay: { 
																  opacity: 0.5, 
																  background: "red" 
															  } 
												});

								$(".password").dialog({ 
													  height: 150,
													  width:  450,
													  show: 'blind',
													  hide: 'explode',
													  modal: true,
													  position: 'center',
													  autoOpen: false,
													  title:'Password Recovery',
													  overlay: { 
																  opacity: 0.5, 
																  background: "red" 
															  } 
												});

												
								 $('#div_Testemonials').cycle({
										 fx: 'fade', 
										 timeout: 10000, 
										speed: 1000, pause: 1
								
										// choose your transition type, ex: fade, scrollUp, shuffle, etc...
									});
								 								 
								$('.tip').tooltip({
									track: true,
									delay: 0,
									showURL: false,
									showBody: " - ",
									fade: 250, 
									color: "#ECECEC"
								});
								
								

								$("#product").hint();
								//$("#div_Products").draggable();
								
								$("#ACC_DEADLINE").datepicker({minDate: 0, inline: true, dateFormat: 'mm/dd/yy'});
								$("#ACC_PHONE_NUM").numeric();

								$("#ACC_ZIP").numeric();
								//$("#ACC_PHONE_NUM").mask("(999)999-9999");
								
								  $(".estvalue").bind("mouseenter mouseleave", function(event){
								  		$(this).toggleClass("ui-state-active");
								  });
	
	function check_length()
	{
		maxLen = 500;
		var _curLen = $("#TEST_TEXT").val().length;
		
		if(_curLen >= maxLen)
		 {
			$("#div_TestimonialStatus").html(" You have reached your maximum limit of characters allowed");
			$("#TEST_TEXT").val($("#TEST_TEXT").val().substring(0, maxLen));
		 }
		else
		 {
			$("#div_TestimonialStatus").html(maxLen - _curLen + " characters remaining.");
		 }
	}

	function fn_ValidateStep(_step)
	{
		$('*[name=' + _step + ']').each(function()
									{ 
										// Test if a required field has no data then set the error flag to true and exit the loop.
										if($(this).val().length == 0)
										 {
											//alert("Missing one or more required field(s).");
											//$(this).addClass("ui-state-error");
											if($(this).hasClass('input'))
											 {
												$("#error").html(ERROR_IMG + " Missing " + $(this).attr('title')); 
											 }
											else
											 {
												$("#error").html(ERROR_IMG + " " + $(this).attr('title'));	 
											 }
											
											$("#error").dialog("open");
											$(this).focus();
											ERROR_ON_PAGE = true;
											return false;
										 }
										 ERROR_ON_PAGE = false;
										
             				}); 
		if(ERROR_ON_PAGE)
		{
			return;	
		}
		
		//alert(_step);
		switch(_step)
		 {
			case "s1":
				ajax_PostProject(_step);
				
				if ($.browser.mozilla)
				{
					//$("#step2").height(440);
				}
			break;
			
			case "s2":
				ajax_UpdateProject(_step);
				if ($.browser.mozilla)
				{
				//$("#step3").height(320);
				}
			break;
			
			case "s3":
				 ajax_UpdateUserAccount(_step);
			break;
			
		 }
	}

	function jsf_CompleteProcess()
	 {
		$("#matches").html("Your Project <br> Has Been Successfully Posted.");
		$("#progress_s3").html("");
		$("#submit_3").toggle("slide");
	 }
	 
	 function jsf_SelectDivision(_id)
	  {
		$("#ACC_CSI_OPPT").val("");
		//alert(_id);

		if($("#" + _id).is(':checked') == false)
		 {
			$("#" + _id).each(function()
										{ 
											$("." + _id).attr('checked', false);
										}); 

		 }
		else
		 {
			$("#" + _id).each(function()
										{ 
											$("." + _id).attr('checked', true);
										}); 
			 
		 }
			jsf_CreateAccountCSIProfile();
	  }
	  
	  function jsf_FillProjectText(_lbl, _level)
	   {
		$("#product").val("");
		$('*[name=' + _level + ']:checked').each(function()
										{								
												if($("#product").val().length == 0)
												 {
													$("#product").val($(this).attr('title'));
												 }
												 else
												 {
													$("#product").val($("#product").val() + ", " + $(this).attr('title'));
												 }
										});
	   }
	   
	   
	   function ajax_LoadCSIDIV(_div, _title)
	    {
			
			$('#divMORE').dialog('open'); 
			$('#divMORE').dialog('option','title',_title);
			setTimeout(function()
								{
									$("#divMORE").dialog("option","maxHeight", $('#CSI').height());
									$("#divMORE").dialog("option","width", $('#CSI').width() + 25);
									$("#divMORE").dialog("option","position", "center");
								}, 1000);
			
			$.ajax({
					  url: "../wrk_new/doGetCsiDivDetails.php?DIV_ID=" + _div + "&SID=" + Math.random(),
					  cache: true,
					  success: function(ajax)
					  {
							$("#divMORE").html(ajax);
					  }
					});
			
			//$('#divMORE').load('doGetDivDetails.php?DIV_ID=$row[DIV_ID]&SID=' + Math.random()); 	
			
			
			
		}

	function jsf_DisplayZipCodeDetails()
	{
		if($("#ACC_ZIP").val().length == 0)
		 {
			return; 
		 }
		
		$("#zipdetails").html("Searching ...");
		setTimeout(function()
							{
								if($("#ACC_CITY").val().length == 0 || $("#ACC_STATE").val().length == 0)
									 {
										$("#zipdetails").html("Invalid Zip Code");
										return;
									 }
								$("#zipdetails").html($("#ACC_CITY").val() + ", " + $("#ACC_STATE").val());						
							}, 1500);
		
	
	}
	
	
	function jsf_OpenUploadDialog()
	{
		$('#divUPLOAD').dialog('open');
		$.ajax({
				  url: "../wrk_new/doNewUploadList.php?SID=" + Math.random(),
				  cache: true,
				  success: function(ajax)
				  {
						$("#divUPLOADLIST").html(ajax);
						window.frames['if_upload'].location.reload(true);
						
				  }
				});
	}
