$(document).ready(function(){
						   
$("#Result").click(function() {
    $.ajax({
      type: "POST",
      url: "Default.aspx/GetDate",
      data: "{}",
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(msg) {
        // Replace the div's content with the page method's return.
        $("#Result").text(msg.d);
      }
    });
  });
						  
$(function(){$('div.pngFix').pngFix();});
					   
// Hide Divs

(function () {
	var head = document.getElementsByTagName("head")[0];
	if (head) {
		var scriptStyles = document.createElement("link");
		scriptStyles.rel = "stylesheet";
		scriptStyles.type = "text/css";
		scriptStyles.href = "css/hide_divs.css";
		head.appendChild(scriptStyles);
	}
}());
 		
// fix for the jQuery slide effects

function slideToggle(el, bShow){
  var $el = $(el), height = $el.data("originalHeight"), visible = $el.is(":visible");
  
  // if the bShow isn't present, get the current visibility and reverse it
  if( arguments.length == 1 ) bShow = !visible;
  
  // if the current visiblilty is the same as the requested state, cancel
  if( bShow == visible ) return false;
  
  // get the original height
  if( !height ){
    // get original height
    height = $el.show().height();
    // update the height
    $el.data("originalHeight", height);
    // if the element was hidden, hide it again
    if( !visible ) $el.hide().css({height: 0});
  }

  // expand the knowledge (instead of slideDown/Up, use custom animation which applies fix)
  if( bShow ){
    $el.show().animate({height: height}, {duration: 250});
  } else {
    $el.animate({height: 0}, {duration: 250, complete:function (){
        $el.hide();
      }
    });
  }
}

// highlight text inputs and REMOVE Single and double quotation values

	    $(':input:not([type="submit"])').each(function() {
	    $(this).focus(function() {
		});	
		$(this).blur(function() {
		this.value = this.value.replace(/[%&*}{>\]\[<|'"\\]/g,'');
		});
		});
// show plan policy	
		$('.pd_link').click(function() {
		$('.pb_box, .pa_box, pu_box,.endorsements_box').hide();
		$('.pd_box').fadeIn().draggable().css({'width':'865px','margin-left':'0px'});
		// Embed PDF
		$('a.media').media({width:865, height:600});
		return false;
		});
		
// show plan administrator	
		$('.pa_link').click(function() {
		$('.pb_box, .pu_box, .pd_box, .endorsements_box').hide();
		$('.pa_box').fadeIn().draggable();
		return false;
		});
		
// show endorsements
		$('.endorsements_link').click(function() {
		$('.pb_box,.pu_box,.pd_box,.pa_box').hide();
		$('.endorsements_box').fadeIn().draggable();
		return false;
		});
// show plan underwriter	
		$('.pu_link').click(function() {
		$('.pb_box,.pa_box,.pd_box,.endorsements_box').hide();
		$('.pu_box').fadeIn().draggable();
		return false;
		});
// show plan brochure	
		$('.pb_link').click(function() {
		$('.pu_box,.pd_box,.pa_box,.endorsements_box').hide();
		$('.pb_box').fadeIn().draggable();
		// Embed PDF
		$('a.media').media({width:648, height:425});
		$('.pb_box').css({'width':'650px'});
		return false;
		});
// close box	
		$('.close').click(function() {
		$('.box').fadeOut();
;
		});
				
// Go to homepage	
		$('.home').click(function() {
		document.location.href="default.aspx"
		 });
		
// Popup Windows
		$('.cert').click(function() {
		window.open('https://mga.eo-insurance.com/Login.aspx','','resizable=yes,menubar=no, location=yes,status=no,scrollbars=yes,toolbar=no,width=980,height=600');	
		return false;

		});

		$('.send_mail').click(function() {
		window.open('http://www.napa-eo.org/contact_napa/','','location=0,status=0,scrollbars=auto,width=550,height=400');
		return false;
		});
		
		$('.im_agent_app').click(function() {
		window.open('https://mgabuy.eo-insurance.com/IM/IM_Agent_App/default.aspx','','location=0,status=0,scrollbars=yes,width=980,height=800');
		return false;
		});
		
		$('.im_agency_app').click(function() {
		window.open('https://mgabuy.eo-insurance.com/IM/IM_Agency_App/default.aspx','','location=0,status=0,scrollbars=yes,width=980,height=800');
		return false;
		});


		// Hover Message

		$(".nd_renew_message").hover(
		function() { $(this).contents("span:last-child").css({ display: "block" }); },
		function() { $(this).contents("span:last-child").css({ display: "none" }); }
	);
	    $(".nd_renew_message").mousemove(function(e) {
		var mousex = e.pageX + 10;
		var mousey = e.pageY + 5;
		$(this).contents("span:last-child").css({  top: mousey, left: mousex });
		});	
		
// IE Cleartype fix
	
jQuery.fn.fadeIn = function(speed, callback) {
     return this.animate({
          opacity: 'show' }, speed, function() {
               if (jQuery.browser.msie)
                    this.style.removeAttribute('filter');
               if (typeof callback == 'function')
                    callback();
     });
};

jQuery.fn.fadeOut = function(speed, callback) {
     return this.animate({
           opacity: 'hide' }, speed, function() {
               if (jQuery.browser.msie)
                    this.style.removeAttribute('filter');
               if (typeof callback == 'function') callback();
     });
};

jQuery.fn.fadeTo = function(speed,to,callback) {
     return this.animate({opacity: to }, speed, function() {
          if (to == 1 && jQuery.browser.msie)
               this.style.removeAttribute('filter');
          if (typeof callback == 'function') callback();
     });
}; 
	
// END IE Cleartype fix		

   		$("#sponsor").change(function(){
  		document.location.href = $('#sponsor').val();
		}); 
	
// Gray Splash Screen		
$(function(){
var pop = function(){
	$('#grayout_screen').show().css({opacity: 0.7,'width':$(document).width(),'height':$(document).height()});
	$('#eo_plans').fadeIn().click(function(){$(this).fadeOut();$('#grayout_screen').fadeOut();});
}
	$('.eo_options_link').click(pop);
	$(window).resize(function(){
	$('#eo_plans').css("display") == 'block'?pop.call($('.eo_options_link')):"";
});
});
});
		