$(document).ready(function(){swapValues=[];$(".swap_value").each(function(i){$(this).addClass('inactiveSwap');swapValues[i]=$(this).val();$(this).focus(function(){$(this).removeClass('inactiveSwap');if($(this).val()==swapValues[i]){$(this).val("");}}).blur(function(){if($.trim($(this).val())==""){$(this).addClass('inactiveSwap');$(this).val(swapValues[i]);}});});$("#progressIndicator").ajaxStart(function(){$(this).show();});$("#progressIndicator").ajaxStop(function(){$(this).hide();});$(".addAnotherField").click(function(){if(!window.fieldHtml)
{window.fieldHtml=$(this).parent().children(":not(a.addAnotherField, label)");}
window.fieldHtml.clone().addClass('childInput').clearForm().insertBefore(this);});if(typeof console=="undefined")
{window.console={log:function(message)
{if($("#jsDebug"))
$("#jsDebug").append(message+"<br>");}};console.log("using alternate js debugging");}
$('body').ajaxStop(function(){bindInvalidFieldsEvent();});bindInvalidFieldsEvent();});$.fn.pause=function(milli,type){milli=milli||1000;type=type||"fx";return this.queue(type,function(){var self=this;setTimeout(function(){$.dequeue(self);},milli);});};$.fn.clearQueue=$.fn.unpause=function(type){return this.each(function(){type=type||"fx";if(this.queue&&this.queue[type]){this.queue[type].length=0;}});};function toggleCheckboxes(checkboxes)
{checkem=false;if($('#checkAll').attr("checked"))
{checkem=true;}
checkboxTog=$('#checkAll').attr("checked");checkboxes.each(function(){$(this).attr("checked",checkem);});}
function redirect(url)
{window.location=url;return true;}
$.fn.clearForm=function(){return this.each(function(){var type=this.type,tag=this.tagName.toLowerCase();if(tag=='form')
return $(':input',this).clearForm();if(type=='text'||type=='password'||tag=='textarea')
this.value='';else if(type=='checkbox'||type=='radio')
this.checked=false;else if(tag=='select')
this.selectedIndex=-1;else
return $(this).children().clearForm();});};function addToolTip(selector,style,parentSelector)
{$(selector).each(function(){if(parentSelector==null)
var qtipSelector=$(this).parent();else
var qtipSelector=$(this).parent(parentSelector);var tip=$(this).text();qtipSelector=qtipSelector.qtip({'content':tip,'style':{name:style}})})}
function applyAutoComplete(selector,url,options)
{try
{return $(selector).autocomplete(url,options);}
catch(e)
{console.log(e);}}
function autoCompleteformatItem(row){if(row[1]==undefined){return row[0];}
else{return row[0];}}
function insertAtCursor(myField,myValue){if(typeof myField=="string")
myField=document.getElementById(myField);if(document.selection){myField.focus();sel=document.selection.createRange();sel.text=myValue;}
else if(myField.selectionStart||myField.selectionStart=='0'){var startPos=myField.selectionStart;var endPos=myField.selectionEnd;myField.value=myField.value.substring(0,startPos)
+ myValue
+ myField.value.substring(endPos,myField.value.length);}else{myField.value+=myValue;}}
(function($){$.fn.outerHTML=function(){return $('<div>').append(this.eq(0).clone()).html();};})(jQuery);function makeHelpTextBox(selector,style)
{if(selector==null)
selector='.helpBox,.helpbox';$(selector).each(function(){$(this).css('display','none');var content=$(this).text();var elem=$('<span class="help_text_marker">(?)</span>');$(this).replaceWith(elem);elem.qtip({'content':content,'style':{name:style}});});}
function inlineMsg(selector,msg)
{$(selector).hide().html(msg).fadeIn();}
function gAlert(msg,title)
{if(title==undefined)
{title="";}
$("<div title='"+title+"'>"+msg+"</div>").dialog({bgiframe:true,modal:true,buttons:{Ok:function(){$(this).dialog('close');}}});}
function bindInvalidFieldsEvent()
{$("div.error input").unbind("focusin");$("div.error input").bind("focusin",function(){$(this).siblings('div.error-message').fadeOut().remove();$(this).parent().removeClass("error");});}
function invalidateField(fieldId,errorMsg)
{errorElem=$(errorMsg).fadeIn().insertAfter("#"+fieldId);$("#"+fieldId).parent().addClass("error");bindInvalidFieldsEvent();}
function getSelectedRows(tableId)
{ids='';$('#'+tableId+' .tabeSelectors:checked').each(function(){ids=ids+ $(this).attr('value')+';';});return ids;}
String.prototype.ucFirst=function()
{return this.charAt(0).toUpperCase()+ this.substring(1);}
