function refreshText(){
	$get('codIns').value = aggIns();
	$get('codInf').value = aggInf();
}

function inpCng(){
	TitoloIe = $get('inpTitolo').value;
	PiattaformaIe = $get('selOs').options[$get('selOs').selectedIndex].value;
	HomePageIE = checkProtocol($get('inpHomePageIE').value);
	HelpPageIE = checkProtocol($get('inpHelpPageIE').value);
	FirstHomePageIE = $get('inpFirstHomePageIE').value;
	$get('inpHomePageIE').value = checkProtocol($get('inpHomePageIE').value);
	$get('inpHelpPageIE').value = checkProtocol($get('inpHelpPageIE').value);
	
	refreshText();
}

function addWS(){
	if($get('inpWSTitolo').value == ""){
		alert('Specificare un nome per il Quick Link');
		return
	}
	if($get('inpWSUrl').value == ""){
		alert('Specificare l\'Url di un Rss 2.0 valido');
		return
	}
	arrayFavoritesBarUtente[arrayFavoritesBarUtente.length] = {"Name" : $get('inpWSTitolo').value, "URL" : _wsQS + "?Url=" + $get('inpWSUrl').value + "&Id=" + $get('inpWSTitolo').value, "Logo" : "ws/Kws.gif", "Enable" : "false"};
	$get('inpWSTitolo').value = "";
	$get('inpWSUrl').value = "";
	popolaDDL('selWS',arrayFavoritesBarUtente);
}

function remWS(){
	for(var i = ($get("selWS").options.length-1); 0 <= i; i--){
		if($get("selWS").options[i].selected == true){
		  arrayFavoritesBarUtente.remove(i);
		  $get("selWS").removeChild($get("selWS").options[i]);
		}
	}
	popolaDDL('selWS',arrayFavoritesBarUtente);
}

function addQL(){
	if($get('inpQLName').value == ""){
		alert('Specificare un nome per il Quick Link');
		return
	}
	if($get('inpQLUrl').value == ""){
		alert('Specificare una Url per il Quick Link');
		return
	}
	arrayQuickLink[arrayQuickLink.length] = {"Name" : $get('inpQLName').value, "URL" : checkProtocol($get('inpQLUrl').value)};
	$get('inpQLName').value = "";
	$get('inpQLUrl').value = "";
	popolaDDL('selQL',arrayQuickLink);
}

function remQL(){
	for(var i = ($get("selQL").options.length-1); 0 <= i; i--){
		if($get("selQL").options[i].selected == true){
		  arrayQuickLink.remove(i);
		  $get("selQL").removeChild($get("selQL").options[i]);
		}
	}
	popolaDDL('selQL',arrayQuickLink);
}

function addL(){
	if($get('inpLName').value == ""){
		alert('Specificare un nome per il Link');
		return
	}
	if($get('inpLUrl').value == ""){
		alert('Specificare una Url per il Link');
		return
	}
	arrayFavorites[arrayFavorites.length] = {"Name" : $get('inpLName').value, "URL" : checkProtocol($get('inpLUrl').value)};
	$get('inpLName').value = "";
	$get('inpLUrl').value = "";
	popolaDDL('selL',arrayFavorites);
}

function remL(){
	for(var i = ($get("selL").options.length-1); 0 <= i; i--){
		if($get("selL").options[i].selected == true){
		  arrayFavorites.remove(i);
		  $get("selL").removeChild($get("selL").options[i]);
		}
	}
	popolaDDL('selL',arrayFavorites);
}

function addF(){
	if($get('inpFName').value == ""){
		alert('Specificare un nome per il Feed');
		return
	}
	if($get('inpFUrl').value == ""){
		alert('Specificare una Url per il Feed');
		return
	}
	arrayFeeds[arrayFeeds.length] = {"Name" : $get('inpFName').value, "URL" : checkProtocol($get('inpFUrl').value)};
	$get('inpFName').value = "";
	$get('inpFUrl').value = "";
	popolaDDL('selF',arrayFeeds);
}

function remF(){
	for(var i = ($get("selF").options.length-1); 0 <= i; i--){
		if($get("selF").options[i].selected == true){
		  arrayFeeds.remove(i);
		  $get("selF").removeChild($get("selF").options[i]);
		}
	}
	popolaDDL('selF',arrayFeeds);
}

function vTab(_index,_senso){//senso: +1 avanti -1 indietro, 0 inerte
    var _host = urlDominio();
	if(_senso > 0){
		if(_index > 1){
			$get('p'+ (_index-1)).style.display = "none";
		}
	}
	if(_senso < 0){
		$get('p'+ (_index+1)).style.display = "none";
	}
	switch (_index){
	    case 2:
	        webSlicesDef = loadObj(_host + 'JsonView.aspx?Type=ws');
	        break;
	    case 4:
	        creaTableWs();
	        break;
	    case 5:
	        acceleratorDef = loadObj(_host + 'JsonView.aspx?Type=acc');
	        break;
	    case 6:
	        creaTableAcc();
	        searchProviderDef = loadObj(_host + 'JsonView.aspx?Type=sp');
	        break;
	    case 7:
	        creaTableSP();
	        break;
	}
	try{
		$get('p'+ _index).style.display = "inline";
	}catch(e){}
	inpCng();
}

function popolaDDL(_idDDL,_array){
	$get(_idDDL).innerHTML = "";
	for(var i = 0; i < _array.length;i++){
		var opt;
		opt = document.createElement("option");
		opt.value = i;
		opt.text = _array[i].Name;
		try{
			$get(_idDDL).add(opt,null);
		}catch(ex){
			$get(_idDDL).add(opt);
		}
	}
}

Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};