// JavaScript Document
$(document).ready(function() {
    jQuery.fn.extend({
        popup_hover: function(id, popid) {
            $('#' + id).css('cursor', 'pointer');
            $(this).click(function() {
                var btn_off = $('#' + id).offset();
                if (id == 'btn-5') {

                    window.parent.document.getElementById('main-pop-bottom').style.marginTop = 0;
                    document.getElementById('requestcall2').src = '/webpages/RequestCallBackNew.aspx?p=' + Math.random();
                    
                    if(document.getElementById('hdFormLoad'))
                    {
                        if(document.getElementById('hdFormLoad').value !='1')
                        document.getElementById('requestcall2').height = '250px';
                    }
 

                    var btn_L = btn_off.left - 157;
                    var btn_T = btn_off.top + $('#' + id).height() - $('#' + popid).height() - 0;
                }
                else {
                    var btn_L = btn_off.left - 115;
                    var btn_T = btn_off.top + $('#' + id).height() - 10;
                }
                $('#main-pop-bottom').fadeIn();
                if (id == 'btn-6') {
                    var btn_L = btn_off.left - 192;
                    var btn_T = btn_off.top + $('#' + id).height() - $('#' + popid).height() - 3;
                    $('#main-pop-bottom-2').fadeIn();
                    $('#popback').css({
                        'width': '100%',
                        'height': '800px',
                        'background': '#000',
                        'opacity': 0.7,
                        'position': 'absolute',
                        'top': 0,
                        'left': 0
                    });
                }

                if (id == 'btn-7') {
                    var btn_L = btn_off.left - 146;
                    var btn_T = btn_off.top + $('#' + id).height() - $('#' + popid).height() + 5;
                }

                if ($('#' + popid).css('display') == 'block') {
                    $('#' + popid).css({
                        'position': 'absolute',
                        'top': btn_T,
                        'left': btn_L,
                        'z-index': 5000
                    });
                    $('#' + popid).animate({ opacity: 'show' }, 0);
                } else {
                    $('#' + popid).css({
                        'position': 'absolute',
                        'top': btn_T,
                        'left': btn_L,
                        'z-index': 5000
                    });
                    $('#' + popid).animate({ opacity: 'show' }, 0);
                }
            });
        }
    });

    $('#btn-close').click(function() { $('#main-pop-bottom').hide(); });
    $('#btn-close2').click(function() {
        $('#main-pop-bottom-2').hide();
        $('#popback').animate({ opacity: 'hide' }, 0);
    });
    $('#btn-close17').click(function() {
        $('#popup17').hide();
        $('#pop_back17').animate({ opacity: 'hide' }, 0);
        $('#popback').animate({ opacity: 'hide' }, 0);
    });
    $('#btn-close16').click(function() { $('#popup16').hide(); $('#pop_back16').animate({ opacity: 'hide' }, 0); });

    $('#popback').click(function() { $('#main-pop-bottom-2').animate({ opacity: 'hide' }, 0); $('#popback').animate({ opacity: 'hide' }, 0); });

    $('#btn-close3').click(function() { $('#main-pop-bottom-3').hide(); });


    $('#btn-5').popup_hover('btn-5', 'main-pop-bottom');
    $('#imgforSignUp').popup_hover('imgforSignUp', 'main-pop-bottom-2');
    $('#btn-6').popup_hover('btn-6', 'main-pop-bottom-2');
    $('#btn-7').popup_hover('btn-7', 'main-pop-bottom-3');
	
	$("#dog-ear").prependTo($('body'));
	$("#dog-ear").hover(
		function(){
			$(this).animate({
				left: '0'
			});
	},function(){
	$(this).animate({
				left: '-10px'
			});
	});
	
	ShowMe();
	function ShowMe() {
		setInterval(function() {
			$("#dog-ear").animate({
				left: '-10px'
			});
		},5000);

	}


});
