
	/////////////////////////////////   functions.js  /////////////////////////////
	/////////
	/////////		for: Austin Insurnace Agency
	/////////		1-10-2010  -
	
		
	
	// /global 
	
	
	
	
	//////     AIA specific Vars...
	
	var bAiaMain = false;
	
	///// / aia
	
	
	
	
	
	
	/////////////////////////     mFUNCTIONS  //////////////////////
	
	
	
	
	
	function changePic(img_name, img_src){
		document.getElementById(img_name).src=img_src;
	}
	
	
	//TEMP
	function changeMain() {
		bAiaMain = !bAiaMain;
		
		if(bAiaMain) {
			document.getElementById('iTemp').src = 'img/temp2_.jpg';
		} else {
			document.getElementById('iTemp').src = 'img/temp2.jpg';
		}
		
	}
	//TEMP
	
	
	
	
	
	
	
	function ranNum(uNum) {
		var nRan = new Number();
		uNum = Number(uNum);
		//generate random between 1 and uNum
		nRan=Math.floor( (Math.random()*uNum) + 1);
		return nRan;
	}
	
	
	
	function showAiaTAS(nDiv, nMax) {
		aiaTASnumShowed++;		
		if(bAiaTASstarted) {
			nDiv++;
			if(nDiv >= nMax+1) {
				nDiv = 1;; 
				eval("this.document.getElementById('aiaTAS1').style.display = ''" );
				eval("this.document.getElementById('aiaTAS" + nMax + "').style.display = 'none'" );
			} else {
				eval("this.document.getElementById('aiaTAS" + nDiv + "').style.display = ''" );
				eval("this.document.getElementById('aiaTAS" + (nDiv-1) + "').style.display = 'none'" );
				
			}	
			tAiaTAS = eval( "setTimeout('showAiaTAS(" + nDiv + ", " + nMax + ")',6000)" ); 
		} else {
			bAiaTASstarted = true;
			document.getElementById('aiaTAS1').style.display = 'none';
			document.getElementById('aiaTAS' + nDiv).style.display = '';			
			tAiaTAS = eval( "setTimeout('showAiaTAS(" + nDiv + ", " + nMax + ")',500)" ); 
			//
		}		
	}
	
	
	function stopAiaTAS(nDiv) {
		clearTimeout(tAiaTAS);
	}

		
				
		
		
	//handles the checkboxes and using words to interact with.
	function clickCB(strCB) {
		//document.getElementById(strCB).focus()
		if(document.getElementById(strCB).checked) {
			document.getElementById(strCB).checked = false;
		} else {
			document.getElementById(strCB).checked = true;	
		}	
		///document.getElementById(strCB).Blur()
	}









	
	function showTpic(nImgs, sSection) {
	
		// 
		//		only goes for Nine images		//
		//		
		var nRan = new Number();
		var sTemp = new String();
		nImgs = Number(nImgs);
		
		
		for (var i = 0; i < nImgs; i++) {
			bTemp = true;
			nRan = Math.floor( (Math.random()*nImgs) + 1);			
			sTemp = aAiaT.toString();
			
			
			while (sTemp.indexOf(String(nRan)) >= 0) { 
				nRan = Math.floor( (Math.random()*nImgs) + 1);							
			}
			aAiaT[i] = String(nRan);
			
		
		} 		
		
		
		
		startTpic(nImgs, sSection);
		
	}
	
	
	
	function startTpic(nImgs, sS) {
			stopTpic();
			slideTpic(nImgs, sS);
	}
	
	function stopTpic() {
		clearTimeout(tAiaTpic);
	}
	
	
	
	
	function slideTpic (nImgs, sS) {
					
			//alert( aAiaT.toString() )
			if (nAiaTcounter == nImgs) {nAiaTcounter = 0;}

			document.getElementById('aiaTpic').src = 'img/' + sS + '_right_' + aAiaT[nAiaTcounter] + '.jpg';
			
			nAiaTcounter++ ;
			
			tAiaTpic = setTimeout("slideTpic(" + nImgs + ", '" + sS + "')",20000) ; 
			
			
	}
	
	
	function checkZipCode(sBoxName) {
		sValue = String(document.getElementById(sBoxName).value);
		if(verifyZipCodeLength(sBoxName, sValue)){
			if(verifyZipCodeMass(sBoxName, sValue)){
				return true;
			}else {
				return false;
			}
		} else {
			return false;
		}
		
	}
	  
	
	function verifyZipCodeLength(sBoxName, sZip) {
		if (sZip.length < 5) {
			alert("the Zip-code length needs to be five digits and valid in the state of Massachusetts");
			document.getElementById(sBoxName).focus();
		} else {
			return true;
		}
	}
	
	function verifyZipCodeMass(sBoxName, sZip) {
		sAlert = "The zip-code value is not valid in the state of Massachusetts. Please check the number prior to hitting the proceed button.";
		nTemp = new Number(sZip);
				
		if(sZip == "05501" || sZip == "05544") {
			return true;
		} else if (nTemp >= 1001 && nTemp <= 2792) {
			return true;
		} else {
			alert(sAlert);
			return false;
		}
		
	}
	
	
	
	function verifyBasicValue(sBox, sValueNot, sAlert)  {	
					
					if(document.getElementById(sBox).value.charCodeAt(0) == 32 && document.getElementById(sBox).value.length == 1){
						//sends error if the first character is a [space] 
						//need to adjust so that it strips each and every leading " " before it checks values.....
						alert(sAlert);
						document.getElementById(sBox).value = '';
						document.getElementById(sBox).focus();
						return false;
					} else if(!document.getElementById(sBox).value == sValueNot) {
						return true;
					} else {
						alert(sAlert);
						document.getElementById(sBox).focus();
						return false;		
					}
						
	}	
	
	
	
	function verifyBasicDropDown(sBox, sValueNot, sAlert) {
	
			if(document.getElementById(sBox).value == sValueNot) {
					alert(sAlert);
					document.getElementById(sBox).focus();
					return false;
					
			} else {
					return true;		
			}
	}
	
	
	function checkEmailBox(str) {
				//quick check for a . and an @ that are at the least not the first character...
				return (str.indexOf(".") > 0) && (str.indexOf("@") > 0);
			}
	

	
	
	
	
	function showHideADiv(sDiv, sDisplay) {

		if (document.all) { //IS IE 4 or 5 (or 6 beta)
			eval( "document.all." + sDiv + ".style.display = sDisplay");
		}
		if (document.layers) { //IS NETSCAPE 4 or below
			document.layers[sDiv].display = sDisplay;
		}
		if (document.getElementById && !document.all) {
			hza = document.getElementById(sDiv);
			hza.style.display = sDisplay;
		}
	}



	function showByDropDown(sDivSection, bVal){
		if(bVal == 1) {
			showHideADiv(sDivSection, 'block');
		} else {
			showHideADiv(sDivSection, 'none');
		}
	}
	
	
	
	
	function textCounter( field, countfield, maxlimit ) {
		  if ( field.value.length > maxlimit )
		  {
		    field.value = field.value.substring( 0, maxlimit );
		   // alert( 'Textarea value can only be 255 characters in length.' );
		    return false;
		  }
		  else
		  {
		    ////countfield.value = maxlimit - field.value.length;
		  }
		}
	
	
	
	
	///////////////// / mFUNCTIONS
	
	





