if(typeof(WAPGEN)!="undefined"||!WAPGEN)
{
    var WAPGEN =
    {
        // Constants
        baseUrl  : "http://www.wap-gen.com/",
        helpFile : "help?query=",
		
		// Get location
		GetLocation : function() { return document.location.href; },

        // Create dialog
        CreateDialog : function( url )
        {
            // Remove any existing dialog
            if( $("#d") ) { $("#d").remove(); };

            // Create dialog
            $("body").append( "<div id=\"d\"></div>" );

            if( $("#d") )
            {
                $("#d").dialog({
                    modal       : true,
                    width       : 500,
                    overlay     : { opacity: 0.4, background: '#000' },
                    dialogClass : "wapGenOverlay roundedBorders",
                    autoOpen    : false,
                    center      : true,
                    resizable   : false
                });

                $.ajax({
                    type    : "GET",
                    url     : url,
                    cache   : true,
                    async   : true,
                    success : function(html)
                    {
                        $("#d").html( html );
                        $("#d").dialog( "option", "position", "center" );
                        $("#d").dialog( "open" );
                    },
                    error   : function() {  }
                });
            };
        },

        // Open Help
        OpenHelp : function( strHelpSection )
        {
            var strUrl = WAPGEN.baseUrl + WAPGEN.helpFile + strHelpSection;
            WAPGEN.CreateDialog( strUrl );
        },
		
		// Show payments
		ShowPayments : function()
		{
			var arrPC;
			if( ( arrPC = $("div[id^=paymentMethods]") ).length > 0 ) {
				arrPC.each(function(){$(this).show();});
			};
		},
		
		// Hide all opened video tutorials
		HideVideoTutorials : function()
		{
			var arr;
			if( ( arr = $("div[id^=video_]") ).length > 0 )
			{
				arr.each(function(){ $(this).hide(); });
			};
		},
		
		// Open video tutorial
		InitVideoTutorials : function()
		{
			var arr;
			if( ( arr = $(".videoList li") ).length > 0 )
			{
				arr.click(function(){
					var videoTitle = $(this).find("h2");
					var videoWrapp = videoTitle.next();
					WAPGEN.HideVideoTutorials();
					videoWrapp.show();
				});
			};
		},
		
		// Initialization
		Init : function()
		{
			if( WAPGEN.GetLocation().match( /#renew/ ) )
			{
				WAPGEN.ShowPayments();
			};
			WAPGEN.InitVideoTutorials();
		}
    };
	
	$(document).ready(function(){
		WAPGEN.Init();
	});
};