function elm(e){
	return document.getElementById(e);
}
function show(e){
	if(elm(e))
		elm(e).style.display='';
}
function hide(e){
	if(elm(e))
		elm(e).style.display='none';
}
function showHide(e){
	if(elm(e))
		with(elm(e).style)
			display=(display=='none'?'':'none');
}
function getCookie(c){
	var splited,a,i;
	if(!c)return null;
	splited=document.cookie.split(';');
	if(!splited)return null;
	for(i=0;i<splited.length;i++){
		a=splited[i].split('=');
		if(a[0].substring(0,1)==' ')a[0]=a[0].substring(1,a[0].length);
		if(a[0]==c)return(a[1]);
	}
	return null;
}
function setCookie(name,value){  
	var argv,argc,expires,path,domain,secure;
	argv=setCookie.arguments;  
	argc=setCookie.arguments.length;  
	expires=(argc>2)?argv[2]:null;  
	path=(argc>3)?argv[3]:null;  
	domain=(argc>4)?argv[4]:null;  
	secure=(argc>5)?argv[5]:false;  
	document.cookie=name+"="+escape(value) 
		+((expires==null)?"":("; expires="+expires.toGMTString()))
		+((path==null)?"":("; path="+path)) 
		+((domain==null)?"":("; domain="+domain))   
		+((secure==true)?"; secure":"");
}
function deleteCookie(name){  
	var exp=new Date();  
	exp.setTime(exp.getTime()-1);  
	var cval=getCookie(name);  
	document.cookie=name+"="+cval+"; expires="+exp.toGMTString();
}
function window_open(url,name,width,height){
	var w=window.open(url,name,'left=16, top='+(window.screen.height>600?104:16)
		+', width='+width+', height='+height+', toolbar=no, menubar=no, '
		+'directories=no, location=yes, scrollbars=yes, resizable=yes, status=no');
	if(w.opener==null)w.opener=self;
	w.focus();
	return!(w);
}
function window_open2(url,name){
	return window_open(url,name,512,256);
}
function withCheckboxes(prefix,op){
	if(!document.getElementById)return false;
	for(i=0;true;i++){
		if(e=elm(prefix+i))
			switch(op){
			case 0:e.checked=false; break;
			case 1:e.checked=true; break;
			case-1:e.checked=!e.checked;
			} 
	else return;
	} 
}
function externalLinks(){
	if(!document.getElementsByTagName)return;
	var i,a,anchors=document.getElementsByTagName("a");
	for(i=0;i<anchors.length;i++){
		a=anchors[i];
		if(a.getAttribute("href") && a.getAttribute("rel")=="external")
			a.target="_blank";
	}
}
function checkTextAreas(){
	for(i=0;i<textareas.length;i+=2){
		id=textareas[i];
		max=textareas[i+1];;
		if(e=elm(id))
			v=e.value;
		else
			continue;
		if(v.length>max)
			elm(id).value=v.substr(0,max);
		if(t=elm(id+'length'))
			t.innerHTML=max-v.length;
	} 
	setTimeout("checkTextAreas()",1000);
}
function placeBubble(e){
	if(document.all){
		x=e.clientX+document.body.parentNode.scrollLeft;
		y=e.clientY+document.body.parentNode.scrollTop;
	}else{
		x=e.pageX;
		y=e.pageY;
	}
	if(b=elm(bubble))
		with(b.style){
			display='inline-block';
			position='absolute';
			w=window.innerWidth;
			w2=(w>1000?w-1000:0)/2;
			left=(x-w2)*0.68+'px';
			top=(y+5)+'px';
		}
}
function sleep(milliseconds){
	var start=new Date().getTime();
	for(var i=0;i<1e7;i++)
		if((new Date().getTime()-start)>milliseconds)
			break;
}

