
// usage: log('inside coolFunc', this, arguments);
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console) {
      arguments.callee = arguments.callee.caller;
      console.log( Array.prototype.slice.call(arguments) );
  }
};
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});


function checkIE() { // check ie version
	var browse = 9;
	if($.browser.msie) {
		if($.browser.version === "7.0") {
			browse = 7;
		} else if ($.browser.version === "8.0") {
			browse = 8;
		}
	}
	return browse;
}

/* identify */
jQuery.fn.identify = function(prefix) {
	var i = 0;
	return this.each(function() {
		if($(this).attr('id')) return;
		do { 
			i++;
			var id = prefix + '-' + i;
		} while(document.getElementById(id) != null);            
		$(this).attr('id', id);            
	});
};

$(function() {

	/* Placeholder */
	if (!Modernizr.input.placeholder) {	
		$('form').submit(function() {
			$(this).find("input, textarea").each(function() {
				if ($(this).attr("placeholder") !== "" && $(this).val() == $(this).attr("placeholder")) {
					$(this).val("");
				}
			});
		});
		$("input, textarea").each(function() {
			if ($(this).attr("placeholder") !== "" && ($(this).val() == "" || $(this).val() == $(this).attr("placeholder"))) {
				$(this).val($(this).attr("placeholder"));
				$(this).focus(function() {
					if ($(this).val() == $(this).attr("placeholder"))
						$(this).val("");
				});
				$(this).blur(function() {
					if ($(this).val() == "") $(this).val($(this).attr("placeholder"));
				});
			}
		});
	}
	
});
