/*-----------------------------
* Ph.Global Functions Version 1.0.9
* by Craig Wilson, Ph.Creative (http://www.ph-creative.com)
* Copyright (c) 2010 Ph.Creative Ltd.
* Last updated 17/05/2010
-----------------------------*/

jQuery(function(){
	//Body Load
	jQuery(".MMDataCaptureForm_ErrorTD span").removeAttr("style");
	jQuery(".MMDataCaptureForm_SubmitButton").removeAttr("value");
	jQuery(".MMDataCaptureForm_Table textarea").each(function(){jQuery(this).parent().addClass("MMDataCaptureForm_TextArea");});
	jQuery("#lnkLogOut").click(function(){var answer=confirm("Are you sure you want to logout?");if(answer){return true;}else{return false;}});
	
	//Functions
	jQuery.fn.addIDs=function(){jQuery(this).attr("id",jQuery(".Phuse_Breadcrumb_CurrentPage_Header_Link").text().toLowerCase().replace(" ","-"));}
	jQuery.fn.noText=function(){jQuery(this).removeAttr("value");}
	jQuery.fn.fullLink=function(link){var thisElem=jQuery(this);thisElem.css("cursor","pointer").click(function(){if(link){window.location=jQuery("a:nth-child("+link+")",this).attr("href");}else{window.location=jQuery("a",this).attr("href");}});}
	jQuery.fn.vertTable=function(){jQuery("tr",this).each(function(){var $this=jQuery(this);jQuery(".MMDataCaptureForm_Input",$this).removeAttr("style").before(jQuery(".MMDataCaptureForm_LabelTD",$this).text()+"<br/>").wrap('<div class="mm_input"></div>');jQuery("textarea",$this).parent().removeClass("mm_input").addClass("mm_textarea");});jQuery(".MMDataCaptureForm_LabelTD,.MMDataCaptureForm_ButtonEmptyTD",this).hide();}
	jQuery.fn.pagination=function(options){var defaults={speed:1000,pageText:"Page",perPage:5};var options=jQuery.extend(defaults,options);var randomNum=Math.ceil(Math.random()*9999999);var thisClass="paging_container_"+randomNum;var pagingClass="paging_"+randomNum;jQuery(this).addClass(thisClass);var thisItem=jQuery("."+thisClass);var thisChild=thisItem.children();var totalItems=thisItem.children(":visible").length;thisItem.after('<div class="paging '+pagingClass+'"></div>');if(totalItems>options.perPage){thisChild.css("position","relative");var pagingItems = Math.ceil(eval(totalItems/options.perPage));var countItems=1;jQuery("."+pagingClass).html("<strong>"+options.pageText+" </strong> ");while(countItems<=pagingItems){
 jQuery("."+pagingClass).append('<span id="'+countItems+'">'+countItems+'</span>');countItems++;}jQuery("."+pagingClass+" span:first").addClass("active");
 jQuery("."+pagingClass+" span").click(function(){var thisSpan=jQuery(this);jQuery("."+pagingClass+" span").removeClass("active");thisSpan.addClass("active");var pageNumber=thisSpan.attr("id")-1;thisChild.animate({"top":"-"+eval(pageNumber*thisItem.height())+"px"},options.speed);});}}
});
