re_email=/^\w+([\w\.-])*[\w\.-]*@\w(([\.-]\w)*[\w-]+)*\.\w{2,4}$/;
re_url=/^http(s)?:\/\/\w(([\.-]\w)*[\w-]+)*\.\w{2,4}[\/\w-]*(\.\w{2,6})?$/;
re_urls=/^http(s)?:\/\/\w(([\.-]\w)*[\w-]+)*\.\w{2,4}[\/\w-]*(\.\w{2,6})?(\?\w.*)?$/;
re_site=/^\w(([\.-]\w)*[\w-]+)*\.\w{2,6}$/;
re_date=/^\d{2}.{1}\d{2}.{1}\d{4}$/;
re_tel=/^[\d]{10,15}$/;
re_tel2=/^[\d-]{1,100}$/;
re_tel3=/^[\d\s-+()]{1,100}$/;
re_blank=/[.]*/;
re_w=/^[\wà-ÿÀ-ß]+$/;
re_ws=/^[\s\wà-ÿÀ-ß]+$/;
re_w_sum=/^\d{1,8}((\.|,)\d{1,2})?$/;
re_w20=/^\w{1,20}$/;
re_w7=/^#\w{6}$/;
re_d20=/^\d{1,20}$/;
re_w50=/^.{1,50}$/;
re_d12=/\d{12}/;
re_de=/\d{1,9}/;
re_w8=/.{8}/;
re_w18=/.{1,8}/;
re_0=/[^0]/;

function support_mess(_value){
	if(_value == 1){
		$("#support_mess").animate({height: "show"}, 300);
	}else{
		$("#support_mess").animate({height: "hide"}, 300);
	}
}
	
function addField(formname, id, title, re) {
	if (typeof(valFields)=="undefined") valFields=new Array();
	if (typeof(valFields[formname])=="undefined") valFields[formname]=new Array();
	valFields[formname][valFields[formname].length]={id:id, title:title, re:re};
}

function formValidate(formname) {
	var i,j,k, failure=false;
	for (i in valFields[formname]) {
		j=valFields[formname][i];
		k=document.getElementById(j.id);
		if(typeof(_dont_do_space) == 'undefined'){
			k.value=trimSpaces(k.value);
		}

		if ((k.value=='' || !j.re.test(k.value)) && k.style.display!='none') {
			alert(j.title);
			failure=true;
		}
		if (failure) {
			k.focus();
			if(k.type!="select-one"){k.select();}
			break;
		}
	}
	return !failure;
}

function formVoteValidate(the_form,alerttext){
	var elts = document.forms[the_form].elements['vote_id[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')? elts.length : 0;
	if_check=false;
    if (elts_cnt) {
		for (var i = 0; i < elts_cnt; i++) {
			if(elts[i].checked){
				if_check=true;
				break;
			}
		} 
	}
	if(if_check){
		document.forms[the_form].submit();
	}else{
		alert(alerttext);
	}
}

function trimSpaces(str){
	return str.replace(/^\s+|\s+$/g, '');
}

var popUpWin=0;
function popUpWindow(URLStr,v_width,v_height){
	if(typeof(screen.height)=="undefined"){
		v_left=0;
		v_top=0;
	}else{
		v_top=(screen.height-v_height)/2;
		v_left=(screen.width-v_width)/2;
	}

	if(popUpWin){
		if(!popUpWin.closed) popUpWin.close();
	}
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+v_width+',height='+v_height+',left='+v_left+', top='+v_top+',screenX='+v_left+',screenY='+v_top+'');
}

function setAction(the_form, action){
	document.forms[the_form].action=action;
	document.forms[the_form].submit();
	return true;
}

function checkDate(cofirmText,notDatesText,the_form){
	return confirmDel(cofirmText) && checkCheckboxes(the_form,notDatesText);
}

function checkCheckboxes(the_form,text){
	var elts = document.forms[the_form].elements[select_all_vars];
    var elts_cnt  = (typeof(elts.length) != 'undefined')? elts.length : 0;
	var ret=false;
    if (elts_cnt) {
		for (var i = 0; i < elts_cnt; i++) {
			if(elts[i].checked == true){return true};
		} 
	}else{
		if(elts.checked == true){return true};
	}
	if(!ret){
		alert(text);
	}
	return ret;
}

function confirmDel(text){
    return confirm(text+'\n');
} 

function innerElementReplace(_id,_text){
	k=document.getElementById(_id);
	if(k!=null){
		k.innerHTML=_text;
	}
}

function addBookmark(url, title){
  if (!url) url = location.href;
  if (!title) title = document.title;
  
  //Gecko
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
  //IE4+
  else if (typeof window.external == "object") window.external.AddFavorite(url, title);
  //Opera7+
  else if (window.opera && document.createElement) {
    var a = document.createElement('A');
    if (!a) return false; //IF Opera 6
    a.setAttribute('rel','sidebar');
    a.setAttribute('href',url);
    a.setAttribute('title',title);
    a.click();
  }
  else return false;
  
  return true;
}

var theDefaultColor='#FFFFFF';
var thePointerColor='#F4F5F7';
var theMarkColor='#D5D5D5';
function setPointer(tableRowObj,theAction,ptheDefaultColor,pthePointerColor,ptheMarkColor){
	if (typeof(ptheDefaultColor)=="undefined" ||
		typeof(pthePointerColor)=="undefined" ||
		typeof(ptheMarkColor)=="undefined"){
		ptheDefaultColor=theDefaultColor;
		pthePointerColor=thePointerColor;
		ptheMarkColor=theMarkColor;
	}

	currentColor=tableRowObj.style.backgroundColor.toUpperCase();
	if (currentColor.indexOf("RGB") >= 0){
		 var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,currentColor.indexOf(')'));
		 var rgbValues = rgbStr.split(",");
		currentColor = "#";
		var hexChars = "0123456789ABCDEF";
		for (var i = 0; i < 3; i++){
			var v = rgbValues[i].valueOf();
			currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
		}
	}
	if (theAction == 'over') {
		tableRowObj.style.backgroundColor=(currentColor!=ptheMarkColor.toUpperCase()) ? pthePointerColor : ptheMarkColor ;
	}
	if (theAction == 'out') {
		tableRowObj.style.backgroundColor=(currentColor!=ptheMarkColor.toUpperCase()) ? ptheDefaultColor : ptheMarkColor ;
	}	
	if (theAction == 'click') {
		tableRowObj.style.backgroundColor=(currentColor!=ptheMarkColor.toUpperCase()) ? ptheMarkColor : ptheDefaultColor;	 
	}
}

