$(document).ready(function(){

  
  
});

$.fn.qtip.styles.info = { 
   background: '#FFF',
   color: '#797196',
   fontSize: '0.75em',
   classes: { content: "info" },
   border: {
      radius: 5
   },
   name: 'green' 
}

$.fn.qtip.styles.error = { 
   background: '#FFF',
   color: '#AB3535',
   fontWeight: 'bold',
   border: {
      radius: 5
   },
   classes: { content: "error" },
   tip: 'bottomLeft',
   name: 'red' 
}

$.fn.qtip.styles.success = { 
   background: '#FFF',
   color: '#797196',
   fontWeight: 'bold',
   border: {
      radius: 5
   },
   classes: { content: "success" },
   tip: 'bottomLeft',
   name: 'green' 
}

function errorTip(el, target, text, tipPos, targetPos){

  el.qtip({
    content: {
      text: text,
      prerender: true
    },
    hide: { when: { event: 'unfocus' } },
    show: { delay: 0, ready: true, when: { event: 'load' } },
    style: {
      name: "error",
      width: "auto",
      tip: tipPos
    },
    position:{
      target: target,
      corner: {
        target: targetPos,
        tooltip: tipPos
      }
    }
  });
  el.click(function(){
    $(this).qtip("hide");
  });
}

function infoTip(el, target, text, tipPos, targetPos, width, show, hide){

	  el.qtip({
	    content: {
	      text: text,
	      prerender: true
	    },
	    show: (show === undefined) ? { delay: 0 } : show,
	    hide: hide,
	    style: {
	      name: "info",
	      width: width,
	      tip: tipPos
	    },
	    position:{
	      target: target,
	      corner: {
	        target: targetPos,
	        tooltip: tipPos
	      }
	    }
	  });
	  el.click(function(){
	    $(this).qtip("hide");
	  });
	  if (hide && hide.when && hide.when.event && hide.when.event == 'mouseover') {
		  el.attr("qtipid", el.qtip("api").id);
		  $("[qtip=" + el.qtip("api").id + "]").mouseover(function(){
			  $(this).fadeOut();
		  });
	  }
	}

function successTip(el, target, text, tipPos, targetPos){

	  el.qtip({
	    content: {
	      text: text,
	      prerender: true
	    },
	    show: { delay: 0 },
	    hide: { when: { event: 'unfocus' } },
		show: { delay: 0, ready: true, when: { event: 'load' } },
	    style: {
	      name: "success",
	      width: "auto",
	      tip: tipPos
	    },
	    position:{
	      target: target,
	      corner: {
	        target: targetPos,
	        tooltip: tipPos
	      }
	    }
	  });
	  el.click(function(){
	    $(this).qtip("hide");
	  });
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
