function dvg_swap( obj ){
	if ( document.getElementById( obj ).style.display=='none' ){
		document.getElementById( obj ).style.display='';
	}
	else{
		document.getElementById( obj ).style.display='none';
	}
}

function setCookie( c_name, value, expiredays ){
	var exdate = new Date();
	exdate.setDate( exdate.getDate() + expiredays );
	document.cookie = c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires=" + exdate.toGMTString() );
}

function getCookie( c_name ){
	if ( document.cookie.length > 0 ){
		c_start=document.cookie.indexOf( c_name + "=" );
		if ( c_start != -1 ){ 
			c_start = c_start + c_name.length + 1; 
			c_end = document.cookie.indexOf( ";", c_start );
			if ( c_end == -1 ) c_end=document.cookie.length;
			return unescape( document.cookie.substring( c_start, c_end ) );
		} 
	}
	return "";
}
function showAttribute( $attribute ){
	if ( document.getElementById('a'+$attribute).style.display=='none' ){
		document.getElementById('a'+$attribute).style.display='';
	}
	else{
		document.getElementById('a'+$attribute).style.display='none';
	}
}
function swapUPermission(){
	if ( document.getElementById('upermission').style.display=='none' ){
		document.getElementById('upermission').style.display='';
		document.getElementById('upermissionshow').style.display='none';
	}
	else{
		document.getElementById('upermission').style.display='none';
		document.getElementById('upermissionshow').style.display='';
	}
}
function swapUMenu(){
	if ( document.getElementById('umenu').style.display=='none' ){
		document.getElementById('umenu').style.display='';
		document.getElementById('umenushow').style.display='none';
	}
	else{
		document.getElementById('umenu').style.display='none';
		document.getElementById('umenushow').style.display='';
	}
}
function swapAL(){
	if ( document.getElementById('ald').style.display == '' ){
		document.getElementById('ald').style.display='none';
		document.getElementById('alh').style.display='';
		document.getElementById('allist').style.display='';
	}
	else{
		document.getElementById('ald').style.display='';
		document.getElementById('alh').style.display='none';
		document.getElementById('allist').style.display='none';
	}
}
function sadf( aid ){
	if ( document.getElementById('sad'+aid ).style.display == '' ){
		document.getElementById('sad'+aid ).style.display='none';
		document.getElementById('aid'+aid ).style.display='';
		document.getElementById('sadh'+aid ).style.display = '';
	}
	else{
		document.getElementById('sad'+aid ).style.display = '';
		document.getElementById('aid'+aid ).style.display='none';
		document.getElementById('sadh'+aid ).style.display = 'none';
	}
}
function hl( thing, setting ){
	if ( setting == 1 ){
		document.getElementById( thing ).className = 'spotlight';
	}
	else{
		document.getElementById( thing ).className = 'normal';
	}
}
function help_icon( thing ){
	if ( document.getElementById( thing ).style.display == '' ){
		document.getElementById( thing ).style.display = 'none';
	}
	else{
		document.getElementById( thing ).style.display = '';
	}
}
function swapVendor(){
	if ( document.getElementById( 'vs' ).style.display == 'none' ){
		document.getElementById( 'vs' ).style.display='';
		document.getElementById( 'vsd' ).style.display='none';
		document.getElementById( 'vss' ).style.display='none';
	}
}
function swapCategory(){
	if ( document.getElementById( 'cs' ).style.display == 'none' ){
		document.getElementById( 'cs' ).style.display='';
		document.getElementById( 'csd' ).style.display='none';
		document.getElementById( 'css' ).style.display='none';
	}
}
function swapDepartment(){
	if ( document.getElementById( 'ds' ).style.display == 'none' ){
		document.getElementById( 'ds' ).style.display='';
		document.getElementById( 'dsd' ).style.display='none';
		document.getElementById( 'dss' ).style.display='none';
	}
}
function swapProductCode(){
	if ( document.getElementById( 'ps' ).style.display == 'none' ){
		document.getElementById( 'ps' ).style.display='';
		document.getElementById( 'psd' ).style.display='none';
		document.getElementById( 'pss' ).style.display='none';
	}
}
function swaptaskrank(){
	if ( document.getElementById( 'diff' ).style.display == '' ){
		document.getElementById( 'diff' ).style.display='none';
		document.getElementById( 'pval' ).style.display='none';
		document.getElementById( 'cval' ).style.display='none';
		document.getElementById( 'pri' ).style.display = 'none';
	}
	else{
		document.getElementById( 'diff' ).style.display='';
		document.getElementById( 'cval' ).style.display='';
		document.getElementById( 'pval' ).style.display='';
		document.getElementById( 'pri' ).style.display = '';
	}
}
function countdown( element_id, time ){
	var x = document.getElementById(element_id);
	var t = time;
	function html(h) {
		if (x) x.innerHTML = h;
	}
	function doCount(){
		if (t<=0) html('TIME HAS RUN OUT');
		else {
			var d = Math.floor(t/86400), h = Math.floor(t/3600)%24, m = Math.floor(t/60)%60, s = t%60, out = '';
			// Full string
			out = (d?d+" Day"+(d!=1?"s":"")+", ":"")+h+" Hour"+(h!=1?"s":"")+" "+m+" Minute"+(m!=1?"s":"")+s+" Second"+(s!=1?"s":"");
			// Trimed string
			out = m+" min "+s+"s";
			html(out);
			t--;
			window.setTimeout(doCount,1000);
		}
	};
	doCount();
}
