/*
Description: Engine
Author: wpworks.net
Author URI: http://wpworks.net
*/



var WPW = WPW || {}; 
WPW.cfg = {};


WPW.windowWidth = 0;
WPW.windowHeight = 0;

WPW.cW = 0;
WPW.cH = 0;

WPW.window;
WPW.body;
WPW.main_node;
WPW.container;
WPW.pageContent;

var windowReady = function(){
	WPW.body = $('body');
	WPW.window = $(window);
	
	if ( $.browser.msie) {
		WPW.IE = true;	
		if($.browser.version < 9) WPW.IE8 = true;
		if($.browser.version < 8) WPW.IE7 = true;
	}
	
	var engine = new WPW.Engine();


    WPW.body.bind('Refresh_Size', function(){
        WPW.windowResize();
    });

    $(window).resize( function() {
         WPW.resizeEvent();
    });

	var logow = $('#logo-white');
	logow.load(function(){
		WPW.windowResize();
	});
    
    WPW.resizeEvent();
    WPW.windowResize();
    
};

WPW.Core.register("windowReady");

WPW.Engine = function(){
	var main = this;


}

WPW.windowResize = function(double_resize) {
    WPW.windowWidth = WPW.window.width();
    WPW.windowHeight = WPW.window.height();
    WPW.cW = WPW.windowWidth;
    WPW.cH = WPW.windowHeight;
    // if(WPW.cW > max_site_width)WPW.cW = max_site_width;
    // if(WPW.cH > max_site_height)WPW.cH = max_site_height;
    // if(WPW.cW < min_site_width)WPW.cW = min_site_width;
    // if(WPW.cH < min_site_height)WPW.cH = min_site_height;
    


    WPW.body.trigger('RefreshSize');
}


WPW.resizeTimer = 0;
WPW.resizeEvent = function(){
	clearInterval(WPW.resizeTimer);
	WPW.resizeTimer = setInterval(function(){
		WPW.body.trigger('Refresh_Size');
		clearInterval(WPW.resizeTimer);
	}, 100);
}


//
// DEBUG CONSOLE
//
WPW.console_status = -1;
WPW.debug_console;
WPW.enable_console = true;
WPW.console = function($msg, $break, $clear){
	if(WPW.console_status < 0){
		if($("body").hasClass("debug") || WPW.enable_console){
			WPW.console_status = 1;
			WPW.debug_console = $('<div id="console"></div');
			$('body').prepend(WPW.debug_console);
		} else {
			WPW.console_status = 0;
		}
	}
	if(WPW.console_status ==  1){
	 	if($clear)WPW.debug_console.html("");
		if(WPW.debug_console.html().length > 300)WPW.debug_console.html("");
		var _break = " | ";
		if($break)_break = "<br />"
	 	WPW.debug_console.html(WPW.debug_console.html() + $msg + _break);
	}
}

