	jQuery(document).ready(function(){
		
		ini();
	});
	
	// Global Objects
	var $marketing = {};
	$marketing.config = {};
	
	// Global Functions
	function ini() 
	{
		if ($('.dataTable_ss').length > 0)
		{
			$('.dataTable_ss').datatable_ajax($marketing.config.datatable).fnSetFilteringDelay(500);
		}
		
		// Fix form placeholders.
		if (!('placeholder' in document.createElement('input'))){
			$('input, textarea').filter(function(i){ return !!$(this).attr('placeholder'); }).each(function(i,el){
				var label = $(el).siblings('label')
					.filter(function(i){return $(this).attr('for') == $(el).attr('id')});
					
				if (label.length == 1){
					label.addClass('label_inline');	
				}
				else{
					label = $('<label>')
						.attr('for', $(el).attr('id'))
						.text($(el).attr('placeholder'))
						.addClass('label_inline');
					$(el).before(label);
				}
				
				label.click(function(event){
					$(el).focus();
				});
				
				// For auto-fill detection.
				var poll_first_entry = function(){
					if ($(el).val().length){
						$(el).trigger('first_entry');
						clearInterval($(el).data('first_entry_timer'));
						$(el).removeData('first_entry_timer');
					}
				};
				
				$(el)
					.focus(function(event){
						label.hide();
					})
					
					.blur(function(event){
						$(el).val().length || label.show();
					})
					
					.bind('first_entry', function(){
						$(this).unbind('first_entry');
						label.hide();
					})
					
					.data('first_entry_timer', setInterval(poll_first_entry, 50));
			});
		}
	}
	
	function isset(node)
	{
		if (typeof(node) != "undefined")
			return true;
		else
			return false;
	}
	
	function get_response(json)
	{
		var rsp = json.rsp;

		if (isset(rsp.msg.notify))
		{
			$.platform_notify({
				status: rsp.stat,
				data: rsp.msg.notify
			});
		}

		if (rsp.stat == 'success')
		{
			return rsp;
		}
		
		else if (rsp.stat == 'failure')
		{
			return rsp;
		}

		return {};
	}	
	
	function is_ie6()
	{
		if ( $.browser.msie === true && $.browser.version === '6.0' )
			return true;
		else
			return false;
	}
	
	(function($) {
		
		$.fn.get_id = function()
		{
			return $(this).attr('id').replace(/[a-z-_]/ig, "");
		}
	
		$.fn.get_class_id = function()
		{
			return $(this).attr('class').replace(/[a-z-_\s]/ig, "");
		}
	
	})(jQuery);
