$(document).ready(function(){
						  						  
$(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, .faq_box').hide();
		$('.pd_box').fadeIn().css({'width':'961px','margin-left':'0px'});
		// Embed file
		$('a.media').media({width:961, height:600});
		return false;
		});
						
// show faqs
		$('.faq_link').click(function() {
		$('.pb_box, .pa_box, pu_box, .endorsements_box, #eo_reminder').hide();
		$('.faq_box').fadeIn();
		// Embed file
		//$('a.media').media({width:961, height:600});
		return false;
		});
		
// show plan administrator	
		$('.pa_link').click(function() {
		$('.pb_box, .pu_box, .pd_box, .endorsements_box, .faq_box, #eo_reminder').hide();
		$('.pa_box').fadeIn();
		return false;
		});
		
// show endorsements
		$('.endorsements_link').click(function() {
		$('.pb_box, .pu_box, .pd_box, .pa_box, .faq_box, #eo_reminder').hide();
		$('.endorsements_box').fadeIn();
		return false;
		});
// show plan underwriter	
		$('.pu_link').click(function() {
		$('.pb_box, .pa_box, .pd_box, .endorsements_box, .faq_box, #eo_reminder').hide();
		$('.pu_box').fadeIn();
		return false;
		});
// show plan brochure	
		$('.pb_link').click(function() {
		$('.pu_box, .pd_box, .pa_box, .endorsements_box, .faq_box, #eo_reminder').hide();
		$('.pb_box').fadeIn();
		// Embed PDF
		$('a.media').media({width:961, height:425});
		$('.pb_box').css({'width':'650px'});
		return false;
		});
// Show E&O Reminder
		var param = $('#homepage_url').val();
		$('.eo_reminder_link').live('click', function () {
		$('.pu_box, .pd_box, .pa_box, .endorsements_box, .faq_box, .pb_box').hide();
		$('#eo_frame').attr('src', 'http://mgabuy.eo-insurance.com/eo_reminder/default.aspx?id='+param);
		$('#eo_reminder').fadeIn().focus().css({'width':'650px','margin-left':'175px'});
		$('#eo_reminder .box_inner').css({'width':'610px', 'height':'575px'});
		});
		$('#x').live('click', function () {
		$('#eo_reminder').fadeOut();
		});
// close box	
		$('.close').click(function() {
		$('.box').fadeOut();
;
		});
				
// Go to homepage	
		$('.home').click(function() {
		document.location.href="index.php"
		 });
		
// Popup Windows
		$('.cert').click(function() {
			window.open('https://mga.eo-insurance.com/Login.aspx','','resizable=yes,menubar=yes,location=yes,status=no,scrollbars=yes,toolbar=yes,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
		$(".hover_message").hover(
		function() { $(this).contents("span:last-child").css({ display: "block" }); },
		function() { $(this).contents("span:last-child").css({ display: "none" }); }
	);
	    $(".hover_message").mousemove(function(e) {
		var mousex = e.pageX + 10;
		var mousey = e.pageY + 5;
		$(this).contents("span:last-child").css({  top: mousey, left: mousex });
		});	
		
		$('.contact').click(function() {
 window.open("https://eo-insurance.com/contact/index.php?ref=MGA_EO",'','location=0,status=0,scrollbars=yes,width=500,height=650');
	return false;
	});
		
// 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')):"";
});
});
});
		
