///////////////////////////////////////////////////////\\
///////////////////////////////////////////////////////\\
//***************************************************\\\\
//*                fullad popup v1.0                *\\\\
//*               www.expBuilder.com                *\\\\
//*             Auther: Ahmed Elkadrey              *\\\\
//*               elkadrey@gmail.com                *\\\\
//***************************************************\\\\
///////////////////////////////////////////////////////\\
///////////////////////////////////////////////////////\\

jQuery.fullad = function (target, options)
{
     var Config = {
                     effects        : true,
                     timeout        : 5,
                     backgroundcolor: "#ffffff",
                     color          : "#000000",
                     buttonskip     : "skip.png",
                     target         : "",
                     waittext       : "Please wait ..."
                  };

     if(options)
     {
		    jQuery.extend(Config, options);
	 };
     Config.target = target;
     var bodydone = false;


     if(Config.target)
     {
         $(document).ready(function()
         {
           if(!$("#fullads_expBuilder_com").html())
           {
               var html = '<div id="fullads_expBuilder_com" style="position: absolute;z-index: 1000;display: none;">';
               html     += '<div class="fullads_expBuilder_com_header"><div></div></div>';
               html     += '<iframe marginheight="0" marginwidth="0" scrolling="auto" width="100%"></iframe>';
               html     += '</div>';

               $("body").append(html);

               var width = screen.width;

               var height = $(document).height();
               var height2 = screen.height - 250;
               $("#fullads_expBuilder_com").css({'width':width, 'height': height,'top':0, 'left':0});
               $("#fullads_expBuilder_com").find('iframe').css({'height': height2});
               if(Config.effects)
               {
                  $("#fullads_expBuilder_com").fadeIn('slow');
               }
               else
               {
                  $("#fullads_expBuilder_com").show();
               }
               $("body").css('overflow','hidden');
               $("#fullads_expBuilder_com").css({'background-color':Config.backgroundcolor, 'color': Config.color}).find(".fullads_expBuilder_com_header div")
               .css({'height':'50px', 'font-size':'18px', 'font-weight':'bold', 'float':'right', 'padding':'10px'}).html(Config.waittext + "<br /><span></span>");

               if((Config.target).substr(0, 4) == 'http')
               {
                  $("#fullads_expBuilder_com iframe").attr('src', Config.target);
               }
               else
               {
                  $(Config.target).hide();
                  $("#fullads_expBuilder_com iframe").load(function()
                  {
                        $(this).contents().find("body").html($(Config.target).html());
                        bodydone = true;
                  });

               }
               var counting = Config.timeout;
               var timing = window.setInterval(function()
               {
                    if(bodydone && counting >= 0)
                    {
                        $("#fullads_expBuilder_com").find(".fullads_expBuilder_com_header div span").html(counting + " Seconds");
                        counting --;
                    }
                    else if(counting < 0)
                    {
                       window.clearInterval(timing);
                       $("#fullads_expBuilder_com").find(".fullads_expBuilder_com_header div").html('<a href="javascript: void(0);"><img border="0" src="' + Config.buttonskip + '" /></a>');
                       $("#fullads_expBuilder_com").find(".fullads_expBuilder_com_header div a").click(function()
                       {
                            $("#fullads_expBuilder_com").fadeOut("", function()
                            {
                                $(this).remove();
                                $("body").css('overflow','auto');
                            });
                       });
                    }
                    else if(!$("#fullads_expBuilder_com iframe").contents().find("body").html())
                    {
                         window.setTimeout(function()
                         {
                             $("#fullads_expBuilder_com iframe").contents().find("body").html($(Config.target).html());

                             bodydone = true;
                         }, 1000);
                    }
               }, 1000);

           }
           else
           {
                alert("AD Already displayed, You can't set more than one");
           }
         });
     }
     else
     {
        alert("You must set the Target ad to Display");
     }
}

