var send_data = function(d,a,callback){
    $.ajax({
        type: "POST",
        url: a,
        data: d,
        async: true,
        dataType: 'json',
        success: function(data){
              if (callback != undefined && typeof callback == 'function') {
              callback(data);
              }
        },
        failure: function() {}
    });
};

var urlgo = function(url) {
	document.location.href = url;
};
var qtipper = function(selector, content) {

$(selector).qtip({
    content: content,
    position: {
        corner: {
            target: 'topRight',
            tooltip: 'bottomLeft'
        }
    },
    style: { 
        width: 200,
        tip: 'bottomLeft',
        name: 'blue'
    }	
});	
};

var formdoc = function(dom) {
	this.obj = dom;  
};

formdoc.prototype.submit = function() {
	$dom = this.obj;
};

formdoc.prototype.change = function() {
	$dom = this.obj;

	// clean up the text when clicked on the text area 
	$('input',$dom).each(function(){
		switch(this.type) {
			case 'text':
				var $old = this.title;
				$(this).focus(function(){
					if($old == this.value) {
						$(this).css({'border':'1px solid #aaa','color':'#000'});
						this.value = '';
						$('.input_'+this.name).fadeIn();
					}
				});
				
				$(this).blur(function(){
					if(this.value == '') {
						this.value = this.title;
						$('.input_'+this.name).fadeOut();
					}
				});
				break;
		}
	});

	$('textarea',$dom).each(function(){
		var $old = this.title;
		$(this).focus(function(){
			$(this).css({'border':'1px solid #aaa','color':'#000'});
			if($old == this.value) {
				this.value = '';
			}
		});
		
		$(this).blur(function(){
			if(this.value == '') {
				this.value = $old;
			}
		});
	});
};
