sfHover = function() {
  
  if( document.getElementById('naviMain') ){
	
	var sfEls = document.getElementById("naviMain").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
  }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);




function validateCmsForm(obj){
	var errorMsg = '';
	for(var i=1;i<= obj.length;i++){
		if(obj['field['+i+']'] && obj['error_field['+i+']'] ){
			var checkVal = obj['error_field['+i+']'].value.split('|');
      setHighlight = false;
			switch (checkVal[1]) {
				case 'text':
					if(obj['field['+i+']'].value.length < checkVal[2]){
						errorMsg+="-> "+checkVal[0]+"\n";
            setHighlight = true;
					}
				break;
				case 'email':
					if(obj['field['+i+']'].value.indexOf('@')==-1 || obj['field['+i+']'].value.indexOf('.')==-1){
						errorMsg+="-> "+checkVal[0]+"\n";
            setHighlight = true;
					}
				break;
				case 'num':
					if( isNaN(obj['field['+i+']'].value) ){
						errorMsg+="-> "+checkVal[0]+"\n";
            setHighlight = true;
					}
				break;
				case 'date':
          var arrDate = obj['field['+i+']'].value.split('.');
          var dateNow = new Date();
          var setNow = dateNow.getTime() + (checkVal[2] * 24 * 3600 * 1000);
          var dateCheck = new Date(arrDate[2],(arrDate[1]-1),arrDate[0]);
          if( setNow > dateCheck.getTime() || isNaN(dateCheck.getTime()) ){
						errorMsg+="-> "+checkVal[0]+"\n";
            setHighlight = true;
          }
				break;
			}
      if( setHighlight == true){
        document.getElementById('field['+i+']').className = "inputError";
      }else{
        document.getElementById('field['+i+']').className = "";
      }
		}
	}
  if( errorMsg.length > 0 ){
    alert(obj["error_title"].value+" \n\n"+errorMsg);
		return false;
  }
}




function UnCryptMail(s){
	var n=0;
	var r="";
	for( var i=0; i < s.length; i++ ){
		n=s.charCodeAt(i);
		if( n>=8364 ){ n = 128; }
		r+= String.fromCharCode(n-(1));
	}
	return r;
}
function linkToUnCryptMail(s){
	location.href=UnCryptMail(s);
}

function checkPrice(price){
  
  var strPrice = String(price);
  strPrice = strPrice.replace(".", ",");
  
  if( strPrice.substr(-2, 1) == ',' ){
    strPrice = price+"0";
  }else if( strPrice.search(/,/) == -1 ){
    strPrice = strPrice+",00";
  }else if( strPrice.search(/,000/) != -1 ){
    var strSplit = strPrice.split(",");
    strPrice = strSplit[0]+",00";
  }else if( strPrice.search(/,999/) != -1 ){
    var strSplit = strPrice.split(",");
    strPrice = eval(strSplit[0]+'+'+1)+",00";
  }
  
  return strPrice;
  
}