// JavaScript Document
function initMenu() {
 $('.sidenavmenu ul').hide();
  $('.on').parents("ul").first().show().prev().addClass("subnavheader");
  $('.on').parents("ul").show();
  if ($(".on").size()==0) $('.sidenav ul:first').slideDown("slow");
  $('.sidenavmenu  li a').click(
    function() {	
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
		$(".sidenavmenu  li a").removeClass("subnavheader");
		$(this).addClass("subnavheader");				
        $('.sidenavmenu  ul:visible').not($(this).parents()).slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }
	
$(document).ready(function() {

	
							   
	initMenu(); 
	
	$("#copy_tech_spec h3").nextUntil("h3").hide();
	$("#copy_tech_spec h3").click(
		function() {
			// check if show
			var checkElement = $(this).next();
			if (checkElement.is(':visible')) {
				$(this).nextUntil("h3").slideUp();
				$(this).removeClass("open");				
			} else {
				$(this).nextUntil("h3").slideDown();
				$(this).addClass("open");
			}
		}
	);
	
	$('#copy_tech_spec h3').hover(function() {
		$(this).css('cursor','pointer');
	}, function() {
		$(this).css('cursor','auto');
	});
	
	$("#logo").click (function() { window.location = "http://www.sentralsystems.com/"; });
	

	// form handling
	          
			var callback = { 
				success:   showResponse,  // post-submit callback 
				dataType:  'json'        // 'xml', 'script', or 'json' (expected server response type) 
			}; 
			
			var redirect = { 
				success:   doRedirect,  // post-submit callback 		 
				dataType:  'json'        // 'xml', 'script', or 'json' (expected server response type) 
			}; 
	
			function showResponse(responseText, statusText, xhr, $form)  { 			 
				$(responseText.div).replaceWith("<div class='form_message rounded_corners'>"+responseText.response+"</div>");		
			} 
			
			function doRedirect(responseText, statusText, xhr, $form)  { 	
				if (responseText.response.search(/unsecured/i) > 0) {
					window.open(responseText.response,'mywindow') ;
				}
				else {
				window.location=responseText.response;
				}
			} 
			


			$("#rma_submit").click(function() 	{ $("#request_callback").ajaxSubmit(callback); return false; });
			


});


