// GLOBAL  //
var contentSpan  	= 'content';
var center_column	= 'center_column';
var regione         = '';
var infoRisorse     = 'InfoRisorse';
var resource		= ';'
var functionQueue   = 0;
var currentSection  = "home";
var searchCache 	= "";
var imagesArray     = new Array();
var cTimeout;


document.onkeydown = function(ev){
	var r = '';
	if (navigator.appName.indexOf("Microsoft")!=-1){
		if(window.event && window.event.keyCode == 116){
			return false; 
		}
	}else{
			r += ev.ctrlKey ? 'Ctrl-' : '';
			r += ev.keyCode;

		if(ev.keyCode == 116 || r == "Ctrl-82") 
        	{ 	
		  		ev.preventDefault();
				ev.stopPropagation();
		  		return false; 
		  	}
  	}  	
}

function enqueue(h_div){

  functionQueue = functionQueue+1;
  if(h_div == null)
  	 h_div = 'center_column';

  if(functionQueue == 1) {
  	$(h_div).style.display = 'none';
	$('breadCrumbs').style.display = 'none';
	$('footer').style.display = 'none';
	//doAnimate('breadCrumbs',"Fade");
  	showLightbox(null);	
  }
}

function dequeue(){
 functionQueue = functionQueue-1;
 var h_div;
  if(currentSection == "ambiente e meteo"){
			h_div = "doNothing";
	}else{
			h_div = "center_column";
  }	
 if(functionQueue == 0) {

 	hideLightbox();	
 	if(currentSection != "ambiente e meteo"){
	 	updateBreadCrumb();
		doAnimate(h_div,"Appear");
	}
	doAnimate('breadCrumbs',"Appear");
	setTimeout('$(\'footer\').style.display = \'\'',500);
  }

}


function doAnimate(element,animation){
	
	if(animation == "Appear")
		new Effect.Appear(element);	
	if(animation == "Fade")
		new Effect.Fade(element);	
	if(animation == "BlindDown")
		new Effect.BlindDown(element);
	if(animation == "SlideDown")
		new Effect.SlideDown(element);
	if(animation == "Shake"){
		$(element).style.display = '';
		new Effect.Shake(element);
		}
	if(animation == "Pulsate"){
		$(element).style.display = '';
		new Effect.Pulsate(element);
	  	}
	if(animation == "Grow")
		new Effect.Grow(element);
	if(animation == "Highlight"){
		$(element).style.display = '';
		new Effect.Highlight(element);
		}
}

//-------------- handlers for paging events ---------------------
function nextPage(prevId, id){	
	document.getElementById(prevId).style.display = 'none';
	new Effect.Appear(id);
}

function previousPage(prevId, id){	
	document.getElementById(id).style.display = 'none';
	new Effect.Appear(prevId);
}

function nextNewsPage(prevId, id){
	new Effect.SlideUp(prevId, {duration:.5});
	new Effect.SlideDown(id, {duration:.5});
}

function previousNewsPage(prevId, id){	
	new Effect.SlideUp(id, {duration:.8});
	new Effect.BlindDown(prevId, {duration:.8});
}
//-----------------------------------------------------------------

