// WE HAD ISSUES IT APPEARS WITH sup_submit 
var ie4= document.all && navigator.userAgent.indexOf("Opera")==-1;
var ns6= document.getElementById && navigator.userAgent.indexOf("Opera")==-1;
var ns4= document.layers;
var advance=1;
var xpc = 0;
var ignoreForm=0;
var forceProcess = false;
var lp_title = ""; //need to declare to avoid non-fatal error 9/12/05
var lp_type = ""; //ditto, other value is "multiprize" that should be set in layout for lp
var lp_brand = ""; //ditto
var all_good = -2;
var dropdown_status = 0;
var nocache=0;
var currently_running = '';

function showdebug(mssg,user){
   if(nocache==user) alert (mssg);
}

function report_error(err){
   if(nocache!='0'){ alert("jscript error in function "+currently_running+":\n"+err);}
   else{
      var a = new XMLHttpRequest();
      var form_vars = '';
      for(var i = 0;i<document.forms.ms.length;i++){
         try{
            form_vars += document.forms.ms[i].name+": "+document.forms.ms[i].value+"\n";
         }
         catch(err){
            form_vars += "could not get info for form element "+i+"\n";
         }
      }
      a.open("GET",'/cust/ajax/report_error.php?error='+escape(err)+'&cr='+escape(currently_running)+'&fv='+escape(form_vars)+'&ua='+escape(navigator.userAgent),true);
      a.send('');
   }
}
onerror = report_error;

function $F(form,name) {
   if(form[name]){
      if(form[name].length){
         for(var z=0;z<form[name].length;z++){
            if(form[name][z].disabled) {return false;}
         }
         if(form[name].disabled){;return false;}
         return form[name];
      }else{
         if(!form[name].disabled){return form[name];}
         else {return false;}
      }
   }else if(form[name+'[]']){
      if(!form[name+'[]'].disabled) {return form[name+'[]'];}
      else {return false;}
   }
   return false;
}

function need_to_validate(element){
   var validate = true;
   if(element.length && !element.type) {
      for(var i = 0; i < element.length; i++) {
         if(element[i].getAttribute){
            if(element[i].getAttribute('bypass_validation')) validate = false; 
         }else if (element[i].attributes){
            if(element[i].attributes.bypass_validation) validate = false; 
         }else if(element[i].bypass_validation){
            validate = false;
         }
      }
   } else {
      if(element.getAttribute){
         if(element.getAttribute('bypass_validation')) validate = false; 
      }else if (element.attributes){
         if(element.attributes.bypass_validation) validate = false; 
      }else if(element.bypass_validation){
         validate = false;
      }
   }
   return validate;
}

function standard_validation(element,qid,type,reg,name){
     switch(type) {
         case 'text':
         case 'textarea':
         case 'password':
            if(!in_array(q_done,qid)){
               if(!(reg.test(element.value))) { 
                  validation_error[validation_error.length] = "Invalid Format for '"+name+"'\n";
               }
               q_done[q_done.length] = qid;
            }
            break;
         case 'radio':
            var this_validation_error = 0;
            if(!in_array(q_done,qid)){
                this_validation_error = 1;
                if(!(element.length)){
                  if(element.checked){ this_validation_error=0; }
                }else{
                  for(var i=0; i<element.length; i++){
                     if(element[i].checked){ this_validation_error=0; }
                  }
               }
               if(this_validation_error){ 
                 validation_error[validation_error.length] = "Please answer '"+name+"'\n"; 
               }
               q_done[q_done.length] = qid;
            }
            break;
         case 'checkbox':
            var this_validation_error=0;
            if(!in_array(q_done,qid)){
               this_validation_error=1;
               if(element.length==null) {
                  if(element.checked){ this_validation_error=0; } 
               }else{
                  for(var i=0; i<element.length; i++){
                     if(element[i].checked){ this_validation_error=0; }
                  }
               }
               if(this_validation_error) { 
                 validation_error[validation_error.length] = "Please answer '"+name+"'\n";
               }
               q_done[q_done.length] = qid;
            }
            break;
         case 'select':
         case 'select-one':
         case 'select-multiple':
            if(!element.multiple) {
               var this_validation_error=0;
               if(!in_array(q_done,qid)){
                  this_validation_error=1;
                  if(element.type=='hidden' || element.selectedIndex>=1){ this_validation_error=0; }
                  if(this_validation_error){
                     validation_error[validation_error.length] = "Please answer '"+name+"'\n";
                  }
                  q_done[q_done.length] = qid;
               }
            } else {
               var this_validation_error=0;
               if(!in_array(q_done,qid)){
                  this_validation_error=1;
                  if(element.type=='hidden' || element.selectedIndex>=1){ this_validation_error=0; }
                  if(this_validation_error){
                     validation_error[validation_error.length] = "Please answer '"+name+"'\n";
                  }
                  q_done[q_done.length] = qid;
               }
            }
            break;
      }
}



function showContent(num,content,adv){
   if(content=='' && adv==1) ignoreForm=1;
   if(ie4){ showContentObj=document.all['div'+num]; }
   if(ns6){ showContentObj=document.getElementById("div"+num); }
   if(ie4||ns6){
      if(showContentObj.innerHTML!=content){
         showContentObj.innerHTML=content;
         if(content!=""){
            window['res'+num] = content.match(/q\d+/g);
         }else{
	        if(window['res'+num]){
             for(l=0;l<window['res'+num].length;l++){
	             document.ms[window['res'+num][l]] = false;
             }
	        }
         }
      }else{
         showContentObj.innerHTML="";
      }
   }
   if(ns4){
      document['layer'+num].document.write(content);
      document['layer'+num].document.close();
   }

   if(validate(document.ms)){advance=adv;}
   else {advance = 0;}
}
function showContent2(div,dir,adv){
   var f = document.forms[0];
   daDiv = document.getElementById('drop'+div);
   if(daDiv.style.display=='block'  && adv==1) ignoreForm=1;
   if(dir=='down'){
      daDiv.style.display = 'block';
      dropdown_status = 1;
   }
   window['res'+div] = daDiv.innerHTML.match(/q\d+/g);
	if(window['res'+div]){
       for(l=0;l<window['res'+div].length;l++){
         var T = window['res'+div][l].match(/q\d+/);
         if(T)var elem = T[0];
         if(f[elem]){
            if(f[elem].length){
               for(var z=0;z<f[elem].length;z++){
                  var sub_elem = f[elem][z];
                  if(sub_elem){
                     if(sub_elem.value){
                        sub_elem.disabled = dir=='down'?false:true;
                     }
                  }
               }
            }
            f[elem].disabled = dir=='down'?false:true; //so values on hidden don't get passed
         }
       }
	}
   if(dir=='up'){
      daDiv.style.display = 'none';
      dropdown_status = 0;
   }
   if(validate(document.ms)){advance=adv;}
   else {advance = 0;}
}

