//CDS JS FUNCTIONS
function isset(varname){
  return(typeof(window[varname])!='undefined');
}


function swapsms(st,sms){
	if(st==1){
		document.getElementById("sms").innerHTML=sms;
	}else{
		document.getElementById("sms").innerHTML="";
	}
}


function swapcss(st,questo,cssname){
	if(st==1){
		if(questo.value==''){
			questo.className=cssname+"_over";
		}else{
			questo.className=cssname+"_over";
		}
	}else{
		if(questo.value==''){
			questo.className=cssname+"_out";
		}else{
			questo.className=cssname+"_out";
		}
	}
}


function opendoc(url, tool, menu, loc, scroll, resize, status, x, y, w, h) {
	if(x=='auto'){ x=(screen.width-w)/2; }
	if(y=='auto'){ y=((screen.height-h)/2)-20; }
win = this.open(url, "CtrlWindow", "toolbar=" + tool + ",menubar=" + menu + ",location=" + loc + ",scrollbars=" + scroll + ",resizable=" + resize + ",status=" + status + ",left=" + x + ",top=" + y + ",width=" + w + ",height=" + h);
}	


function txt_counter(questo,limit){
	num=limit-questo.value.length;
	if(questo.value.length>limit){questo.value=questo.value.substring(0,limit);}
	if(num<0){num=0;}
	document.getElementById(questo.name+"_counter").innerHTML="["+limit+"/"+num+"]";
}


function input_mod(mod_type,obj_input,obj_form,set_val){
	obj=document.getElementById(obj_form);
	x=obj.elements[obj_input];
	x_def=set_val;
	x_cur=x.value;
	switch(mod_type){
		case "num_add":
			x.value=parseInt(x_cur)+1;
		break;

		case "num_rem":
			x.value=parseInt(x_cur)-1;
		break;

		case "num_reset":
		x.value=x_def;
		break;
	}
}



function cds_swap_display(oggetto){
	x=document.getElementById(oggetto);
	x.style.display=(x.style.display!="block")? "block" : "none"
}


function getTop(layName){
	if(document.all)                    //e4,e5,e6,o6,o7?
	  return document.all(layName).style.pixelTop
	else if(document.getElementById)    //n6,n7,m1,s1?
	  return (document.getElementById(layName).style.top!="")
			  ?parseInt(document.getElementById(layName).style.top):""
	else if(document.layers)            //n4?
	  return document.layers[layName].top 
}


function getLeft(layName){
	if(document.all)                    //e4,e5,e6,o6,o7?
	  return document.all(layName).style.pixelLeft
	else if(document.getElementById)    //n6,n7,m1,s1?
	  return (document.getElementById(layName).style.left!="")
			  ?parseInt(document.getElementById(layName).style.left):""
	else if(document.layers)            //n4?
	  return document.layers[layName].left 
}




function init() {
// interrompi se questa funzione è stata già chiamata
if (arguments.callee.done) return;
// contrassegna questa funzione in modo da non fare due volte la stessa cosa
arguments.callee.done = true;
// interrompi il timer
if (_timer) {
	clearInterval(_timer);
	_timer = null;
}
//////////////////////////////////////////////////////////
inf=navigator.userAgent.toUpperCase();
if(inf.indexOf("MSIE 6")<0){
	//MSIE6 functions
	//alert("MSIE 6");
}

if(set_js_init!='undefined'){
if(set_js_init==1){

	switch(set_page){//start switch page
		case "index":
		/////////////////////index
			switch(set_section){//start switch section
				case 1:
				break;
			}//end switch section
		/////////////////////end_index
		break;


		case "agel_user":
		/////////////////////adm_user
		/////////////////////end_adm_user
		break;


		case "adm_newsmail":
		/////////////////////adm_newsmail
			switch(set_section){//start switch section
				case 8:
				//expandcontent('vis_sect_1');
				//expandcontent('vis_sect_3');
				break;
			}//end switch section
		/////////////////////end adm_newsmail
		break;
	

		default:
		/////////////////////default
			if(set_js_mode=="www"){
				agel_main.salign='T';
				agel_main.scale='noborder';
				agel_main.height=110;
				
				document.getElementById('main_login').style.left='10px';
				document.getElementById('main_login').style.top='69px';
				document.getElementById('main_sms').style.left='10px';
				document.getElementById('main_sms').style.top='91px';
			}
		/////////////////////end_default
	}//end switch page
}
}//end if set_js_init
//////////////////////////////////////////////////////////
};
/* per Mozilla/Opera9 */
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", init, false);
}
/* per Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
if (this.readyState == "complete") {
init(); // call the onload handler
}
};
/*@end @*/
/* per Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
var _timer = setInterval(function() {
if (/loaded|complete/.test(document.readyState)) {
init(); // call the onload handler
}
}, 10);
}
/* per gli altri browser */
window.onload = init; 








//END