$(document).ready(function() {
    var popinPoll = {
        init:function(){
            $('body').prepend('<div id="popPoll"></div>');
            $('#popPoll').load('popinpoll.php',{},
		     function(){
		        popinPoll.showPopin();
		    });
        },
        showPopin:function(){
            $('#questpopinMaskWrapper').show();
            if(isIE6) {
                PNGKiller('questpopinMaskWrapper')
            }
            $('#questpopin a').click(function(){
                if($(this).hasClass('openpunder')){
                    popinPoll.showPopunder();
                } else {
                    // do nothing
                }
                $('#popPoll').html('');
                return false;
            });
        },
        showPopunder:function(){
            if(lg == 'fr') {
                win2 = window.open("http://agency.dcm5.com/bin/usurvey?key=ED780D056592F5FF2683CB5804A07077&lang="+lg+"&country="+country+"&market="+market+"","WebPoll","scrollbars=no,resizable=no,toolbar=no,menubar=yes,status=yes,location=no,left=85,top=20,height=718,width=593");
            } else if (lg == 'en') {
                win2 = window.open("http://agency.dcm5.com/bin/usurvey?key=95A0AB3DB2EEF4B92683CB5804A07077&lang="+lg+"&market="+market+"","WebPoll","scrollbars=no,resizable=no,toolbar=no,menubar=yes,status=yes,location=no,left=85,top=20,height=718,width=593")
            } else if (lg == 'sp') {
                win2 = window.open("http://agency.dcm5.com/bin/usurvey?key=5E468DDEFB87BEFF2683CB5804A07077&lang="+lg+"&market="+market+"","WebPoll","scrollbars=no,resizable=no,toolbar=no,menubar=yes,status=yes,location=no,left=85,top=20,height=718,width=593")
            }
            win2.blur();
            window.focus();
        }
    };
    var webpoll = $.cookie('webpoll');
    var cookieManagement = {
    	init:function(){
    		$.cookie('webpoll', 'yes',{ expires: 3650 });
    		if(webpoll == null){
    			//popinPoll.init();
    		} else if(webpoll == 'yes'){
    		    // do nothing
    		}
    	}
    };
    cookieManagement.init();
});