function setJSCookie(cname,cvalue,domain) {
   var nextWeek = new Date();
   nextWeek.setMinutes(nextWeek.getUTCMinutes() + 10080);
   document.cookie = cname+"="+cvalue + "; path=/; expires=" + nextWeek.toGMTString() + "; domain=" + domain;
}



function setTTIMG(ttid,uk,pid,src,domain,sc) {

   var num = "TTIMG";
   var adv = 0;
   var ssl = ""; //enhance to determine secure status
   var imgtag = "<IMG src='http" + ssl + "://" + domain + "/ttset.php?ttid=" + ttid + "&pid=" + pid + "&src=" + src + "&uk=" + uk + sc + "' height=1 width=1 border=0>";

   showContent(num,imgtag,adv);
	//re-allow pops
	// (disallowed by above call)
	xpc=0;

}


function tracktagListen(tagid){
   var allcookies = document.cookie;
   if(allcookies.indexOf("msadv_"+tagid)!=-1) {document.cookie = "msadv_"+tagid+"=; expires=Fri, 02-Jan-1970 00:00:00 GMT"; top.document.forms['ms'].submit();}
}

function autoAdvance(){
   xpc=1;
   if(advance && (validate(document.ms) || ignoreForm==1)){
   //NOTE ON BELOW: can override the ?bcv token setup (which disables form processing by default)
   //by setting forceProcess=1 somewhere in form
    if(ignoreForm==1 && !forceProcess)document.ms.action = document.ms.action + "?bcv";
    show_spinner();
    document.ms.submit();
   }
   advance=1;
   ignoreForm=0;
}

function xpop(url,xname,hght,wdth){

  if(!xpc){
     if(document.forms[0].xps && document.forms[0].xps.value==1){return true;}
     var xp = window.open(url,'xpop'+xname,'width='+wdth+',height='+hght+',resizable=yes,menubar=yes,scrollbars=yes,screenX=500,screenY=190,left=500,top=190'); 
     return true;
  }else{
	return true;
  }	
}

function show_spinner(){

	if(document.getElementById){
	 if(showSpinner=='yes'){
   		subspin = document.getElementById('spinner');
  		   tbox = document.getElementById('transbox');
         if(document.all){
          finalpos = document.body.scrollTop + (document.body.clientHeight/3) - 50; 
 	  finalHeight = document.body.scrollTop + document.body.clientHeight;
         }else{
          finalpos = window.pageYOffset + (window.innerHeight/3)-10;
  	  finalHeight = window.pageYOffset + window.innerHeight;
         }
         if(subspin){
					subspin.style.top = finalpos + "px"
 					subspin.style.display='block';
         }
			if(tbox){
				tbox.style.height= finalHeight + 'px';
         	tbox.style.display='block';
			}
   	 }
	}
} 

function hide_spinner(){
	
	if(document.getElementById){
      	   subspin = document.getElementById('spinner');
           tbox = document.getElementById('transbox');
  	   if(subspin) subspin.style.display='none';
  	   if(tbox){
			tbox.style.display='none';
      	tbox.style.height='100px';
		}
	}
}

function getMouseXY(e) {
	if(document.getElementById){
		var posx = 0;
		var posy = 0;
		if (!e) var e = window.event;
		if (e.pageX || e.pageY){
			posx = e.pageX;
			posy = e.pageY;
		}else if (e.clientX || e.clientY){
			posx = e.clientX + document.body.scrollLeft;
			posy = e.clientY + document.body.scrollTop;
		}
  		subspin = document.getElementById('spinner')
  		finalpos = posy;  
  		if(subspin) subspin.style.top = (posy -5) + "px"
  		if(subspin) subspin.style.left = (posx + 10) + "px"
	}
  return true
}
//moving dots script
direction = 1;
function do_dots(loop){
    var txt="";
    if(loop==limit) direction = -1;
    if(loop==0) direction = 1;
    for(k=0;k<limit+1;k++){
        if(k==loop){
            txt += "<span style='font-size:30px;font-weight:bold;color:#467bb8;'>.</span>";
        }else if((direction==1 && k==(loop-1)) || (direction==-1 && k==(loop+1))){
			   txt += "<span style='font-size:30px;font-weight:bold;color:#B4B2B8;'>.</span>";
		  }else if((direction==1 && k==(loop-2)) || (direction==-1 && k==(loop+2))){
			   txt += "<span style='font-size:30px;font-weight:bold;color:#CAC7CE;'>.</span>";
		  }else{
            txt +="&nbsp;";
        }
    }
    t.innerHTML = txt;
    loop = loop + direction;
    setTimeout('do_dots('+loop+')',speed);
}
/*************
pops the info window on cpas
*************/
times = 0;
pagenum = 1; //gets changed per cpa wall
function cpa_pop(link,offer,pbk,pzk,sk){
  var a = window.open(link,'_blank','toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=800,height=800,top=100,left=50');
  if(times<2){
			 var b = window.open('cpa_help2.php?cid='+offer+'&pbk='+pbk+'&pzk='+pzk+'&sk='+sk,'_blank','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resiable=1,width=300,height=350,top=50,left=10');
			// times++;
			 if(b) b.focus();
  }
  var a = new XMLHttpRequest();
  var sesp = document.forms.ms.sesp.value;
  var location = '/cust/ajax/getresult.php?qk=udoW3&sesp='+sesp+'&arg1='+pagenum+'&arg2='+offer;
  a.open("GET",location,true);
  a.send('');
}