function escapeCharacter(str){
		str = str.replace(/`/,"\`");
		str = str.replace(/'/,"\u005C\u0027");
		return str;
}

/*

*/
function search(){
 	query = $('form1').strCerca.value;
 	var h_div;
		if(currentSection == "ambiente e meteo" ){
			  	h_div = "doNothing";
		}else{
			h_div = "center_column";
		}
			
    if(query == null || query == ''){
    	alert("il campo della ricerca e' vuoto.")
    	return;
    }    
    
    
    if($('InfoRisorse')) DWRUtil.setValue('InfoRisorse','');
    if($('info')) DWRUtil.setValue('info','');
    if($('doNothing')) {
    		enqueue(h_div);
    		applicationController.getComponent('/homeContainer',{
				callback:function(str){				
					DWRUtil.setValue('AjaxInclude', str);
					element=$('newsPage1');
					if (element!=null) new Effect.Appear('newsPage1', {duration:1.0});
					

    				portalUtils.doSearch({
						parameters:{strCerca:query},
						callback:function(searchResults){
							currentSection = 'home';
							DWRUtil.setValue('center_column',searchResults);
							dequeue();	
							new Effect.Appear('page' + 1)
							searchCache = searchResults;				
						}
				});
				}
			});
    }else{
    		enqueue();
    		portalUtils.doSearch({
					parameters:{strCerca:query},
					callback:function(searchResults){
						DWRUtil.setValue('center_column',searchResults);
						dequeue();	
						new Effect.Appear('page' + 1)
						searchCache = searchResults;				
					}
   			});
    }
}

/*
	rimanda al metodo createMenu delle singole action attraverso i wrapper methods di ApplicationController
*/
function createMenu(nomeSezione, option, include){	
	applicationController.createMenu(nomeSezione,option,
		function callback(str){
		   DWRUtil.setValue(include,str);
		   new Effect.Pulsate('top_left_boxMenu',{pulses:1.0,duration:2.0});
		});
	
}


function addChildScript(src){
	var script = document.createElement('script');
		script.src = src;
		script.type = 'text/javascript';
		script.defer = true;
		var head = document.getElementsByTagName('head').item(0);
		head.appendChild(script);		
}

/*

*/
function reloadSearch(id){
	DWRUtil.setValue('center_column',searchCache);
	if(id != 0){
		new Effect.Appear('page' + id)
	}else{
		new Effect.Appear('page' + 1)
	}
}

/*
	
*/
function createSection(section, title, resource, element, form){

		//DWRUtil.setValue('breadCrumbs', '');
		var h_div;
		if(currentSection == "ambiente e meteo" ){
			  	h_div = "doNothing";
		}else{
			h_div = "center_column";
		}	
		/* alert(currentSection) */
		currentSection = section;
		
		
		
		if(currentSection == 'home'){
		
			enqueue(h_div);
			applicationController.getComponent('/homeContainer',{
				callback:function(str){				
					DWRUtil.setValue('AjaxInclude', str);
					element=$('newsPage1');
					if (element!=null) new Effect.Appear('newsPage1', {duration:1.0});
					dequeue();
				}
			});
			
		}else if(currentSection == 'ambiente e meteo'){
		
			applicationController.getMessage('index.ambiente.meteo',
				{
				callback:function(message){
					DWRUtil.setValue('breadCrumbs', message);
				}
			});
			
			enqueue(h_div);
			applicationController.getLocale(function(locale){
				URL = '/cocoon/tm/app/' + locale +'/index.ajax';
				embed_ajax = false;
				// we must use direct browser in-call. no DWR pass
				var iFrame = '<div id="doNothing"></div><iframe class="ambienteMeteo" frameborder="0" src="' + URL + '"></iframe>';
				$('AjaxInclude').update(iFrame);
				dequeue();
			});	
										
		}else if(currentSection == 'difesa del mare'){
	
			enqueue(h_div);
				applicationController.getComponent('/defaultContainer',{
					callback:function(str){				
						DWRUtil.setValue('AjaxInclude', str);
						element = $('newsPage1');
						if (element!=null) new Effect.Appear('newsPage1', {duration:1.0});							
						getInclude('center_column', resource , form);
						dequeue();					
					}
				});
			
		}else if(currentSection == 'pubblicazioni'){

			enqueue(h_div);
			applicationController.getComponent('/defaultContainer',{
					callback:function(str){				
						DWRUtil.setValue('AjaxInclude', str);
						element = $('newsPage1');
						if (element!=null) new Effect.Appear('newsPage1', {duration:1.0});
						//$(h_div).style.display = 'none';
						getInclude('center_column', resource, form);
						dequeue();
					}
				});
			
		}else if(currentSection == 'link'){

			enqueue(h_div);
			applicationController.getComponent('/defaultContainer',{
					callback:function(str){				
						DWRUtil.setValue('AjaxInclude', str);
						element = $('newsPage1');
						if (element!=null) new Effect.Appear('newsPage1', {duration:1.0});
						//$(h_div).style.display = 'none';
						getInclude('center_column', resource, form);
						dequeue();
					}
				});
			
		}else if(currentSection == 'regioni'){
			var selectedRegione = '' + document.form2.nomeRegione.value;
			enqueue(h_div);
			applicationController.getComponent('/regioniContainer',{
					parameters:{nomeRegione:selectedRegione},
					callback:function(str){				
						DWRUtil.setValue('AjaxInclude', str);
						element = $('newsPage1');
						if (element!=null) new Effect.Appear('newsPage1', {duration:1.0});
						//$(h_div).style.display = 'none';
						dequeue();
					}
				});
			
		}else{
			return;
		}

}


/*


*/
function loadPage(title, resource, element, form){
	if(cTimeout){
		clearTimeout(cTimeout);
	}
	var section = extractSection(resource);
	//alert('loading page ' + title + ' of section ' + section + ' in section ' + currentSection)	
	if(section != currentSection && section != 'accessibilità'){
			createSection(section, title, resource, element, form);
	}else if(currentSection == 'regioni'){
	if(form){
			loadRegioni(document.form2.nomeRegione.value);
		}else{
			if(title == 'Link'){
				getInclude('center_column', resource, form);
			}else{
				loadAreaMarina(resource);
			}
		}
	}else if(currentSection == 'amp'){
			getInclude('center_column', resource, form);
	}else if(currentSection == 'ambiente e meteo'){
		
	}else if(currentSection == 'difesa del mare'){
		var a = resource.split('/home');
		if(a.length > 1){
			createSection(section, title, resource, element, form);
		}
		getInclude('center_column', resource, form);
	}else{
		getInclude('center_column', resource, form);
	}
}



function updateBreadCrumb(){
	applicationController.getBreadCrumbs({
		callback:function(navigation){
			var breadCrumbList = navigation.formattedBreadCrumbs; 
			DWRUtil.setValue("breadCrumbs",breadCrumbList);
		}
	})
}


// TO DO: move it to server and store this information in a DB
function extractSection(aResource){
	var elems = new Array();
  	elems = aResource.split('/');
  	var res;
  	for(var i = 0; i < elems.length; i++){
  	  var currentElem = elems[i];
  	  if(currentElem == 'regione.jsp'){
  	  	res = 'regioni';
  	  }else if(currentElem == 'Regioni'){
  	    res = 'regioni';
  	  	for(var u = 0; u < elems.length; u++){
  	  		var anAmp = elems[u];
  	  		if(anAmp == 'aree_protette'){
  	  			res = 'amp';
  	  		}
  	  	}
  	  	if(res == 'amp' && currentSection == 'difesa del mare'){
  	  		res = 'difesa del mare';
  	  	}
  	  }else if(currentElem == 'DifesaMare'){
  	  	res = 'difesa del mare';
  	  }else if(currentElem == 'pubblicazioni'){
  	  	res = 'pubblicazioni';
  	  }else if(currentElem == 'index'){
  	  	res = 'home';
  	  }else if(currentElem == 'link'){
  	  	res = 'link';
  	  }else if(currentElem == 'AmbienteMeteo'){
  	  	res = 'ambiente e meteo';
  	  }else if(currentElem == 'access'){
  	  	res = 'accessibilità';
  	  }
  	}
  	return res;
}
 

/*

*/
function loadResult(element,path,id,fullcontext){
//	alert(fullcontext);
	if ( fullcontext == undefined ) {
		fullcontext = 1;
	}
	var temp = path.toLowerCase();
	var regione=null;
	var temp1 = temp.split('regioni/');
	if ( temp1[1] != null ) regione = temp1[1].substring ( 0 , temp1[1].indexOf('/') ) ;
	var areamarina=null;
	temp1 = temp.split('aree_protette/');	
	if (temp1[1] != null) areamarina=temp1[1].substring(0,temp1[1].indexOf('/'));
	if (fullcontext==1)  {
		if (areamarina != null)  {
			applicationController.createMenu('Aree Marine Protette',{
   			 								  parameters:{nomeRegione:regione,areaMarina:areamarina},
			 								  callback:function(str){
		   											DWRUtil.setValue('InfoRisorse',str);
		  											new Effect.Pulsate('top_left_boxMenu',{pulses:1.0,duration:2.0});
		  											}
											  });	
			}
		if (regione != null)  {
			applicationController.invokeActionMethod('Regioni','createInforegioni', {
											  		  callback:function(result){
													  DWRUtil.setValue('info',result);
											  		},
											  		parameters:{nomeRegione:regione}
											  });
		}
	}
	if ( areamarina != null && path.indexOf ( areamarina + '.html') > 0 ) 
		loadAreaMarina(path,regione,areamarina);
	else
		getInclude(element,path,null);		
	DWRUtil.setValue('breadCrumbs', '<a href="javascript:reloadSearch('+id+');"> ricerca </a>')
}

/*
 crea una news all'interno del <div> center_column.
*/
function createMainScreen(element,id){

 	   var mainScreenContents=''
 	   enqueue();
 	   	   
 	   applicationController.invokeActionMethod('Home','createNewsDetail',{
 	   			parameters:{index:id},
 	   			callback:function(mainScreenContents){
 	   					DWRUtil.setValue('center_column',mainScreenContents);
 	   					dequeue();
      					new Effect.Appear('displayable');
 	   			}
 	   });
	}
	
/*
 costruisce e mostra l'archivio delle news all'interno del <div> center_column.
*/
function showArchivio(){

		enqueue();
  		applicationController.invokeActionMethod('Home','createNewsArchivio',{
				callback:function(content){
  		 			DWRUtil.setValue("center_column",content);
  					dequeue();
  					new Effect.Appear('archive');
  				}
			});
}

/*
	funzione di utility: ottiene una una pagina e la include all'interno del DOM:
	
*/
function getInclude(element, include, form){
	
    enqueue();
    portalUtils.forward(1,include,{
    		callback:function(str){
	    			if(str == ""){
	     				portalUtils.getInclude('/includes/ND.html', this);
	    			}else{
	    				DWRUtil.setValue(element,str);
	    				dequeue();
	    		}
    		}   
    	});
}

/*
	scrive un'immagine all'interno di un <div> "immagine"
*/
function writeImage(fileName,orientation,description){

	var content;
	if(orientation==0){
    	content = '<div id="toDisplay" style="display:none;"><img src="'+fileName+'" width="534px" height="356px" /></div>';
    }else{
	    content = '<div id="toDisplay" style="display:none;"><img src="'+fileName+'" width="356px" height="534px" /></div>';
    }
    var prop = fileName.substring(fileName.lastIndexOf('/') + 1,fileName.length);
    var nm = prop.split("_");
    
    DWRUtil.setValue('descrizione',description);
    applicationController.getMessage('regioni.galleria.proprietario',

        { callback:function(owner){

            DWRUtil.setValue('proprietario',owner + ': <span id="nome_prop" class="prop">' + nm[0] + ' ' + nm[1] + '</span>'); }

    });
	
	new Effect.Fade('toDisplay', {duration:.5});
	setTimeout("DWRUtil.setValue('immagine','" + content + "');new Effect.Appear('toDisplay',{duration:.6});",600);	
}

/*
	scrive un player video all'interno di un <div> "currentMovie"
*/
function writeMovie(fileName){
	var content;
   	content = '<embed src="' + fileName + '" width=\"536\" height=\"310\" controller=\"true\" type=\"video/quicktime\" pluginspage=\"http://www.apple.com/quicktime/download/\" scale=\"tofit\"></embed>'
	DWRUtil.setValue('currentMovie',content);
}

/*
	funzione che genera il contenuto della pagina "News.jsp"
*/
function loadNewsPage(){

	applicationController.createMenu('Home', function(output){
			DWRUtil.setValue("left_box",output);
			element = $('newsPage1');
			if (element!=null) new Effect.Appear('newsPage1', {duration:1.0});
		});
}

/*

*/
function loadIndexRegioni(){
	enqueue();
	if(currentSection != 'regioni')
		currentSection =  'regioni';
	applicationController.invokeActionMethod('Regioni','getIndexedPage', {
											  callback:function(result){
												DWRUtil.setValue('center_column',result);
												dequeue();
												new Effect.Appear('center_column', {duration:1.0});
											  	}
											 });
}


/*
	imposta e visualizza una pagina di regione in tutti i suoi componenti remoti
*/
function loadRegioni(nomeRegione){
	if(currentSection != 'regioni')
	currentSection = 'regioni';
	
	applicationController.createMenu('Regioni',{
												parameters:{nomeRegione:nomeRegione},
											    callback:function(str){
		   											DWRUtil.setValue('InfoRisorse',str);
		  											new Effect.Pulsate('top_left_boxMenu',{pulses:1.0,duration:2.0});}
												});
	
	var params = new Array();
	params[0] = nomeRegione;
	applicationController.invokeActionMethod('Regioni','createInforegioni', {
											  callback:function(result){
													DWRUtil.setValue('info',result);
											  },
											  parameters:{nomeRegione:nomeRegione}
											  });

	document.form2.nomeRegione.options[0].selected = true;
	
	
	enqueue();
	applicationController.createPage('Regioni',
						{
							callback:function(content){
								DWRUtil.setValue('center_column', content);
								dequeue();
								},
							parameters:{nomeRegione:nomeRegione}
						});
}


/*
	imposta e visualizza una pagina di un area marina protetta AMP in tutti i suoi componenti remoti
*/
function loadAreaMarina(include,regione,nomeAMP){
	if(cTimeout){
		cTimeout = 0;
	}
	var a = include.split('/aree_protette/');
	var title = a[1].substring(0,a[1].lastIndexOf('/'));
	enqueue();
	portalUtils.bannerAreaMarina(title.toLowerCase(), function callback(results){
		imagesArray = results;
		var cb_am = function(str){
			if(str == ""){
     			getInclude('center_column','/includes/ND.html',null);
     			dequeue();
    		}else{
				DWRUtil.setValue('center_column', '<div id="AMP_banner"></div>' + str);
				$('linkGalleria').href = 'javascript:loadGalleriaFotografica(\''+ nomeAMP + '\');';
				
				applicationController.getLocale(function(locale){
									$('bannerhtml').style.height = '380px';
									DWRUtil.setValue('AMP_banner','<img src="/minamb/' + locale + '/img/' + title + '.jpg" alt="AMP '+ nomeAMP + '" title="AMP ' + nomeAMP + '" />');
									var img1 = '<img src="'+imagesArray[0]+'" alt="banner ' + title + '" title="banner ' + title + '" height="356px" width="534px"/>';
									var img2 = '<img src="'+imagesArray[1]+'" alt="banner ' + title + '" title="banner ' + title + '" height="356px" width="534px"/>';
    							var div_inj = '<div id="banner1" style="display:none;">'+img1+'</div><div id="banner2" style="display:none;">'+img2+'</div><p></p>'
    							DWRUtil.setValue('bannerhtml',div_inj);
    							changeBanner(0,2,title);
    							dequeue();
				});

    			}
			};
		
		portalUtils.forward(1,include,{
   			 		parameters:{nomeRegione:regione,areaMarina:title},
			 		callback:cb_am
			 		});
	});
    
    var infoAMP = include.substring(0, include.lastIndexOf('/'));
    
    if(currentSection != 'difesa del mare'){
   			 currentSection = "amp";
   		}
	applicationController.invokeActionMethod('Regioni','createInforegioni', {
											  callback:function(result){
													DWRUtil.setValue('info',result);
											  },
											  parameters:{nomeRegione:regione}
											  });
 		  
   		 applicationController.createMenu('Aree Marine Protette',{
   			 								  parameters:{nomeRegione:regione,areaMarina:title},
			 								  callback:function(str){
		   											DWRUtil.setValue('InfoRisorse',str);
		  											new Effect.Pulsate('top_left_boxMenu',{pulses:1.0,duration:2.0});
		  											}
												});	
}

function changeBanner(flag,index,title){
	var b_div = document.getElementById('bannerhtml');	
	if(b_div){
		if(flag == 0){
		 	 currentBanner = 'banner1';
		 	 nextBanner = 'banner2';
		 	 flag = 1;
		 	}else{
		 	 currentBanner = 'banner2';
		 	 nextBanner = 'banner1';
		 	 flag = 0;
		 	}
		 	
	if(cTimeout){
	
		if(index == imagesArray.length-1) index = 0;
		var img = '<img src="'+imagesArray[index]+'" alt="banner di ' + title + '" height="356px" width="534px"/>';
		new Effect.Fade(currentBanner, {duration:.8});
		window.setTimeout('new Effect.Appear(\'' + nextBanner + '\', {duration:.4});DWRUtil.setValue(\''+currentBanner+'\',\'' + img + '\');',800);
		cTimeout = setTimeout('changeBanner('+flag+','+(index + 1)+',\''+title+'\')',8000);
	
	}else{
		$(currentBanner).show();
		cTimeout = setTimeout('changeBanner('+flag+','+(index + 1)+',\''+title+'\')',8000);
	
		}
	}
}

/*

*/
function getPrevisioniMeteo(regione){
	enqueue();
	applicationController.invokeActionMethod('Regioni','getPrevisioni',{
		parameters:{nomeRegione:regione},
		callback:function(content){
			  DWRUtil.setValue('center_column',content);
      		  dequeue();
		}
	});
}

/*
	crea una galleria fotografica a partire dalla String areaMarinaProtetta per identificare l'amp corrispondente
*/
function loadGalleriaFotografica(areaMarinaProtetta){
	
	enqueue();
	applicationController.invokeActionMethod('Aree Marine Protette','slideShow',{
		parameters:{areaMarina:areaMarinaProtetta},
		callback:function(content){
			  DWRUtil.setValue('center_column',content[2]);
      		  writeImage(content[0], content[1],content[3]);
      		  dequeue();
              new Effect.Appear('displayable');
		}
	});

}

/*
 *
 */
function loadSezioneFilmati(idRegione){
	enqueue();
	applicationController.invokeActionMethod('Regioni','getMovies',{
		parameters:{nomeRegione:idRegione},
		callback:function(content){
			DWRUtil.setValue('center_column',content);
			dequeue();
			new Effect.Appear('displayable');
		}
	});	
}

function loadWebCam(regione){

	enqueue();
	//http://www.demo.tutelamare.it/dwr/call/plaincall/applicationController.invokeActionMethod.dwr 
		applicationController.invokeActionMethod('Regioni','createWebCamPage',	{
			parameters:{nomeRegione:regione},
			callback:function(content){				
				DWRUtil.setValue('center_column',content);
				dequeue();
			}
		});
}

/*
  Create a player object in the web cam container element
*/
function writeObj(name, address, cam) {
	var content = '';
	
	if (cam!='3')
		document.getElementById("layer_video").innerHTML="<embed id=\"player\" src=\"./js/FLVPlayer_Progressive.swf\" flashvars=\"&MM_ComponentVersion=1&skinName=/js/Clear_Skin_1&streamName=http://stream.tutelamare.it/stream"+cam+"&autoPlay=true&autoRewind=false\" quality=\"high\" scale=\"noscale\" name=\"FLVPlayer\" salign=\"lt\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\"  width=\"352\" height=\"288\" >";
	else
		document.getElementById("layer_video").innerHTML="<embed id=\"player\" src=\"./js/FLVPlayer_Progressive.swf\" flashvars=\"&MM_ComponentVersion=1&skinName=/js/Clear_Skin_1&streamName=http://stream.tutelamare.it/stream"+cam+"&autoPlay=true&autoRewind=false\" quality=\"high\" scale=\"noscale\" name=\"FLVPlayer\" salign=\"lt\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\"  width=\"320\" height=\"240\" >";
	
	/*var vlc_elem=document.getElementById("webcam_loading");
	if (vlc_elem!=null) vlc_elem.style.display = 'block';	
	alert('width=' + $('player').width);
	alert('height=' + $('player').height);
	/*
   	if (navigator.appName.indexOf("Microsoft")!=-1) {	// MICROSOFT BROWSER
   		//alert('internet explorer 1')
   		
		//content = '<object classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8"';
		//content =  content + ' codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab"';
		//content =  content + ' id="VLC" width=\'320px\' height=\'240px\' events="false">';
		content = '<object id=VLC classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8"';
		content =  content + ' codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab" width="400" height="300" events="false">';
		content =  content + ' <param name="src" value="http://'+address+'/?cam=' + cam + '" />';
		content =  content + ' <param name="showDisplay?" value="True" />';
		content =  content + ' <param name="autoLoop?" value="false" />';
		content =  content + ' <param name="autoPlay?" value="TRUE" />';
		content =  content + ' </object>';
   		
/*		content =  content + '<object classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8" codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab" ';
		content =  content + 'width="320" height="240" events="True"';
		content =  content + 'id="'+ name + '">';
		content =  content + '<param name="Src" value="http://' + address + '/?cam=' + cam + '">';
		content =  content + '<param name="ShowDisplay" value="True" />';
		content =  content + '<param name="AutoPlay" value="True" />';
		content =  content + '</object>';  
		alert(content);
		DWRUtil.setValue('Stream', content);
		$('VLC').width = 320;
		//$('VLC').style.width = 320;
		$('VLC').height = 240;
		//$('VLC').style.height = 240;
					
   	} else {  	//MOZILLA FIREFOX BROWSER
   	
   		//QUICKTIME
   		//content = '<embed autoplay="True" loop="yes" name="' + name + '" target="http://'+address+'/?cam=' + cam + '" width=\"320\" height=\"240\" controller=\"true\" type=\"video/quicktime\" pluginspage=\"http://www.apple.com/quicktime/download/\" scale=\"tofit\"></embed>';
   		
   		//MICROSOFT media-player
   		/*content = '<embed autoplay="True" loop="yes" type="application/x-mplayer2" ' +
   				'target="http://'+address+'/?cam=' + cam + '" name="' + name + '" ' +
   				'pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&amp;sbp=mediaplayer&amp;ar=media&amp;sba=plugin&amp;" ' +
   				'autosize="1" autostart="1" showcontrols="1" showdisplay="0" showstatusbar="1" height="240" width="320">';
   		
   		//VLC Player
			content =  content + '<embed type="application/x-vlc-plugin"';
        	content =  content + 'name="' + name + '"';			
        	content =  content + 'autoplay="True" loop="yes" width="320" height="240"';
        	content =  content + 'target="http://'+address+'/?cam=' + cam + '">';
        	
        DWRUtil.setValue('Stream', content);*/
	//}
 }
