/********************************************************************************************************************//*                                             MAIN WEBTRAC JAVSCRIPT                                               *//*                                               VERMONT SYSTEMS INC                                                *//********************************************************************************************************************///jQuery Document Load Functions$(function(){	    //Menu Operation and Options	$('#menu ul').superfish({		hoverClass:    'menu-hover',      		pathClass:     'menu-path', 	                    		delay:         500,                		animation:     {height:'show'}, 		speed:         1,				autoArrows:    false,              		dropShadows:   true,              		disableHI:     false             	}).find("ul").bgIframe({opacity:false});		$(CommonCalls);});function CommonCalls() {	//Do not cache Ajax Pages	$.ajaxSetup({ cache: false });	$.blockUI.defaults.baseZ = 99999;    $.blockUI.defaults.overlayCSS = {backgroundColor: '#000',opacity:0.5};		//Close Error Messages	$("#message .message-close").bind("click.errormsg",function(){$("#message").removeClass("show").hide();});		//Date Specifics	$("input.date-fmt").not("input:disabled").datePicker({startDate:'01/01/1985'});	$("input.date-fmt").mask(dateFormat,{placeholder:" "});	$("input.date-fmt").not("input:disabled").dateFormatCheck({dateFormat:Date.format});		//For ALL tables on the even row will add the class "even" and for odd rows "odd"	$("table tr:nth-child(even) td").not('table.no-evenodd tr:nth-child(even) td').addClass("even");	$("table tr:nth-child(odd) td").not('table.no-evenodd tr:nth-child(odd) td').addClass("odd");		//Cross used to close a parent div tag	$(".close").click(function() {		$(".close").parent('div').hide(500);		$("#overlay").hide();	});	//Attach validate form to all forms with class "validateForm"	$(".validateForm").validate({		rules: {			xxemail: {				required: function() {						if ($("#xxreply1").length > 0) {							return $("#xxreply1").is(":checked");						} else return true;					},				email:true			},			xxphone: {				required: function() {						if ($("#xxreply2").length > 0) {							return $("#xxreply2").is(":checked");						} else return true;					}			}        },				submitHandler: function(form) {			//$.blockUI();			form.submit();			return false;		}	});		$(".validateForm input").focusout(function(){$(this).valid();});	$(".validateForm select").focusout(function(){$(this).valid();});		//Adds the required class to any label that preceeds an input with class required	$("input.required").prev("label").addClass("required");		//PHONE MASKS	$("input.phone-fmt").mask(phoneFormat,{placeholder:"X"});		//MISC MASKING FORMATS	$(".credit").mask("9999999999999999",{placeholder:" "});	$(".zip").mask("999999",{placeholder:" "});	$(".ssn").mask("999-99-9999",{placeholder:" "});		//VSI Specific Classes	$(".num").numeric();	$(".int").numeric();	$(".dec").numeric({allow:"."});	$(".char").alphanumeric();		//Language List	$("#languages select").change(function(){		$("#languages").submit();	});			//ColorBox AJAX loading class	$(".ajaxLoad").colorbox({overlayClose:false,width:'800px',onComplete: CommonCalls});		//Ajax a form that loads into colorbox with vaildation.	$(".ajaxForm").validate({		submitHandler: function(form) {			$.blockUI();			$(form).ajaxSubmit({				success: function(html) {				    $.unblockUI();					$.fn.colorbox({html:html,open:true,overlayClose:false,width:'800px',onComplete: CommonCalls});				}			});		}	});	//add cim number to link for forms	$(".cim-link").click(function(ev){		ev.preventDefault();		var cimnum  = 0;		if ($("#xxcim").val() > 0) {cimnum = $("#xxcim").val();}		var newlink = $(this).attr("href") + '&xxcim=' + cimnum;		location.replace(newlink);	});		//Print content block	$("a.print").click(function(ev){		ev.preventDefault();		printObj($(this),"#content");	});			//Reset Form	$(".reloadForm").click(function(){		var $parid  = $(this).parents("form");		$parid.get(0).reset();	});		//Message Box Popup	if ($("#message-box h1").text() != "" || $("#message-box p").text() != "") {		messageBoxDefault();	}		$(".time-change select").change(function(){		var timeid  = $(this).parent("li.time-change").attr("id");		var inputid = timeid.split("-")[0];		var hourval = 0;		var minval  = 0;		var ampmval = "";		var timeval = 0;				$("#" + timeid + " select").each(function(i,v){			if (i == 0) { hourval = $(v).val(); }			if (i == 1) { minval = $(v).val(); }			if (i == 2) { ampmval = $(v).val(); }		});				if (inputid != "") {			timeval = getintTime(hourval,minval,ampmval);			$('#' + inputid).val(timeval);		}	});		/* WISHLIST FEATURES */	$(".wishlist").click(function(ev){		ev.preventDefault();		var newurl = $(this).attr('href');		var $wish  = $(this);		var rmvrow = false;		var setcls = true;				if ($wish.is(".clear-row")) {rmvrow = true;}		if ($wish.is(".button")) {setcls = false;}				$.blockUI();		$.ajax({			type: "POST",			url: newurl,			success: function(html) {				$.unblockUI();				var status = html.split("|")[0];				var items = html.split("|")[1];				if (status == "Added") {					if (setcls) {						$wish.removeClass('onwish-icon').removeClass('wish-icon');						$wish.addClass('onwish-icon');					}					if (rmvrow) {$wish.parents('tr').remove();}				}				else if (status == "Removed") {					if (setcls) {						$wish.removeClass('onwish-icon').removeClass('wish-icon');						$wish.addClass('wish-icon');					}					if (rmvrow) {$wish.parents('tr').remove();}				} else {					if (setcls) {						$wish.removeClass('onwish-icon').removeClass('wish-icon');						$wish.addClass('wish-icon');					}					if (rmvrow) {$wish.parents('tr').remove();}				}								if (items == null || items == "") {items = "0"};				if (items == null || items == "" || items == "0") {					$("#wish-list").remove();					$(".extra-controls").remove();					$("#wish-list-empty").removeClass('hide');				}								$("#wishlist strong").html("(" + items + ")");							},			error: function(errObj,errStatus,errThrown) {				$.unblockUI();				alert('An Error Occurred when adding to the WishList. Please contact the webmaster.');			}		});	});			//Icon Tooltip	$('.tooltips[title]').tooltip({tipClass:'status-tooltip',offset:[-5,0],opacity:0.8,predelay:10});			//Focus Class	$('.focus-now').focus();		//Waiver Print	$('.waiver-print').click(function(ev){		ev.preventDefault();				var waivrText = $(this).attr('rel').split('|')[0];		var waivrChng = $(this).attr('rel').split('|')[1];				if (waivrText) {printObj($(this),waivrText);}		if (waivrChng) {$(waivrChng).val('yes');}		$(waivrChng).valid();		return false;	});		/* MIN/MAX OPTION */	$('.minmax').each(function(i,v){		$(v).removeClass('maximize').removeClass('minimize').unbind();				if ($(v).nextAll("ol").not('.submit-list').not('.html-hide').is(':hidden')) {			$(v).addClass('maximize');		} else {			$(v).addClass('minimize')		}				$(v).click(function(){			var $item = $(this).nextAll("ol").not('.submit-list').not('.html-hide');						if ($item.is(":hidden")) {				$item.removeClass('hide').show();				$(this).addClass('minimize').removeClass('maximize');			} else {				$item.addClass('hide').hide();				$(this).addClass('maximize').removeClass('minimize');			}		});	});			/* Self change submit for form */	$('.self-change').change(function(){		if ($(this).valid()) {			$.blockUI();			$(this).submit();		}	});		/* Used for hiding/showing data */	$('select.option-open').each(function(){		var $this = $(this);				openOption($this);				$this.change(function(){			openOption($(this));				});	});		/* Hide something after a set amount of time (15 Seconds) */	$('.timeout-hide').fadeIn("slow").animate({opacity:1.0},15000).fadeOut("slow");		$('.blockui').click(function(){$.blockUI();});	}//Block UI Popup Boxfunction messagePopup(butnText) {	$.blockUI({message: $("#message-box"),bindEvents: true,css: {border:'0'}});	$("#message-box span").html(butnText);}//Default BlockUI Message Boxfunction messageBoxDefault() {	var butnCont   = '<input id="msg-cont" type="button" value="' + buttonOK + '" />';	messagePopup(butnCont);	$("#msg-cont").click(function(){$.unblockUI();clearMessage();});}//Clear Message Popup Boxfunction clearMessage(){	$("#message-box").removeClass();	$("#message-box h1").text("");	$("#message-box p").text("");	$("#message-box span").html("");}//Used to create a time value to be passed between programsfunction getintTime(hr,min,ampm){	var inithour = 0;	var inittime = 0;	if (parseInt(hr) != 12 && ampm == "P") {		inithour = parseInt(hr) + 12;	} else if (parseInt(hr) == 12 && ampm == "A") {		inithour = 0;	} else {		inithour = parseInt(hr);	}	inittime = (inithour * 3600) + (parseInt(min) * 60);	return inittime;}//Load an ajax page with type of ajax request,url, parameter string and what to attach the response tofunction loadAjax(ajaxType,ajaxURL,ajaxString,ajaxAttach) {	$.blockUI();	$.ajax({		type: ajaxType,		url: ajaxURL,		data: ajaxString,		success: function(html) {			$.unblockUI();			$(ajaxAttach).html(html);			CommonCalls();		},		error: function(errObj,errStatus,errThrown) {			$.unblockUI();			$(ajaxAttach).html("Error Object: " + errObj + "<br />Error Status: " + errStatus + "<br />Error Thrown: " + errThrown);			CommonCalls();		}	});}//Print Functionfunction printObj(prntObj,prntData) {	var disp_setting  = "toolbar=yes,location=no,directories=yes,menubar=yes,"; 		disp_setting += "scrollbars=yes,width=650, height=600, left=100, top=25";	var printcss      = $(prntObj).attr("rel");			var content_vlue  = $(prntData).html();	var docprint      = window.open("","",disp_setting); 	var objdoc        = docprint.document;	printcss = '<link rel="stylesheet" type="text/css" media="all" href="' + printcss + '" />';		objdoc.open(); 	objdoc.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");	objdoc.write('<html>'); 	objdoc.write('<head>');	objdoc.write('<title>'); 			objdoc.write(document.title);	objdoc.write('</title>');	objdoc.write(printcss);	objdoc.write('</head>');	objdoc.write('<body><div id="content">');			objdoc.write(content_vlue);          	objdoc.write('</div></body>'); 	objdoc.write('</html>');	$(objdoc).find("a").contents().unwrap();	$(objdoc).find(".printRemove").remove();	objdoc.close(); 	docprint.focus();	docprint.print();	return true;}//Needed for cross browser indexOf functionalityif(!Array.indexOf){  Array.prototype.indexOf = function(obj){   for(var i=0; i<this.length; i++){    if(this[i]==obj){     return i;    }   }   return -1;  }}function openOption($obj) {	var thisid  = $obj.attr('id'),		thisval = $obj.val(); 		$('[id^=' + thisid + '-]').each(function(){		$(this).hide();		});		$('[id=' + thisid + '-' + thisval + ']')		.removeClass('hide')		.show();}