default_service_hook='';
function set_hook(hook){ //used in quick_popval below
	if(default_service_hook == '')
		default_service_hook = 'arg';
		
	if(!hook) hook = default_service_hook;
	if(frames['searchIFrame'].document.search.hook) frames['searchIFrame'].document.search.hook.value = hook;
}
function set_action(act){
	if(frames['searchIFrame'].document.search.act) frames['searchIFrame'].document.search.act.value = act;
}
suppressed = 0;
function suppress_submit(){
	//if (frames['searchIFrame'].document.search.submit_parent) 
	frames['searchIFrame'].document.search.submit_parent.value = "0";
	suppressed = 1;
}

/***********************************************************************
supporting functions for the multiple-call popval logic
************************************************************************/
function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/m;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = / +/g;
   temp = temp.replace(obj, " ");
   if (temp == " ") { temp = ""; }
   return temp;
}

function get_all_popval_objects(){
	var inp = document.forms[0];
	var resret = new Array();
	for (var j=0;j<inp.length;j++){
	if(inp[j]){
		//alert(inp[j].name);
			if(inp[j].onclick){
		//		alert('found onclick');
				if(parse_call(inp[j].onclick)) resret[j] =  new Array(trim(parse_call(inp[j].onclick)),trim(inp[j].name));
			}else if(inp[j].onchange){
				if(parse_call(inp[j].onchange)) resret[j] = new Array(trim(parse_call(inp[j].onchange)),trim(inp[j].name));
			}else if (inp[j].onsubmit){
				if(parse_call(inp[j].onsubmit)) resret[j] = new Array(trim(parse_call(inp[j].onsubmit)),trim(inp[j].name));
			}else if (inp[j].href){
				resret[j] = new Array(trim(parse_call(inp[j].href)),trim(inp[j].name));
			}
		}
	}
	//now do links, j.i.c
	for(z=0;z<document.links.length;z++){
		daLink = document.links[z];
		call = daLink.href;
		//alert(call);
		if(parse_call(call)) resret[j] = new Array(trim(parse_call(call)),trim(daLink.name));
		//else alert ('parse call failed');
		
	}
	
	if(resret.length > 0){
		return resret;
	}else{
		return false;
	}

}
function parse_call(call,getAll){
		var theCall = call.toString();
		//alert ('the call: '+theCall);
		if(theCall.indexOf("{") > 0){
			theCall = theCall.substring(theCall.indexOf("{") + 3,theCall.indexOf("}"));
		}
		theCall = theCall.replace(/javascript:/,'');
		//alert ('the call 2: '+theCall);
		var theCalls = Array();
		var returnedCalls = "";
		var rl = 0;
		theCalls = theCall.split(/;/);	
		for (var k=0;k<theCalls.length;k++){
			currentCall = theCalls[k];
			//alert ('current call: '+ currentCall);
			if(currentCall.length<5 && !getAll)return false;
			if(currentCall.match(/opval/)){
				if(getAll){
					returnedCalls += (returnedCalls==""?"":";")+currentCall;
					rl++;
				}else{
				toreturn =  trim(currentCall);
				//alert ('to return '+toreturn);
				return toreturn;
				}
			}
		}
		if(getAll) return returnedCalls;
		return false;
}
function parse_mode(call){
	 res = call[0].substring(call[0].indexOf("("));
	 res = res.replace(/"/g,"");
	 res = res.replace(/'/g,"");
	 res = res.substring(res.indexOf("(")+1,res.indexOf(","))
	 return res;
}
function get_calling_name(mode){
      var DADOM = get_all_popval_objects();
      var DOM = new Array();
      var dl = 0;
      //clean it up
      for(var h=0;h<DADOM.length;h++){
         call = DADOM[h];
         if (call){ DOM[dl] = call; dl++;}
      }
      //loop through DOM and see where the fist call matches the current mode
      for(var x = 0;x<DOM.length;x++){
         var dadom = DOM[x];
         var damode = parse_mode(dadom);
         if (damode == mode){
				//alert ('got onei '+dadom[1].length);
				return (dadom[1].length > 0?dadom[1]:calling_field_hash);;
            break;
         }
      }
}

function reset_vars(){
	//alert ('resetting vars');
	js_error_mssg = null;
   js_error_mssg = new Array;
	if(val_error_mssg.length > 0) {
		//alert('sup sub 1');
		sup_submit = 1;
	}
	val_error_mssg = null;
   val_error_mssg = new Array;
	total_to_run = 0;
	current_loop = 1;
	sup_popval = 0;
}
function add_to_mssgs(mssg){
	val_error_mssg[current_loop - 1] = mssg;
	js_error_mssg[current_loop - 1] = mssg;
}
function show_js_mssg(){
    //alert ('showing mssg');
	if(js_error_mssg.length > 0 ) alert(js_error_mssg.join('\n'));
}
function should_submit(){
	if(window.sup_submit){
		//alert('submit suppressed');
		sup_submit = 0;
		return false;
	}else{
		//alert('not suppressed');
		sup_submit = 0;
		return true;
	}
}
function show_div_mssg(display_mssg){
	if(document.getElementById){
     daname = parent.document.getElementById('iForm_errors')?'iForm_errors':'dmsg';
     parent.document.getElementById(daname).innerHTML = display_mssg;
   }else if (document.all){
     if(parent.document.all.iForm_errors)
        parent.document.all.iForm_errors.innerHTML = display_mssg;
     else
        parent.document.all.dmsg.innerHTML = display_mssg;
   }else if (document.layers){
     if(parent.document.layers.iForm_errors)
       parent.document.layers.iForm_errors.innerHTML = display_mssg;
     else
       parent.document.layers.dmsg.innerHTML = display_mssg;
   }

}
/***************************************************************
quick_popval: dynamic prepop and validation.  This master function is a regrouping 
of all the functions under "address validation routines"
that allows for production-friendly prepoulation of form fields
*****************************************************************/
//set up some defaults
dpt=0; //1 means testing, comment out for live
var popval_running = false;
var total_to_run = 0;
var current_loop = 1;
var val_error_mssg = new Array;
var js_error_mssg = new Array;
var sup_submit = 0;
var sup_popval = 0;
var calling_field_hash = 'asdfasdfasdf98as7dfasdf';
var current_popval_mode ='';
var freepass_data = new Array();
var popval_freepass = new Array();
var popval_calls = new Array();
var cb=0;

function quick_popval(mode,f1,f2,f3,f4,f5,f6,f7,f8){
	//add to popval calls so we know what's what
	popval_set = 0;
	cb=1;
	for(j=0;j<popval_calls.length;j++){
		if(popval_calls[j] == mode) popval_set = 1;
	}
	if(!popval_set) popval_calls[popval_calls.length] = mode;
	current_popval_mode = mode;
	if (sup_popval > 0){
		current_loop++;
		//alert ('popval suppressed ('+mode+')');
		if((current_loop == total_to_run) || !total_to_run){
		 window.reset_vars();
		}
		return false;
	}
	if(current_loop > 1 && current_loop > total_to_run){ //corner case....
//		alert('greater than, resetting; '+current_loop+' '+total_to_run);
		window.reset_vars();
		setTimeout("quick_popval('"+mode+"', '"+f1+"','"+f2+"','"+f3+"','"+f4+"','"+f5+"','"+f6+"','"+f7+"','"+f8+"')", 10);
		return;
	}
	//check if we're on loop 1 and sup_submit is set -- shouldn't be
	// ie another corner case
	if(current_loop == 1 && sup_submit == 1) sup_submit = 0;
	//Make sure the last one is done before we do this one.
	if(popval_running) {
	//	alert('timeout for mode: ' + mode);
		setTimeout("quick_popval('"+mode+"', '"+f1+"','"+f2+"','"+f3+"','"+f4+"','"+f5+"','"+f6+"','"+f7+"','"+f8+"')", 200);
		return;
	}
	popval_running = true;
	/*************
	figure out which call called us and find the total numer of popval calls
	in that call -- this is done for one error message display even if many
	popvals called
	******************/
	if(!total_to_run){
		var calling_field = get_calling_name(mode);
		//alert('calling field: '+calling_field);
		relevant_calls = false;
		if(calling_field || calling_field == calling_field_hash){
		//	if(calling_field != calling_field_hash){ //on hrefs without a name, this returns false
			eval( "var field = document.forms[0]."+calling_field+";");
		//	}else alert('got hash');
			if(!field){
		//	alert('no field 1');
				//could be a <a> . Because IE won't recognize document.links[name], kludge:
				for(zz=0;zz<document.links.length;zz++){
					if(document.links[zz].name == calling_field){
						field = document.links[zz];
						break;
					}
				}
			//if STILL don't have field, super kludge: find first <a> with mode in its href
				if(!field){
		//		alert ('field still not found');
					for(zz=0;zz<document.links.length;zz++){
						if(document.links[zz].href.indexOf(mode) > -1 ){
							field = document.links[zz];
				//			alert(field.name);
							break;
						}
					}
				}
		//		if(!field) alert ('no field at all!');

				if (field.href) var relevant_calls = parse_call(field.href,1);
			}else{
				if(field.onchange)var relevant_calls = parse_call(field.onchange,1);
				else if (field.onclick) var relevant_calls = parse_call(field.onclick,1);
				else if (field.onsubmit) var relevant_calls = parse_call(field.onsubmit,1);
			}
		}
		if(relevant_calls){
			var count_me = relevant_calls.split(";");
			total_to_run = count_me.length;
		}//else alert ('no relevant calls');
	}

	if(dpt) alert(mode);
	set_action(mode);
	suppressed = 0;
	switch (mode){
		case "prepop_citystate_from_zip":
		   set_hook(f4);
		   set_mapping("city",f1);
		   set_mapping("state",f2);
		   set_mapping("zip",f3);
		   suppress_submit();
		   start_validation();
			break;
		case "prepop_citystatearea_from_zip":
		   set_hook(f5);
		   set_mapping("city",f1);
		   set_mapping("state",f2);
		   set_mapping("areacode",f3);
		   set_mapping("zip",f4);
		   suppress_submit();
		   start_validation();
			break;
		case "prepop_area_from_zip":
		   set_hook(f3);
		   set_mapping("areacode",f1);
		   set_mapping("zip",f2);
		   suppress_submit();
			start_validation();
			break;
		case "validate_zip":
		   set_hook(f2);
		   set_mapping("zip",f1);
		   start_validation();
			break;
		case "validate_zip_no_submit":
		   set_hook(f2);
		   set_action("validate_zip");
		   set_mapping("zip",f1);
			suppress_submit();
			start_validation();
			break;
		case "validate_citystatezip":
		   set_hook(f4);
		   set_mapping("city",f1);
		   set_mapping("state",f2);
		   set_mapping("zip",f3);
		   start_validation();
			break;
		case "validate_citystatezip_no_submit":
			set_hook(f4);
			set_action("validate_citystatezip");
			set_mapping("city",f1);
		   set_mapping("state",f2);
		   set_mapping("zip",f3);
		   suppress_submit();
		   start_validation();
			break;
		case "validate_a1a2citystatezip":
			set_hook(f6);
			set_mapping("address1",f1);
			set_mapping("address2",f2);
			set_mapping("city",f3);
			set_mapping("state",f4);
			set_mapping("zip",f5);
			start_validation();
			break;
		case "validate_a1a2citystatezip_no_submit":
			set_hook(f6);
			set_action("validate_a1a2citystatezip");
			suppress_submit();
			set_mapping("address1",f1);
			set_mapping("address2",f2);
			set_mapping("city",f3);
			set_mapping("state",f4);
			set_mapping("zip",f5);
			start_validation();
			break;
		case "validate_a1a2citystatezipzip4":
			set_hook(f7);
			set_mapping("address1",f1);
			set_mapping("address2",f2);
			set_mapping("city",f3);
			set_mapping("state",f4);
			set_mapping("zip",f5);
			start_validation();
			break;		
		case "validate_a1a2citystatezipzip4_no_submit":
			set_hook(f7);
			set_action("validate_a1a2citystatezip");
			suppress_submit();
			set_mapping("address1",f1);
			set_mapping("address2",f2);
			set_mapping("city",f3);
			set_mapping("state",f4);
			set_mapping("zip",f5);
			start_validation();
			break;
		case "validate_email":
			set_hook(f2);
			set_action("validate_email");
			set_mapping("email",f1);
			start_validation();
			break;
		case "validate_email_no_submit":
			set_hook(f2);
			set_action("validate_email");
			set_mapping("email",f1);
			suppress_submit();
			start_validation();
			break;
		case "validate_ssn":
			set_hook(f2);
			set_action("validate_ssn");
			set_mapping("ssn",f1);
			start_validation();
			break;
		case "validate_ssn_no_submit":
			set_hook(f2);
			set_action("validate_ssn");
			set_mapping("ssn",f1);
			suppress_submit();
			start_validation();
			break;
		case "validate_ssn3":
			set_hook(f4);
			set_action("validate_ssn");
			set_mapping("ssn1",f1);
			set_mapping("ssn2",f2);
			set_mapping("ssn3",f3);
			start_validation();
			break;
		case "validate_ssn3_no_submit":
			set_hook(f4);
			set_action("validate_ssn");
			set_mapping("ssn1",f1);
			set_mapping("ssn2",f2);
			set_mapping("ssn3",f3);
			suppress_submit();
			start_validation();
			break;
		case "validate_phone":
			set_hook(f4);
			set_action("validate_phone");
			set_mapping("areacode",f1);
			set_mapping("prefix", f2);
			set_mapping("suffix", f3);
			start_validation();
			break;
		case "validate_phone_no_submit":
			set_hook(f4);
			set_action("validate_phone");
			set_mapping("areacode",f1);
			set_mapping("prefix", f2);
			set_mapping("suffix", f3);
			suppress_submit();
			start_validation();
			break;
		case "validate_phone_cell":
			set_hook(f4);
			set_action("validate_phone_cell");
			set_mapping("areacode",f1);
			set_mapping("prefix", f2);
			set_mapping("suffix", f3);
			start_validation();
			break;
		case "validate_phone_cell_no_submit":
			set_hook(f4);
			set_action("validate_phone_cell");
			set_mapping("areacode",f1);
			set_mapping("prefix", f2);
			set_mapping("suffix", f3);
			suppress_submit();
			start_validation();
			break;
		case "validate_phone_land":
			set_hook(f4);
			set_action("validate_phone_land");
			set_mapping("areacode",f1);
			set_mapping("prefix", f2);
			set_mapping("suffix", f3);
			start_validation();
			break;
		case "validate_phone_land_no_submit":
			set_hook(f4);
			set_action("validate_phone_land");
			set_mapping("areacode",f1);
			set_mapping("prefix", f2);
			set_mapping("suffix", f3);
			suppress_submit();
			start_validation();
			break;
		default:
			alert("no mode: "+ mode);
			break;
	}
	last_val = mode;
	void(null);
}

function popval(mode,f1,f2,f3,f4,f5,f6,f7,f8){
	preval='no';
	if(validate(document.ms,'alert')){
		show_spinner();
		if(f8) quick_popval(mode,f1,f2,f3,f4,f5,f6,f7,f8);
		else if (f7) quick_popval(mode,f1,f2,f3,f4,f5,f6,f7);
		else if (f6) quick_popval(mode,f1,f2,f3,f4,f5,f6);
		else if (f5) quick_popval(mode,f1,f2,f3,f4,f5);
		else if (f4) quick_popval(mode,f1,f2,f3,f4);
		else if (f3) quick_popval(mode,f1,f2,f3);
		else if (f2) quick_popval(mode,f1,f2);
		else if (f1) quick_popval(mode,f1);
	}else{<
		reset_vars();
		sup_popval = 1;
		void(null);
	}
}



/*************************************************
*	Address validation routines
*************************************************/
M = new Array();
M['zip'] = 'zipId';
M['zip4'] = 'zip4Id';
M['email'] = 'emailId';
M['fname'] = 'fnameId';
M['lname'] = 'lnameId';
M['address1'] = 'address1Id';
M['address2'] = 'address2Id';
M['city'] = 'cityId';
M['state'] = 'stateId';
M['areacode'] = 'areacodeId';
M['prefix'] = 'prefixId';
M['suffix'] = 'suffixId';
/***********************************
TODO:

make set_mapping set up a freepass_data varialbe, probablyan array
that has all the fields it's working on
the free_pass can use that array to build its unique string of numbers
it's already checked
*************************************/

function set_mapping(fieldName,fieldId){
		eval ("target = frames['searchIFrame'].document.search." + M[fieldName]);
		if(target) target.value = fieldId;
		eval ("if(document.ms." + fieldId+" && frames['searchIFrame'].document.search." + fieldName+") frames['searchIFrame'].document.search." + fieldName + ".value = document.ms." + fieldId + ".value;");
		//add field to list of concatenated valid addr
		if(!freepass_data[current_popval_mode+'_ids']){
			freepass_data[current_popval_mode+'_ids'] = new Array();
		}
		if(!freepass_data[current_popval_mode+'_fields']){
			freepass_data[current_popval_mode+'_fields'] = new Array();
		}
		if(fieldId) freepass_data[current_popval_mode+'_ids'][freepass_data[current_popval_mode+'_ids'].length] = fieldId;
		if(fieldName) freepass_data[current_popval_mode+'_fields'][freepass_data[current_popval_mode+'_fields'].length] = fieldName;
}
function start_validation(){
	//if they get a free pass, just submit form, otherwise, run validation
	if(free_pass() && !suppressed && (current_loop >= total_to_run)){
		//alert ('free pass');
		document.forms[0].js.value='yes';
		return document.ms.submit();
	}else{
	   // alert ('no free pass '+suppressed);
		freepass_data[current_popval_mode+'_ids'] = new Array();
		freepass_data[current_popval_mode+'_fields'] = new Array(); //these need to be reinit here otherwise grow too long
		return frames['searchIFrame'].document.search.submit();
	}
}

//checks the number of submission attempts and lets them through if greater than x
function free_pass(){
	var numberOfValidationAttempts = 2; //2 means 3 attempts (starts @ zero)
	var freepass = 0;
	for(fl=0;fl<freepass_data[current_popval_mode+"_ids"].length;fl++){ //create the valid string for which they get n tries
      if(document.forms.ms[freepass_data[current_popval_mode+"_ids"][fl]].value){
         if(!freepass_data[current_popval_mode]) freepass_data[current_popval_mode] = '';
            freepass_data[current_popval_mode] += document.forms.ms[freepass_data[current_popval_mode+"_ids"][fl]].value + "|";;
         }
      }
	//get the cookie val, if any, for validAttempts and validString for this mode
    var validString = getCookie(current_popval_mode);
	 freepass_data[current_popval_mode+'_validAttempts'] = getCookie(current_popval_mode+'_validAttempts');
    if(validString == freepass_data[current_popval_mode]) freepass_data[current_popval_mode+'_validAttempts']++;
	 else{
	 	freepass_data[current_popval_mode+'_validAttempts'] = 0;
		temp = popval_freepass;
		popval_freepass.length = 0;
		for(j=0;j<temp.length;j++){ //rebuild popval freepass without this one
			if(temp[j] != current_popval_mode) popval_freepass[j] = temp[j];
		}
		setCookie(current_popval_mode,freepass_data[current_popval_mode]);
		freepass_data[current_popval_mode] = '';
	 }
    setCookie(current_popval_mode+'_validAttempts', freepass_data[current_popval_mode+'_validAttempts']);
	 if(freepass_data[current_popval_mode+'_validAttempts'] < numberOfValidationAttempts){ //havent tried enough times
	 	freepass_data[current_popval_mode] = '';
		return false;
	 }else { //have tried enough times
		sup_submit = 0;
		suppressed = 0;
		if(popval_freepass.length >= total_to_run){
			freepass_data[current_popval_mode] = '';
			return true; //we only want to give a freepass to someone who's through the multiple calls
		}else{
			if(!in_array(popval_freepass,current_popval_mode)){
				popval_freepass[popval_freepass.length] = current_popval_mode;
			}
			freepass_data[current_popval_mode] = '';
			return false;
		}
	 }
}

function in_array(arr,val){
	for(j=0;j<arr.length;j++){
		if(arr[j]==val) return true;
	}
	return false;
}

function createIFrame () {
	// for debugging
	document.write("<iframe name=\"searchIFrame\" id=\"searchIFrame\" src=\"lib/searchIForm.php\"></iframe>");
}

/****************
dynamic month / day in month check
***************/
function set_up_months(){
	var f = document.forms[0];
	if(f){
		if(f.ARG_PAGE_BUILT){
			if(f.q11 && f.q12 && f.q11.setAttribute && f.q13){
					f.q11['onchange'] = new Function("set_month_days()");
					f.q13['onchange']= new Function("set_month_days()");
			}
		}else{
			setTimeout('set_up_months()',200);
		}
	}else{
		setTimeout('set_up_months()',200);
	}
}
set_up_months();

function set_month_days(){
	var f = document.forms[0];
	if (f.q12) var mm = f.q11;
	if (f.q11) var dm = f.q12;
	if (f.q13) var ym = f.q13;
	var data = new Array();
	data['01'] = 31; //jan
	data['02'] = (ym.value/4)==Math.floor(ym.value/4) && ym.value>0?29:28; //feb
	data['03'] = 31; //march
	data['04'] = 30; //apr
	data['05'] = 31; //may
	data['06'] = 30; //june
	data['07'] = 31; //july
	data['08'] = 31; //august
	data['09'] = 30; //sept
	data['10'] = 31; //oct
	data['11'] = 30; //nov
	data['12'] = 31; //dec
	if(mm && dm){
		var oldIndex = dm.selectedIndex;
		dm.options.length=0;
		dm.options[0] = new Option('DD','');
		for(l=1;l<data[mm.value]+1;l++){
			value = l<10?'0'+l:l;
			dm.options[l] = new Option(value);	
			if(l==oldIndex) dm.options[l].selected = true;
		}
	}
}

/*************************************************
*	Credit card validation routines
*************************************************/

var CardTypes = new Array("M", "V", "A", "DinersClubCard", "Z", "enRouteCard", "JCBCard");
var Cards = new makeArray(8);
Cards[0] = new CardType("MASTERCARD", "51,52,53,54,55", "16");
var MasterCard = Cards[0];
Cards[1] = new CardType("VISA", "4", "13,16");
var VisaCard = Cards[1];
Cards[2] = new CardType("AMEX", "34,37", "15");
var AmExCard = Cards[2];
Cards[3] = new CardType("DinersClubCard", "30,36,38", "14");
var DinersClubCard = Cards[3];
Cards[4] = new CardType("DISCOVER", "6011", "16");
var DiscoverCard = Cards[4];
Cards[5] = new CardType("enRouteCard", "2014,2149", "15");
var enRouteCard = Cards[5];
Cards[6] = new CardType("JCBCard", "3088,3096,3112,3158,3337,3528", "16");
var JCBCard = Cards[6];
var LuhnCheckSum = Cards[7] = new CardType();

/*************************************************************************
*	CheckCardNumber(cardNumber, cardType, expMonth, expYear)
*	function called when form is submitted
*************************************************************************/
function CheckCardNumber(cardNumber, cardType, expMonth, expYear) {

	if (cardNumber.length == 0) {
		alert("Please enter a valid credit card number.");
		return false;
	}
	if (expYear.length == 0) {
		alert("Please enter the expiration year for your credit card.");
		return false;
	}
	expYear = "20" + expYear;

	if (!(new CardType()).isExpiryDate(expYear, expMonth)) {
		alert("The credit card you specified has already expired.");
		return false;
	}

	// find the CardType object for the card type
	var cardArrayLoc = -1;
	for (i=0; i<=CardTypes.length; i++) {
		if (CardTypes[i] == cardType) {
			cardArrayLoc = i;
			break;
		}
	}
	if (cardArrayLoc < 0) {
		alert("Please enter a valid credit card type.");
		return false;
	}
		
	var retval =  eval("Cards[" + cardArrayLoc + "].checkCardNumber('" + cardNumber + "'," + expYear + ", " + expMonth + ");");
	cardname = "";
	if (!retval) {
		// The cardnumber has the valid luhn checksum, but we want to know which
		// cardtype it belongs to.
		for (var n = 0; n < Cards.size; n++) {
			if (Cards[n].checkCardNumber(cardNumber, expYear, expMonth)) {
				cardname = Cards[n].getCardType();
				break;
   			}
		}
		if (cardname.length > 0) {
			alert("Please select the card type.  The number you have submitted looks like a " + cardname + " number.");
			return false;
		} else {
			alert("Please enter a valid credit card number.");
			return false;
    	}	
	}
}

/*************************************************************************
*	Object CardType([String cardtype, String rules, String len, int year, 
*		int month])
*	cardtype    : type of card, eg: MasterCard, Visa, etc.
*	rules       : rules of the cardnumber, eg: "4", "6011", "34,37".
*	len         : valid length of cardnumber, eg: "16,19", "13,16".
*	year        : year of expiry date.
*	month       : month of expiry date.
*	eg:
*	var VisaCard = new CardType("Visa", "4", "16");
*	var AmExCard = new CardType("AmEx", "34,37", "15");
*************************************************************************/
function CardType() {
	var n;
	var argv = CardType.arguments;
	var argc = CardType.arguments.length;

	this.objname = "object CardType";

	var tmpcardtype = (argc > 0) ? argv[0] : "CardObject";
	var tmprules = (argc > 1) ? argv[1] : "0,1,2,3,4,5,6,7,8,9";
	var tmplen = (argc > 2) ? argv[2] : "13,14,15,16,19";

	this.setCardNumber = setCardNumber;  // set CardNumber method.
	this.setCardType = setCardType;  // setCardType method.
	this.setLen = setLen;  // setLen method.
	this.setRules = setRules;  // setRules method.
	this.setExpiryDate = setExpiryDate;  // setExpiryDate method.

	this.setCardType(tmpcardtype);
	this.setLen(tmplen);
	this.setRules(tmprules);
	if (argc > 4)
		this.setExpiryDate(argv[3], argv[4]);

	this.checkCardNumber = checkCardNumber;  // checkCardNumber method.
	this.getExpiryDate = getExpiryDate;  // getExpiryDate method.
	this.getCardType = getCardType;  // getCardType method.
	this.isCardNumber = isCardNumber;  // isCardNumber method.
	this.isExpiryDate = isExpiryDate;  // isExpiryDate method.
	this.luhnCheck = luhnCheck;// luhnCheck method.
	return this;
}

/*************************************************************************
*	boolean checkCardNumber([String cardnumber, int year, int month])
*	return true if cardnumber pass the luhncheck and the expiry date is
*	valid, else return false.
*************************************************************************/
function checkCardNumber() {
	var argv = checkCardNumber.arguments;
	var argc = checkCardNumber.arguments.length;
	var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
	var year = (argc > 1) ? argv[1] : this.year;
	var month = (argc > 2) ? argv[2] : this.month;

	this.setCardNumber(cardnumber);
	this.setExpiryDate(year, month);

	if (!this.isCardNumber())
		return false;
	if (!this.isExpiryDate())
		return false;

	return true;
}
/*************************************************************************
*	String getCardType()
*	return the cardtype.
*************************************************************************/
function getCardType() {
	return this.cardtype;
}
/*************************************************************************
*	String getExpiryDate()
*	return the expiry date.
*************************************************************************/
function getExpiryDate() {
	return this.month + "/" + this.year;
}
/*************************************************************************
*	boolean isCardNumber([String cardnumber])
*	return true if cardnumber pass the luhncheck and the rules, else return
*	false.
*************************************************************************/
function isCardNumber() {
	var argv = isCardNumber.arguments;
	var argc = isCardNumber.arguments.length;
	var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
	if (!this.luhnCheck())
		return false;

	for (var n = 0; n < this.len.size; n++)
	if (cardnumber.toString().length == this.len[n]) {
		for (var m = 0; m < this.rules.size; m++) {
			var headdigit = cardnumber.substring(0, this.rules[m].toString().length);
			if (headdigit == this.rules[m])
				return true;
		}
		return false;
	}
	return false;
}

/*************************************************************************
*	boolean isExpiryDate([int year, int month])
*	return true if the date is a valid expiry date,
*	else return false.
*************************************************************************/
function isExpiryDate() {
	var argv = isExpiryDate.arguments;
	var argc = isExpiryDate.arguments.length;
	
	year = argc > 0 ? argv[0] : this.year;
	month = argc > 1 ? argv[1] : this.month;

	if (!isNum(year+""))
		return false;
	if (!isNum(month+""))
		return false;
	today = new Date();
	expiry = new Date(year, month);
	if (today.getTime() > expiry.getTime())
		return false;
	else
		return true;
}

/*************************************************************************
*	boolean isNum(String argvalue)
*	return true if argvalue contains only numeric characters,
*	else return false.
*************************************************************************/
function isNum(argvalue) {
	argvalue = argvalue.toString();

	if (argvalue.length == 0)
		return false;

	for (var n = 0; n < argvalue.length; n++)
	if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
		return false;

	return true;
}

/*************************************************************************
*	boolean luhnCheck([String CardNumber])
*	return true if CardNumber pass the luhn check else return false.
*	Reference: http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl
*************************************************************************/
function luhnCheck() {
	var argv = luhnCheck.arguments;
	var argc = luhnCheck.arguments.length;

	var CardNumber = argc > 0 ? argv[0] : this.cardnumber;

	if (! isNum(CardNumber)) {
		return false;
  	}

	var no_digit = CardNumber.length;
	var oddoeven = no_digit & 1;
	var sum = 0;

	for (var count = 0; count < no_digit; count++) {
		var digit = parseInt(CardNumber.charAt(count));
		if (!((count & 1) ^ oddoeven)) {
			digit *= 2;
			if (digit > 9)
				digit -= 9;
		}
		sum += digit;
	}
	if (sum % 10 == 0)
		return true;
	else
		return false;
}

/*************************************************************************
*	ArrayObject makeArray(int size)
*	return the array object in the size specified.
*************************************************************************/
function makeArray(size) {
	this.size = size;
	return this;
}

/*************************************************************************
*	CardType setCardNumber(cardnumber)
*	return the CardType object.
*************************************************************************/
function setCardNumber(cardnumber) {
	this.cardnumber = cardnumber;
	return this;
}

/*************************************************************************
*	CardType setCardType(cardtype)
*	return the CardType object.
*************************************************************************/
function setCardType(cardtype) {
	this.cardtype = cardtype;
	return this;
}

/*************************************************************************
*	CardType setExpiryDate(year, month)
*	return the CardType object.
*************************************************************************/
function setExpiryDate(year, month) {
	this.year = year;
	this.month = month;
	return this;
}

/*************************************************************************
*	CardType setLen(len)
*	return the CardType object.
*************************************************************************/
function setLen(len) {
	// Create the len array.
	if (len.length == 0 || len == null)
		len = "13,14,15,16,19";

	var tmplen = len;
	n = 1;
	while (tmplen.indexOf(",") != -1) {
		tmplen = tmplen.substring(tmplen.indexOf(",") + 1, tmplen.length);
		n++;
	}
	this.len = new makeArray(n);
	n = 0;
	while (len.indexOf(",") != -1) {
		var tmpstr = len.substring(0, len.indexOf(","));
		this.len[n] = tmpstr;
		len = len.substring(len.indexOf(",") + 1, len.length);
		n++;
	}
	this.len[n] = len;
	return this;
}

/*************************************************************************
*	CardType setRules()
*	return the CardType object.
*************************************************************************/
function setRules(rules) {
	// Create the rules array.
	if (rules.length == 0 || rules == null)
		rules = "0,1,2,3,4,5,6,7,8,9";
  
	var tmprules = rules;
	n = 1;
	while (tmprules.indexOf(",") != -1) {
		tmprules = tmprules.substring(tmprules.indexOf(",") + 1, tmprules.length);
		n++;
	}
	this.rules = new makeArray(n);
	n = 0;
	while (rules.indexOf(",") != -1) {
		var tmpstr = rules.substring(0, rules.indexOf(","));
		this.rules[n] = tmpstr;
		rules = rules.substring(rules.indexOf(",") + 1, rules.length);
		n++;
	}
	this.rules[n] = rules;
	return this;
}
/**************************************************************************
* calculate_age()
*
* returns the age of user based on three hidden fields (birthYear,birthMonth,birthDay)
* that should be included in the page if this script is to work.
**************************************************************************/
function calculate_age(){
    var yy = document.forms[0].birthYear.value;
    var mm = document.forms[0].birthMonth.value;
    var dd = document.forms[0].birthMonth.value;
    var days = new Date();
    var gdate = days.getDate();
    var gmonth = days.getMonth();
    var gyear = days.getFullYear();
    var age = gyear - yy;
    if((mm == (gmonth + 1)) && (dd <= parseInt(gdate))) {
    age = age;
    }
    else {
    if(mm <= (gmonth)) {
    age = age;
    }
    else {
    age = age - 1; 
       }
    }
    return age;
}

/**************************************************************************
* validate_age()
*
* validates the age of current user against an upper and lower limit,then
* automatically set a data point to yes/no depending on whether the age falls
* in that limit.
* NOTE: this function is pretty rigid.  It requires the yes/no target field
* to be two radio buttons, [0] is the yes button, [1] is the no button.
**************************************************************************/
function validate_age(lower,upper,qualField){
	var age = calculate_age();
         yF = eval ('document.forms[0].' + qualField + '[0]');
         nF = eval ('document.forms[0].' + qualField + '[1]');
    if(age < lower || age > upper){
         yF.checked = false;
         nF.checked = true;
    }else{
         yF.checked = true;
         nF.checked = false;       
    }
}
/***************************************************************************
*check_state()
*
* validates a data point against a list of states to be excluded from the leads.
* requires that a hidden "state" variable be inserted into the form so that the
* javascript can verify what state the user is from.
* ALSO requires that the dataPoint be a yes/no radio button, with yes as the first
* value (more flexibility on this function can be added down the line)
*******************************************************************************/

function check_state(dataPoint){
    var optin = eval ('document.forms[0].'+ dataPoint);
    var leadStt = document.forms[0].state.value;
    for(j=0;j<excludeStates.length;j++){
        var checkStt = excludeStates[j];
        if (leadStt==checkStt){
            optin[0].checked = false;
            optin[1].checked = true;
            break;
        }
    }
}

/*************************************************
*	General cookie functions
*************************************************/
/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: current path)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
//word scrub, each index in a regexp
//                  0   1   2   3   4   5
var tx = new Array('a','e','i','o','u','y');

var scrub = new Array('sh(2|\!|0)t(1)*','p2ss','c4nt','f4ck','wh3r1','p1n2s','b2tch','(0ss|b4m|c3rn|0rs1)(-+|_+| +)*h3l1','f0gg3t','n2gg(1r|0h|0)','w1tb0ck','tw0t','t2ts','spl33g1','sp2c','sl4t','sh1m0l1','q411f','p4ss5(?!(-+|_+| +)*c0t)','l1sb(3|20n)','m0st4rb0','j2zz','g33k','f0t(-+|_+| +)*(0ss|0rs1)','cl2t(s|)','v0g2n0','d2ld3','d2ck(s*).+?(?=(h10d|s4ck|l2ck))','0n4s','b0st0rd','l3v1(-+|_+| +)*b0n0n0','(bl3w|r2m)(_+|-+| +)*j3b','f0rt','f3r1(_+|-+| +)*sk2n','m4ff','n3bj42c1','c4m(_|-| |@)+','p1ck1r','t4rd','^(0ss|b4tt)(_+|-+| +)*(r0mm1r|p2r0t1|((lick|pump|jump|taste)er))*');
var scrub = new Array('sh2t','p2ss','f4ck','v0g2n0','d2ld3','p4ss5(?!(-+|_+| +)*c0t)');
var scrub_words = new Array();
for(z=0;z<scrub.length;z++){
	for(y=0;y<tx.length;y++){
		scrub[z] = scrub[z].replace(new RegExp(y+'','g'),tx[y]);
	}
	scrub_words[scrub_words.length] = new RegExp(scrub[z]);
}
//scrub_words = new Array();

//page awareness
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;}
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;}
function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;}
function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;}
function posRight() {return posLeft()+pageWidth();}
function posBottom() {return posTop()+pageHeight();}
