// the hatch JavaScript Document
$(document).ready(function() {
	
			$('.notification').hover(function() {
 				$(this).css('cursor','pointer');
 			}, function() {
 					$(this).css('cursor','auto');
				});

			$('.notification span').click(function() {
                $(this).parents('.notification').fadeOut(800);
            });
			
			$('.notification').click(function() {
                $(this).fadeOut(800);
            });
		

});


// phone formating
function formatPhone(objFormField){
    intFieldLength = objFormField.value.length;
    if(intFieldLength == 3){
         objFormField.value = "(" + objFormField.value + ") ";
         return false;
         }
   if(intFieldLength >= 9 && intFieldLength <= 10){
       objFormField.value = objFormField.value + "-";
       return false;
       }
}


// textfield text counter
function textCounter(field,counter,maxlimit,linecounter) {
	// text width//
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        

	// trim the extra text
	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	}

	else { 
	// progress bar percentage
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	document.getElementById(counter).innerHTML=""+percentage+"%"
	// color correction on style from CCFFF -> CC0000
	setcolor(document.getElementById(counter),percentage,"background-color");
	}
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}

// rods popup
function rodsPopup(popupPath) {
	window.open(popupPath,'name','width=660,height=520,scrollbars=YES');
}

// show hide layers
function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}