
					function shuffle_v2(inputArr){
						var valArr = [];
						var k = '', i = 0;
					
						for (k in inputArr) {
							valArr.push(inputArr[k]);
							delete inputArr[k];
						}
						valArr.sort(function() {return 0.5 - Math.random();});
					
						for (i = 0; i < valArr.length; i++) {
							inputArr[i] = valArr[i];
						}
					
						return true;
					}
					
					
					shuffle = function(o){
						for(var j, x, i = o.length; i > 0; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
						return o;
					};
					
			/*
					Object.prototype.clone = MM_clone;
					
					function MM_clone(){
						var objectClone = new this.constructor();
					
						for(var property in this)
							if(typeof this[property] == 'object' && this[property])
								objectClone[property] = this[property].clone();
							else
								objectClone[property] = this[property];
						
						return objectClone;
					}
				*/
				
					function getProperties(){
						tmp = document.getElementById('wt1').getCurrentItem();
						for (var prop in tmp) {
						   alert(prop + '==' + tmp[prop]);
						   }
					}	
					
					function viewVideoDivs(){													
						document.getElementById("lineUpTable").style.visibility = "visible";
						document.getElementById("videoData_1").style.visibility = "visible";
						document.getElementById("videoData_1").style.display = "block";												
					}
		
					//	ratings
					
					function heartSelect(heartNro){
						var voteNro = parseInt(heartNro);
						var happyLevelsMessages = Array("Aburrido!", "Para pasar\nel rato", "Entretenido", "Muy Bueno!", "Super chido!\nquiero m\xe1s!");
						
						for (i=1;i<=5;i++){
							var heartId = 'votingHeart'+i;
							var iterationHeart = document.getElementById(heartId);
							iterationHeart.className = (i<=voteNro) ? 'starOn' : 'starOff';
						}
						document.getElementById('voteHappyLevel').innerHTML = happyLevelsMessages[voteNro-1];						
						return true;
					}
					
					function heartClear(heartNro){
						var voteNro = parseInt(heartNro);
						for (i=1;i<=5;i++){
							var heartId = 'votingHeart'+i;
							var iterationHeart = document.getElementById(heartId);
							iterationHeart.className = (i>=voteNro) ? 'starOff' : 'starOn';
						}
						//document.getElementById('voteHappyLevel').innerHTML = "";
						return true;
					}

					function heartVote(starNro, videoEmbedCode){	
						loadcontent('http://www.latv.com/actions/ooyalavideos_ops.php?v=' + starNro + '&videoEmbedCode=' + videoEmbedCode, 'voteResult');
						return true;		
					}
					
					function initVotes(videoEmbedCode){
						loadcontent('http://www.latv.com/actions/ooyalavideos_ops.php?initr=true&videoEmbedCode=' + videoEmbedCode, 'initVotes');
						return true;		
					}
					
					// stats
					
					function initStats(videoEmbedCode){
						loadcontent('http://www.latv.com/actions/ooyalavideos_ops.php?inits=true&videoEmbedCode=' + videoEmbedCode, 'initStats');
						return true;		
					}
										
					function viewInsertCode(option){
						ViewOrHide('insertCode', 'insertcode_view', 'insertcode_hide', option);
						return true;
					}
					
					//	comments
					
					function ViewOrHide(div1, div2, div3, opt){
						// opt = view OR hide

						if(opt == 'view'){
							   document.getElementById(div1).style.display = "block";
							   document.getElementById(div1).style.visibility = "visible";
								
							   document.getElementById(div2).style.display = "none";
							   document.getElementById(div2).style.visibility = "hidden";
				
							   document.getElementById(div3).style.display = "block";
							   document.getElementById(div3).style.visibility = "visible";							   
						}else{				
							  document.getElementById(div1).style.display = "none";
							  document.getElementById(div1).style.visibility = "hidden";
							   			
							  document.getElementById(div2).style.display = "block";
							  document.getElementById(div2).style.visibility = "visible";
				
							  document.getElementById(div3).style.display = "none";
							  document.getElementById(div3).style.visibility = "hidden";
						}						
					}
	
					function commentVideo(option){
						ViewOrHide('comment', 'comment_view', 'comment_hide', option);
						return true;
					}
					
					function viewAllComments(option){
						ViewOrHide('allComments', 'viewAllComments_view', 'viewAllComments_hide', option);
						return true;
					}
					
					function ooyalaVideoCommentVote(voteType, commentID){
						containerResult = 'voteContainer' + voteType + '_' + commentID;
						loadcontent(WEBSITE_URL + '/actions/ooyalavideos_ops.php?action=vote&voteType=' + voteType + '&commentID=' + commentID, containerResult);
						return false;
					}
	
					function AddComment(videoEmbedCode){
						var name = trim(document.getElementById("user_name").value);
						var email = trim(document.getElementById("user_email").value);
						var comment =  trim(document.getElementById("user_comment").value);

						
						if(!validateName(name)){
							alert('Debes ingresar tu nombre.');
							document.getElementById("user_name").value = "Tu Nombre *";
							document.getElementById("user_name").focus();
							return false;
						}
						
						/*
						if(!validateEmail(email)){
							alert('Debes ingresar tu email.');
							document.getElementById("user_email").focus();
							return false;
						}
						*/
						
						if(!validateComment(comment, false, 10, 1000)){
							alert('Debes ingresar tu comentario; al menos ' + 10 + ' caracteres.');
							document.getElementById("user_comment").value = "Que estas pensando?";
							document.getElementById("user_comment").focus();
							return false;
						}

						loadcontent('http://www.latv.com/actions/ooyalavideos_ops.php?c=true&videoEmbedCode=' + videoEmbedCode + '&cmt=' + comment + '&e=' + email+ '&n=' + name, 'commentResult');
						document.getElementById('sendButton').disabled = true;
						document.getElementById('sendButton').value = "Enviado";
						
						//comentar en facebook
						if(parseInt(document.getElementById('commentInFacebook').value)){
						
							f_message = comment;
							f_message_title = document.title;
							f_message_link = document.getElementById("f_message_link").value;
							f_message_description = document.getElementById("f_message_description").value;
							f_message_image_url = document.getElementById("f_message_image_url").value;
							f_message_image_href = document.getElementById("f_message_image_href").value;
							
							// function defined in global.js
							setCommentInFacebook(f_message, f_message_title, f_message_link, f_message_description, f_message_image_url, f_message_image_href);			
						}
						
						return false;
					}
					
					function validateEmail(val){
						var reg=/(^[a-zA-Z0-9._-]{1,30})@([a-zA-Z0-9.-]{1,30}$)/;
						if(reg.test(val)){
							return true;
						}else{
							return false;
						}
					}
					
					function validateName(nameValue){
					alert(nameValue + ' -- ' + nameValue.length)
						if(nameValue == '' || !nameValue || nameValue == "Tu Nombre *"){){
							return false;
						}else{
							return true;
						}
					}
					
					function validateComment(comment, enabledNull, minLong, maxLong){
						var cantCar = comment.length;
						if(comment == "" || comment == "Que estas pensando?"){
							if(enabledNull){
								return true;
							}else{
								return false;
							}
						}else{
							if(cantCar >= minLong && cantCar <= maxLong) return true;
							else return false;
						}
					}
			
					function trim(s){
						s = s.replace(/\s+/gi,' '); //sacar espacios repetidos dejando solo uno
						s = s.replace(/^\s+|\s+$/gi,''); //sacar espacios blanco principio y final				
						return s;
					}

					function initComments(videoEmbedCode){
						loadcontent('http://www.latv.com/actions/ooyalavideos_ops.php?initc=true&videoEmbedCode=' + videoEmbedCode, 'initComments');
						return true;		
					}
					
					//  ajax
					
					function loadcontent(url, id_contenedor){    
						var pagina_requerida = false;    
						if(window.XMLHttpRequest){       
							pagina_requerida = new XMLHttpRequest();    
						}else 
							if(window.ActiveXObject){       
								try{            
									pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP");        
								}catch(e){           
									try{                
										pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP");            
									}catch(e){            
									}        
								}    
							}else    
								return false; 
				
							pagina_requerida.onreadystatechange = function(){        
								cargarpagina(pagina_requerida, id_contenedor);    
							}    
							
							pagina_requerida.open('GET', url, true);
							pagina_requerida.send(null);
					}		

					function cargarpagina (pagina_requerida, id_contenedor){ 
						var preloadHTML = '<img width="16" height="11" src="img/siteElements/loading_mini.gif" alt="Cargando...">&nbsp;<small class="fontBlue" style="font-weight:normal;">Cargando...</small>';						
						document.getElementById(id_contenedor).innerHTML = preloadHTML;
						if(pagina_requerida.readyState == 4 && (pagina_requerida.status == 200 || window.location.href.indexOf ("http") == - 1))    
							document.getElementById (id_contenedor).innerHTML = pagina_requerida.responseText;
					}
