﻿function setbg(This,cssName){
	This.className=cssName;
	This.onmouseout=function(){this.className='';}
}

function SetNavCss(){
	var navs = document.getElementById("Nav").getElementsByTagName("A");
	var pathname = window.location.pathname.toLowerCase().split('/');
	var pagePath = pathname[pathname.length-1];
	for(i=0;i<navs.length;i++){
		var pname=navs[i].href.toLowerCase();
		if(pname.indexOf(pagePath)!=-1){
			navs[i].className='NavOnSelect';
		}else{
			navs[i].className='';
		}
	}
}

function showStar(id,level){
	var oElement = document.getElementById(id);
	var showStarLevel;
	
	if ( level == 1  ){ showStarLevel = "background:url(templates/images/Star.gif) no-repeat;" }
	else if (  level == 2 ){ showStarLevel = "background:url(templates/images/Star.gif) no-repeat 0% 17%;" }
	else if ( level == 3  ){ showStarLevel = "background:url(templates/images/Star.gif) no-repeat 0% 33%;" }
	else if ( level == 4  ){ showStarLevel = "background:url(templates/images/Star.gif) no-repeat 0% 50%;" }
	else if ( level == 5  ){ showStarLevel = "background:url(templates/images/Star.gif) no-repeat 0% 67%;" }
	
	oElement.innerHTML = "<span style='height:24px;width:100px;" + showStarLevel + "'></span>";
}

function cint(_id){if(isNaN(_id)){return 0}else{return Number(_id)}}
function reImgSize(This,w,h){
  var _width = w;
  var _height= h;
  var picW = cint(This.width);
  var picH = cint(This.height);
	if(picW > _width){
		This.style.width=_width+'px';
	}
	if(picH > picW){
		This.style.width='auto';
		This.style.height=_height+'px';
	}
	if(picW==picH){
		This.style.width = _height+'px';
	}
}
