var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
var check=/@[\w\-]+\./;
var checkend=/\.[a-zA-Z]{2,3}$/;

//var agent = navigator.userAgent;
		
function more(myPage, windowName, myWidth, myHeight, resize, scroll){
	LeftPosition= (screen.width*0.5)-(myWidth*0.5);
	TopPosition= (screen.height*0.4)-(myHeight*0.5);
	window.open(myPage, windowName, 'width='+myWidth+',height='+myHeight+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=' + resize);
}

var last_error="", last_error_elem="";
function error_me(element, message, caption){
	last_error_elem=element;
	if(caption==undefined)caption=element;
	if(last_error!="")last_error.className="";
	
	alert(message);
	/*if(navigator.userAgent.indexOf("MSIE")>-1){
		var obj_desire = document.getElementsByTagName("select");
		for (i=0; i<obj_desire.length; i++) obj_desire(i).style.display="none";
	}
	document.getElementById("error_box_content").replaceChild(document.createTextNode(message), document.getElementById("error_box_content").childNodes[0]);
	document.getElementById("error_box").className="visible";*/
	//end
	
	last_error=document.getElementById(caption+'~'); last_error.className="highlight_error";
	if(!navigator.userAgent.indexOf("MSIE")) location.href="#"+caption+"~";
	document.getElementById(element).focus();
	return false;
}

function changeToMoney(nowField){
	tmpValue2=""
	tmpValue = document.getElementById(nowField).value;
	tmpValue = tmpValue.replace(/[^0-9]/ig,"");
	if(tmpValue > 999){
		countNo=0;
		for (i=tmpValue.length; i>=0; i--){
			countNo++;
			tmpValue2 = tmpValue.substr(i,1) + tmpValue2;
			if (countNo>=4){
				countNo=1;
				tmpValue2 = "," + tmpValue2;
				}
			}
		tmpValue = tmpValue2;
		}
	if (tmpValue.substr(0,1)==",") tmpValue=tmpValue.substr(1,tmpValue.length-1);
	if (tmpValue.length>1) if (tmpValue.substr(0,1)=="0") tmpValue=tmpValue.substr(1,tmpValue.length-1);
	document.getElementById(nowField).value=tmpValue;
}

function changeToNumeric(nowField){
	tmpValue = document.getElementById(nowField).value;
	tmpValue = tmpValue.replace(/[^0-9]/ig,"");
	document.getElementById(nowField).value=tmpValue;
}

function changeToPhone(nowField){
	tmpValue = document.getElementById(nowField).value;
	tmpValue = tmpValue.replace(/[^0-9]/ig,"");
	if ((tmpValue.substr(0,3)=="000")||(tmpValue.substr(0,3)=="555")) tmpValue = "";
	document.getElementById(nowField).value=tmpValue;
}

function jumpToNext(nowField, nextField){
	if (document.getElementById(nowField).value.length==document.getElementById(nowField).maxLength) document.getElementById(nextField).focus();
}

/*function show_hide_obj(element_name){
	if (document.getElementById(element_name).value) {
		document.getElementById(element_name).value=false;
		document.getElementById(element_name).className='hidden';
		}
	else {
		document.getElementById(element_name).value=true;
		document.getElementById(element_name).className='visible';
		}
}

function verify_callme() {
	if ((document.getElementById('area').value == '') || (document.getElementById('exchange').value == '') || (document.getElementById('number').value == '')) return error_me('area', 'Please enter full number');
	document.getElementById('callme').className='hidden'; document.getElementById('callme_done').className='visible';
	return true;
}*/

var pixels_to_move=0, current_count=0, next_url="";

function slide_x(pixels){
	pixels_to_move = pixels;
	multi=1;
	if (pixels<0)multi=-1;
	slide_it_x_engine(80*multi);
}

function slide_it_x_engine(speed){
	current_count+=speed;
	document.getElementById('anim').style.marginLeft = (current_count+'px');
	//document.getElementById('anim').style.margin = (current_count+'px');
	if(pixels_to_move>0){
		if(current_count <= pixels_to_move) timerID = setTimeout("slide_it_x_engine("+speed+")",1);
 		else {
			timerID="";
			document.getElementById('loading_float').className="visible";
			if(next_url!="")location.href=next_url;
			}
		}
	else{
		if(current_count >= pixels_to_move) timerID = setTimeout("slide_it_x_engine("+speed+")",1);
 		else {
			timerID="";
			document.getElementById('loading_float').className="visible";
			document.getElementById('formMe').submit();
			}
	}
}

function valid(function_perform, form_id){
	if(form_id=='undefined')form_id='formMe';
	if(eval(function_perform)())document.getElementById(form_id).submit();
}

function valid_roll(){
	next_url="";
	if(check_form())slide_x(-400);
}

function back_roll(goto_url){
	if(goto_url!="")next_url=goto_url;
	slide_x(400);
}

function close_error_box(){
	if(navigator.userAgent.indexOf("MSIE")>-1){
		var obj_desire = document.getElementsByTagName("select");
		for (i=0; i<obj_desire.length; i++) obj_desire(i).style.display="inline";
	}
	document.getElementById(last_error_elem).focus();
	document.getElementById('error_box').className="hidden";
}

function check_small_form(){
	now_field="quoteFor";
		if(document.getElementById(now_field).value=="") return error_me(now_field, 'Please select Insurance Yype');
	now_field="zip";
		if(document.getElementById(now_field).value=="") return error_me(now_field, 'Please enter Zip Code');
	return true;
}

function addBookmark(title, url) {
	if (window.sidebar) window.sidebar.addPanel(title, url,""); 
	else if(document.all)window.external.AddFavorite(url, title);
	else if(window.opera && window.print)return true;
}

function assign_class(elem, class_name){
	document.getElementById(elem).className=class_name;
}