jQuery.noConflict();


jQuery(document).ready(function() {
	if(jQuery('#popup_quiz').length > 0){
		jQuery('#popup_quiz').click(function(){
			scroll(0,0);
			QBox(661, 453, "quiz", "quiz");
			return false;
		});
	}

});

jQuery(window).load(function(){
	jQuery('#mdp_content2').css('display','block').remove();
});


var QBox = function(width, height, name, div) {
	
    jQuery("#mdp_overlay").remove();

    jQuery("body").append(
   		"<div id='mdp_overlay'>" +
   		"<div id='mdp_content2'>" +
			"<div id='mdp_content_close'></div>" +
   		"<div id='mdp_content_body'></div>" +
   		"</div>" +
   		"</div>");

    jQuery("#mdp_overlay").css({
        'height': jQuery(document).height() + "px",
        'width': jQuery(document).width() + "px",
        'background': 'url(/public/images/calculators/bg_black_trans.png) repeat',
        'top': 0,
        'left': 0,
        'position': 'absolute',
        'zIndex': '999',
        'display': 'none'
    });

    jQuery("#mdp_overlay").fadeIn();
    // if (!jQuery.browser.safari) {
    //         jQuery("#mdp_overlay").click(function() {
    //             jQuery("#mdp_overlay").remove();
    //         });
    //     }

    jQuery("#mdp_content2").css({
        'width': (width + 0) + "px",
        'zIndex': '999',
        "float": "left",
        "position": "relative",
        'height': (height + 0) + "px",
        'marginLeft': (jQuery(window).width() - width) / 2 + "px",
        'marginTop': (jQuery(window).height() - height) / 2 + "px"
    });
		
		
		var content = jQuery("#mdp_content_body");
    content.css({
        'zIndex': '999',
        'width': '100%',
        'height': '100%'
    });
		
		
		content.load('/public/quiz/index.html');

    jQuery("#mdp_content_close").css({
        'position': 'absolute',
        'background': 'url(http://glucocardyouchoose.com/public/images/calculators/x.png) no-repeat',
        'top': '-14px',
				'right': '-15px',
        'cursor': 'pointer',
        'zIndex': '999',
        
        'width': '40px',
        'height': '40px'
    });

    jQuery("#mdp_content_close").click(function() {
        jQuery("#mdp_overlay").remove()
    });


    //bind to the resize event to resize the background
    jQuery(window).resize(function() {
        jQuery("#mdp_overlay").css({
            'height': jQuery(document).height() + "px",
            'width': jQuery(document).width() + "px"
        });
				
				if(jQuery('#mdp_content2').length > 0){
        	jQuery("#mdp_content2").css({
            'marginLeft': (jQuery(window).width() - width) / 2 + "px",
            'marginTop': (jQuery(window).height() - height) / 2 + "px"
        	});
				}
				
    });
}
