var isDebug = true;
function DIY_Browser() {
 d=document;
 this.agent=navigator.userAgent.toLowerCase();
 this.major = parseInt(navigator.appVersion);
 this.dom=(d.getElementById)?1:0; // true for ie6, ns6
 this.ns=(d.layers);
 this.ns4up=(this.ns && this.major >=4);
 this.ns6=(this.dom&&navigator.appName=="Netscape");
 this.op=(this.agent.indexOf('opera')!=-1&&this.major<7);
 this.opera5=(this.agent.indexOf("Opera 5")>-1);
 this.ie=(d.all);
 this.ie4=(d.all&&!this.dom)?1:0;
 this.ie4up=(this.ie && this.major >= 4);
 this.ie5=(d.all&&this.dom);
 this.ie6=(this.agent.indexOf("msie 6")>-1 && this.dom && !this.opera5)?1:0;
 this.ie7=(this.agent.indexOf("msie 7")>-1 && this.dom && !this.opera5)?1:0;
 this.win=((this.agent.indexOf("win")!=-1) || (this.agent.indexOf("16bit")!=-1));
 this.mac=(this.agent.indexOf("mac")!=-1);
}

var oBw = new DIY_Browser();

function getObject(n, d) { //v4.01
	var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=getObject(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function checkLength(obj,num,op){
	var inputLength=obj.replace(/[^\x00-\xff]/g,'**').length;
	var rv = false;
	if (op==">"){ rv = inputLength>num;}
	if (op=="<"){ rv = inputLength<num;}
	if (op=="="){ rv = inputLength!=num;}
	return rv;
}

function MyGetKeyCode(e){
	var code;
	if (!e) var e = window.event;
	if (e.keyCode){
    code = e.keyCode;
	}else if (e.which){
    code = e.which;
	}
  return code;
}

//-2.36onkeypress
function MyCheckNum(obj,e)
{
  var code = MyGetKeyCode(e);
  if ((code<45 || code>57 || code==47) && code!=45 && code!=9 && code!=8) return false;
  if(code==46 && obj.value.indexOf(".")>-1) return false;
  return true;
}

//325onkeypress
function MyCheckInt(obj,e)
{
  var code = MyGetKeyCode(e);
  if ((code<48 || code>57) && code!=45 && code!=9 && code!=8) return false;
  return true;
}

function MyOnfocusSelect(obj){
	if (obj.type=="text"){
		obj.select();
	}
}

function getFullName(path){
  var tmp = path;
	var pos = -1;
	pos = tmp.lastIndexOf("\\");
	if (pos==-1){
	  pos = tmp.lastIndexOf("/");
	}
	if (pos==-1){
	  return path;
	}else{
	  return tmp.substring(pos+1);
	}
}

//return abc
function getName(path){
  var tmp = path;
	var pos = -1;
	var endPos = -1;
	pos = tmp.lastIndexOf("\\");
	if (pos==-1){
	  pos = tmp.lastIndexOf("/");
	}
	endPos = tmp.indexOf(".",pos);
	if (endPos==-1){
	  return tmp.substring(pos+1);
	}else{
	  return tmp.substring(pos+1,endPos);
	}
}

/**
 * Get file's extends
 */
function getFileExt(path){
	var tmp = path;
	tmp = tmp.substring(tmp.lastIndexOf(".")+1);
	return tmp.toUpperCase();
}

/**
 * Clear the object in the form
 * @param obj -- The object in the form
 */
function MyClearObject(obj){
    obj.value = "";
}



/**
 * Check file's extends name in extList
 */
function MyCheckExt(path,extList){
	var ext = getFileExt(path);
	extList = extList.toUpperCase();
	var cExt = extList.indexOf("," + ext + ",");
	if (ext == "") return -1;
	if (cExt==-1){
		return 0;
	}else{
		return 1;
	}
}

function MyStr2Float(as_str,ai_digit,as_type)
{
   var fdb_tmp = 0;
   var fi_digit = 0;
   var fs_digit = "1";
   var fs_str = "" + as_str;
   var fs_tmp1 = "";
   var fs_tmp2 = "";
   var fi_pos = 0;
   var fi_len = 0;
   fdb_tmp = parseFloat(isNaN(parseFloat(fs_str))?0:fs_str);

   switch (true)
   {
      case (ai_digit==null)://
         fdb_tmp = fdb_tmp;
         break;
      case (ai_digit==0)://
         fdb_tmp = Math.round(fdb_tmp);
         break;
      case (ai_digit>0)://
         for (var i=0;i<ai_digit;i++) fs_digit +="0";
         fi_digit = parseInt(fs_digit);
         fdb_tmp = Math.round(fdb_tmp * fi_digit) / fi_digit;
         if (as_type=="str")
         {
            fs_tmp1 = fdb_tmp.toString();
            fs_tmp1 +=((fs_tmp1.indexOf(".")!=-1)?"":".") + fs_digit.substr(1);
            fi_pos = fs_tmp1.indexOf(".") + 1 + ai_digit;
            fdb_tmp = fs_tmp1.substr(0,fi_pos);
         }
         break;
   }
   return fdb_tmp;
}


function ClearSelected(obj,index){
  if (obj != null){
    if(obj.length==null){
		  if (index==-1) obj.checked = false;
    }else{
      for (i = 0 ; i< obj.length ; i++){
			  if (index!=-1 && index==i){
				  obj[i].checked = true;
				}else{
          obj[i].checked = false;
				}
      }
    }
  }
}

function SelectedAll(obj){
  if (obj != null){
    if(obj.length==null){
		  obj.checked = true;
    }else{
      for (i = 0 ; i< obj.length ; i++){
			  obj[i].checked = true;
      }
    }
  }
}
function FocusOptions(obj){
	if (obj != null){
		if(obj.length==null){
			obj.focus();
		}else{
			obj[0].focus();
		}
	}	
}
function CheckIsSelected(obj){
	var ischeck = false;
	if (obj != null){
		if(obj.length==null){
			if (obj.checked == true) ischeck = true;
		}else{
			for (i = 0 ; i< obj.length ; i++){
				if (obj[i].checked == true){ischeck = true;break;}
			}
		}
	}
	return ischeck;
}


function getSelectedValue(obj){
	var v = "";
	var t = "checkbox";
	if (obj != null){
		t = obj.type;
		if(obj.length==null){
			if (obj.checked == true) v = obj.value;
		}else{
			for (i = 0 ; i< obj.length ; i++){
				if (obj[i].checked == true){
				  v += ", " + obj[i].value;
					if (t == "radio") break;
				}
			}
		}
	}
	return v.substring(2);
}

function OperateSelect(sel,ddl){
	var selectType;
	var obj=sel;
	try{
		selectType = ddl.value
		ddl.options[0].selected=true;
	}catch(e){
		selectType = ddl
	}
	if(obj){
		if(obj.length==null){
			if (!obj.disabled){
				switch (selectType){
					case "all":obj.checked=true;break;
					case "invert":obj.checked=!obj.checked;break;
					case "none":obj.checked=false;break;
				}
			}
		}else{
			for (var i = 0 ; i< obj.length ; i++){
				if (!obj[i].disabled){
					switch (selectType){
						case "all":obj[i].checked=true;break;
						case "invert":obj[i].checked=!obj[i].checked;break;
						case "none":obj[i].checked=false;break;
					}
			  }
			}
		}
	}
}

function OperateSelectCustom(frmName,selPrefix,stuffix,ddl){
	var selectType;
	var obj=stuffix;
	var objSel = null;
	try{
		selectType = ddl.value
		ddl.options[0].selected=true;
	}catch(e){
		selectType = ddl
		alert("ss")
	}
	if(obj){
		if(obj.length==null){
			if (!obj.disabled){
				objSel = eval("document." + frmName + "." + selPrefix + obj.value);
				switch (selectType){
					case "all":objSel.checked=true;break;
					case "invert":objSel.checked=!objSel.checked;break;
					case "none":objSel.checked=false;break;
				}
			}
		}else{
			for (var i = 0 ; i< obj.length ; i++){
				if (!obj[i].disabled){
					objSel = eval("document." + frmName + "." + selPrefix + obj[i].value);

					switch (selectType){
						case "all":objSel.checked=true;break;
						case "invert":objSel.checked=!objSel.checked;break;
						case "none":objSel.checked=false;break;
					}
			  }
			}
		}
	}
}

function SetSelectItem(ddl,v){
	for (var i = 0 ; i<ddl.options.length;i++){
		if (ddl.options[i].value==v){
			ddl.options[i].selected = true;
			break;
		}
	}
}

function PreviewPic(path){
  if (path == ""){
		alert("Please select a pic");
  }else{
		window.open("previewImage.asp?img=" + path,"preImg","");
  }
}

function AddFavorite(sURL, sTitle){
	try
	{
			window.external.addFavorite(sURL, sTitle);
	}
	catch (e)
	{
			try
			{
					window.sidebar.addPanel(sTitle, sURL, "");
			}
			catch (e)
			{
					alert("加入收藏失败，有劳您手动添加。");
			}
	}
}

/**
 * Tempate used
 */
function getRadio(w,h,mw,mh){
	var rw = mw/w;
	var rh = mh/h;
	var r = Math.min(rw,rh);
	if (mw ==0 && mh == 0){
		r = 1;
	}else if (mw == 0){
		r = rh<1?rh:1;
	}else if (mh == 0){
		r = rw<1?rw:1;
	}
	w = w*r;
	h = h*r;
	return [w,h];
}

/**
 ԶѹͼƬ
 */
function AutoResizeImage(maxWidth,maxHeight,objImg){
	objImg = $(objImg);
	if (objImg.src.indexOf("blank.gif")!=-1) return;
	var img = new Image();	
	img.onload = function(){
	  var hRatio;
		var wRatio;
		var Ratio = 1;
		var w = img.width;
		var h = img.height;
		wRatio = maxWidth / w;
		hRatio = maxHeight / h;
		wRatio = wRatio>1?1:wRatio;
		hRatio = hRatio>1?1:hRatio;
		if (maxWidth ==0 && maxHeight==0){
			Ratio = 1;
		}else if (maxWidth==0){//
			Ratio = hRatio;
		}else if (maxHeight==0){
			Ratio = wRatio;
		}else {
			Ratio = (wRatio<=hRatio?wRatio:hRatio);
		}
		if (Ratio<1){
		  w = w * Ratio;
		  h = h * Ratio;
		}
		objImg.height = h;
		objImg.width = w;
		AlphaImageLoader(objImg);
		
		this.onload = function(){}
	}
	img.src = objImg.src;
}

function AlphaImageLoader(img){
  if (is_ie6down){
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + " ' " : " "
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText 
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle  
			
			var strNewHTML = "<img src=\"images/blank.gif\" " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\">" 
			img.outerHTML = strNewHTML
			//Debug(strNewHTML);
		}
	}
}

function Debug(info,displayTime){
  if (isDebug){
    if (arguments.length<=0) return ;
    var objdebug = $('JsDebugContent');
    d = document;
    if (!objdebug && parent!=null){
      parent.Debug(info,displayTime);
      return;
    }
    if (!objdebug){
      return;
    }
    displayTime = displayTime?true:false;
    infoType = typeof info;
    if (infoType=="object"){
      if (info){
				if (info.type){
					infoType = '<span style="font-style:italic;">typeof</span> : [' + infoType + ']<br/>\
											<span style="font-style:italic;">type</span> : [' + info.type + ']<br/>\
											<span style="font-style:italic;">len</span> : ['+(info.length?info.length:'')+']<br/>\
											<span style="font-style:italic;">value</span> : [' + (info.value?info.value.escapeHTML():'undefined') +']<br/>';
				}else{
					infoType = '[' + infoType + ']';
				}
				infoType +='<span style="font-style:italic;">toString</span> : ' + info.toString();
				info = infoType;
			}else{
				info = '<span style="font-style:italic;">typeof</span> : [' + infoType + ']<br/><span style="font-style:italic;">value</span> : [null]';
			}
    }else if (infoType=="undefined"){
      info = '<span style="font-style:italic;">typeof</span> : [undefined]';
    }else if (infoType=="string"){
      info = info.escapeHTML();
    }else{
			info = '<span style="font-style:italic;">typeof</span> : [' + infoType + '],value:[' + info.toString() + ']';
		}
    info = "{" + info + "}";
	  var div = document.createElement("div");
	  Element.setStyle(div,{width:'96%',fontSize:'16px',backgroundColor:objdebug.childNodes.length % 2==0?'#efefef':''});
	  if (displayTime){
		  div.innerHTML = '<table border="0" cellspacing="0" cellpadding="2">\
		                   <tr>\
		                   <td style="font-style:italic;" valign="top">'+new Date().toString('HH:mm:ss')+'</td>\
		                   <td style="word-break:break-all;">' + info + '</td></tr></table>';
		}else{
		  div.innerHTML = '<table width="100%"><tr><td style="word-break:break-all;">' + info + '</td></tr></table>';
		}
		objdebug.appendChild(div);
		
		$('debugHideBut').isHide = true;
		if (document.all){
		  $('debugHideBut').click();
		}else{
      var evt = document.createEvent("MouseEvents"); 
      evt.initEvent("click",true,true); 
      $('debugHideBut').dispatchEvent(evt); 
		}
	}	
}

function enableDebug(){
  var div = document.createElement("div");
  div = $(div);
  div.setAttribute("id","JsDebug");
  div.addClassName("Debug")
  div.setStyle({width: '450px',height: '150px',left:'-440px',textAlign:'left',display:isDebug?'':'none',padding:'0px',overflow:'hidden'});
  
  div.innerHTML = '<div id="JsDebugTitle" style="background-color:#000000;color:#FFFFFF;text-align:left;padding:0px;">\
  <table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>\
  <td style="">Debug Information [<span id="_debug_time_now"></span>]</td>\
  <td style="width:30px;text-align:right;"><span style="cursor:pointer;" id="clearHander">clear</span></td>\
  <td style="text-align:right;width:20px"><span id="debugHideBut" isHide="true" style="cursor:pointer;">&gt;</span></td>\
  </tr></table></div>\
  <div id="JsDebugContent" style="width:450px; height:135px;text-align:left;padding:0px;overflow-x:hidden;overflow-y:scroll;"></div>';

  document.body.insertBefore(div,document.body.firstChild);

  $('debugHideBut').onclick = function(){
    if (this.isHide){
      $('JsDebug').setStyle({left:'1px'});
      this.isHide = false;
      this.innerHTML = '&lt;';//<<
    }else{
      $('JsDebug').setStyle({left: -(Element.getWidth('JsDebug') - 10) + 'px'});
      this.isHide = true;
      this.innerHTML = '&gt;';//>>
    }
  }
  $('clearHander').onclick = function(){
    $('JsDebugContent').innerHTML='';
		if (document.all){
		  $('debugHideBut').click();
		}else{
      var evt = document.createEvent("MouseEvents"); 
      evt.initEvent("click",true,true); 
      $('debugHideBut').dispatchEvent(evt); 
		}
  }
  Event.observe(window, "scroll", scrollDebug);
  scrollDebug();
  window.setInterval('$("_debug_time_now").innerHTML=(new Date()).toString("yyyy-MM-dd HH:mm:ss");',1000);
}

function scrollDebug(){
	var page = getPageSize();
	var pageScroll = getPageScroll();
	$('JsDebug').style.top = (pageScroll[1] + page[3] - $('JsDebug').getHeight()-2) + 'px';	
}

var Ads = Class.create();
Ads.prototype = {
  initialize: function() {
	  if (arguments!=null){
			if (arguments[0]!=null){
			  this.id = arguments[0];
			  this.parent = $(arguments[0]);
				this.numberTab = "number" + this.id;
				this.contentTab = "content" + this.id;
			}
			if (arguments[1]!=null){
        this.height = arguments[1];
			}
		  if (arguments[2]!=null){
        this.path = arguments[2];
			}
			if (arguments[3]!=null){
        this.adsData = arguments[3];
			}
			if (arguments[4]!=null){
        this.objectAds = arguments[4];
			}
			if (arguments[5]!=null){
			  this.isAutoScroll = arguments[5];
			}
		}
		this.adsWidth = 200;
		this.currentId = "";
		this.currentIndex = 0;
		this.firstRand = "";
		this.totalAds = this.adsData.length;
		this.adsHander = this;
		this.numbers = [];
		this.interval = null;
		this._createAdsModule();
		this.startTime = new Date().getTime();
		this.switchAds($("l" + this.currentId));
		if (this.isAutoScroll){
		  this.interval = window.setInterval(this.objectAds + ".autoScroll()",4000);
		}
  },
	_createAdsModule: function(){
	  var content = '<div class="tpbnbox">\
			<div class="tpbntabs">\
				<div class="tpbntabsbg">\
					<span class="tabCell" id="' + this.numberTab + '">\
					</span>\
				</div>\
			</div>\
			<ol class="tpbnpans" id="' + this.contentTab + '">\
			</ol>\
			<i class="mask tl"></i><i class="mask tr"></i><i class="mask bl"></i><i class="mask br"></i>\
		</div>';
		this.parent.innerHTML = content;
		var box = $($(this.numberTab).parentNode.parentNode.parentNode);
		box.setStyle({height:this.height + "px"});
		this.adsWidth = box.getWidth();
		this._createAds();
	},
	_createAds: function(){
	  //Debug(this.adsData.length);
		var objectAds = this.objectAds;
		var adsHander = this.adsHander;
		for(var i=0;i<this.adsData.length;i++){
		  //if (i>0) break;
			var rand = this.getRandom(5);
			var data = this.adsData[i];
			var a = document.createElement("a");
			a = $(a);
			a.setAttribute("id","l" + rand);
			a.setAttribute("href","javascript:void(0);");
			a.setAttribute("title",data.name.encodeToHtml());
			a.index = i;
			a.rand = rand;
			var linkText=document.createTextNode(i+1);
			//a.innerText = i+1
			//a.textContent = i+1;
			a.appendChild(linkText);
			if (i==0) {
				this.currentId = rand;
				this.currentIndex = i;
				a.addClassName("current");
			}
			a.onclick=function(){
			  if (adsHander.currentId!=this.rand){
					adsHander.switchAds(this);
				}
				if (adsHander.isAutoScroll){
					window.clearInterval(eval(objectAds + ".interval"));
					adsHander.interval = window.setInterval(objectAds + ".autoScroll()",4000);
				}
				return false;
			}
			this.numbers[i] = a;
			$(this.numberTab).appendChild(a);
			
			var li = document.createElement("li");
			li = $(li);
			li.setAttribute("id","li" + rand);
			li.addClassName("pan");

			li.style.display = "";
			li.style.visibility = "hidden";
			
			if (data.image==""){
			  li.isImage = false;
			  li.addClassName("hover");
				li.innerHTML = '<div class="contentBox"><div class="contentBoxBg"><h4>' + data.name + '</h4>' + data.text.encodeToHtml() + '</div></div>';
			}else{
			  li.isImage = true;
			  li.removeClassName("hover");
				li.onmouseover = function(){
					$(this).addClassName("hover");
				}
				li.onmouseout = function(){
					$(this).removeClassName("hover");
				}

				li.innerHTML = '<div>' + createModule(this.path,data.image,this.adsWidth,this.height,0,"","",' alt="" ') + '</div>';
				li.innerHTML +='<div class="contentBox"><div class="contentBoxBg"><h4>' + data.name + '</h4>' + data.text.encodeToHtml() + '</div></div>';
			}
			
			if (i==0){
			  var rand = this.getRandom(5);
			  this.firstRand = rand;
				var lifirst = document.createElement("li");
				lifirst = $(lifirst);
				lifirst.setAttribute("id","li" + rand);
				lifirst.addClassName("pan");
				lifirst.style.display = "";
				lifirst.style.visibility = "visible";
				if (li.isImage){
				  lifirst.removeClassName("hover");
					lifirst.onmouseover = function(){
						$(this).addClassName("hover");
					}
					lifirst.onmouseout = function(){
						$(this).removeClassName("hover");
					}
				}else{
				  lifirst.addClassName("hover");
				}
				lifirst.innerHTML = li.innerHTML;
				
				$(this.contentTab).appendChild(lifirst);
		  }
		  $(this.contentTab).appendChild(li);
		}
		if (this.adsData.length<=1){
		  $($(this.numberTab).parentNode.parentNode).hide();
		}
	},
	switchAds: function(onum){
	  if (this.isIE5Up()){
	    var currentLi = $("li" + onum.rand);
	    var firstLi = $("li" + this.firstRand);
			firstLi.style.filter="blendTrans(duration=1.5) revealTrans(duration=1.0,transition=" + this.getEffectRand() + ")";
			firstLi.filters(0).apply();
			firstLi.filters(1).apply();
			
			if (currentLi.isImage){
			  firstLi.removeClassName("hover");
				firstLi.onmouseover = function(){
					$(this).addClassName("hover");
				}
				firstLi.onmouseout = function(){
					$(this).removeClassName("hover");
				}
			}else{
			  firstLi.addClassName("hover");
				firstLi.onmouseover = function(){}
				firstLi.onmouseout = function(){}
			}
			firstLi.innerHTML = currentLi.innerHTML;
			firstLi.filters(0).play();
			firstLi.filters(1).play();			
	  }else{
			if (this.currentId!=onum.rand){
			  this.fadeOut(this.currentId,99.999);
			}
			this.fadeIn(onum.rand,0);
    }
		$("l" + onum.rand).addClassName("current");
		if (this.currentId!=onum.rand){
		  $("l" + this.currentId).removeClassName("current");
		}
		this.currentId = onum.rand;
		this.currentIndex = onum.index;
		var nowTime = new Date().getTime();
		Debug((nowTime-this.startTime)/1000 + "s");
		this.startTime = nowTime;
	},
	autoScroll: function(){
	  if (this.currentIndex + 1 < this.totalAds){
		  this.switchAds(this.numbers[this.currentIndex+1]);
		}else{
		  this.switchAds(this.numbers[0]);
		}
	},
	
	getRandom: function(digit){
    return Math.round(Math.random()*Math.pow(10,digit))
  },
  getEffectRand: function(){
    var e = Math.round(Math.random() * 30);
    if (e>23){
      return this.getEffectRand();
    }else{
      return e;
    }
  },
  isIE5Up: function(){
		var browser = navigator.userAgent;
		var startPos = browser.indexOf("MSIE");
		if (startPos < 0)return false;
		var IEversion = parseInt(browser.substring(startPos+5, browser.indexOf(".", startPos)));
		return (IEversion >= 5)
  },
  setOpacity:function(obj, opacity){
		if (obj != null){
			opacity = (opacity == 100)?99.999:opacity;
			// IE/Win
			obj.style.filter = "alpha(opacity:"+opacity+")";
			// Safari<1.2, Konqueror
			obj.style.KHTMLOpacity = opacity/100;
			// Older Mozilla and Firefox
			obj.style.MozOpacity = opacity/100;
			// Safari 1.2, newer Firefox and Mozilla, CSS3
			obj.style.opacity = opacity/100;
		}
	},
	fadeOut:function(rand,opacity){
		var adObj = $("li" + rand);
		if (adObj != null){
			if (opacity > -1){
				this.setOpacity(adObj, opacity);
				opacity -= 10;
				window.setTimeout(this.objectAds + ".fadeOut('"+rand+"',"+opacity+")", 100);
			}else{
				adObj.style.visibility = "hidden";
				adObj.style.zIndex=1;
			}
		}
	},
  fadeIn:function(rand,opacity){
		var adObj = $("li" + rand);
		if (adObj != null){
			if (opacity <= 99.999){
				adObj.style.visibility = "visible";
				adObj.style.zIndex=9999;
				this.setOpacity(adObj, opacity);
				opacity += 10;
				window.setTimeout(this.objectAds + ".fadeIn('"+rand+"',"+opacity+")", 100);
			}
		}
	}
}

Object.extend(String.prototype, {
  encodeToHtml: function() {
    return this.replace(/\n/gi,"<br/>");
  },
  encodeFormValue: function(){
    return this.replace(/\"/g,"&quot;").replace(/</g,'&lt;').replace(/>/g,'&gt;');;
  }
});


function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

// ---------------------------------------------------

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}

}
