var str_div_aberta= "id_menu_03";
var str_actual_datetime = '';

function updateTimeZone(obj){
	
	var register = document.getElementById('register').value;
	var url = "online_workshop.php";
	if(register == "true"){
		var webinar = document.getElementById("webinarid").value;
		url += "?timezone="+obj[obj.selectedIndex].value+"&register="+register+"&webinarid="+webinar;
	}
	else {
		url += "?timezone="+obj[obj.selectedIndex].value+"&register="+register;
	}
	window.location = url;
}

function doRegister(webinarid){
	var timezone = document.getElementById('timezoneid').value;	
	window.location = "online_workshop.php?register=true&webinarid="+webinarid+"&timezone="+timezone;
}


function showTimeZoneDiv(){
	
	div = document.getElementById('timeZn');
	if(div.style.display == "none" || div.style.display == "" ){
		div.style.display = "block";
	}
	else{
		div.style.display = "none";	
	}
}

function hideTimeZoneDiv(){
	
	div = document.getElementById('timeZn');
	div.style.display = "none";	
}

function updateWorkshop(obj){
	var workshop  = obj.options[obj.selectedIndex].value;
	url = 'online_workshop.php';
    url = url + '?ajax=true&option=updateWorkshop&workshop_id='+workshop;
    getDataAjax(url, ajax_set_updateWorkshop);
}

function ajax_set_updateWorkshop(str_retorno)
{

    url = url + '?actual_datetime='+actual_datetime.value+'&actual_timezone='+actual_timezone.value+'&new_timezone='+timezone;
	getDataAjax(url, ajax_set_updateTimeZone);

}

function showDiv(str_div)
{
	if(str_div_aberta != "")
	{
		document.getElementById(str_div_aberta).className = "";
		document.getElementById(str_div_aberta + "_desc").style.display = "none";
	}
	
	str_div_aberta = str_div;
	
	document.getElementById(str_div_aberta).className = "here";
	document.getElementById(str_div_aberta + "_desc").style.display = "";	
}

function doWorkShop()
{
	obj_sel = document.form_curso.str_workshop;
	str_workshop = obj_sel.value;
	if(str_workshop > 0)
	{
		document.getElementById("id_processing").style.display = "block";
		document.getElementById('id_error_msg').style.display = "none";
		document.getElementById('id_ok_msg').style.display = "none";
		
		ajax_post_send_workshop(str_workshop);
	}
}

function ajax_post_send_workshop(str_workshop)
{	

	str_msg = "ajax=true&";
	str_msg = str_msg + "option=register_workshop&";
	str_msg = str_msg + "str_workshop="    + str_workshop + "&";
	str_msg = str_msg + "str_nome="    + document.form_curso.str_nome.value + "&";
	str_msg = str_msg + "str_email="   + document.form_curso.str_email.value + "&";
	str_msg = str_msg + "str_telefone="    + document.form_curso.str_telefone.value + "&";
	str_msg = str_msg + "str_empresa=" + document.form_curso.str_empresa.value + "&";
	str_msg = str_msg + "str_timezone=" + document.form_curso.str_timezone.value+"&";
	
	url = 'online_workshop.php';
	postDataAjax(url, str_msg, ajax_set_send_workshop, "N");

}

function ajax_set_send_workshop(str_retorno)
{
	document.getElementById("id_processing").style.display = "none";

	if(str_retorno.substring(0, 8) == "ERROR#@#")
	{
		str_erro = str_retorno.substring(8);
		arr_erro = str_erro.split("#@#");
		
		str_erro = "";
		for(it=0; it<arr_erro.length; it++)
		{
			if(arr_erro[it] != "")
			{
				str_erro = str_erro + arr_erro[it] + "<br />";
			}
		}
		document.getElementById("id_error_msg").innerHTML = str_erro + "<br />";
		document.getElementById("id_error_msg").style.display = "";
	}else
	{
		mudaMsg();
	}
}

function mudaMsg()
{
	str_msg = document.getElementById("id_webinar_datetime").innerHTML; 
	document.getElementById('id_webinar_datetime_registro').innerHTML = str_msg;
	document.getElementById('id_ok_msg').style.display = "block";
	document.getElementById('id_table_register').style.display = "none";
}

function ajax_save_views(str_video_id, str_video_link, str_video_lang)
{
	url   = 'online_workshop.php';
    param = 'ajax=true&option=saveviews&video_id='+str_video_id+'&video_lang'+str_video_lang;
    postDataAjax(url, param, ajax_set_views);
	window.open(str_video_link);
}

function ajax_set_views(str_return)
{
	retorno = str_return.split("@@");
	document.getElementById('id_display_video').innerHTML = retorno[1];
	tb_show(retorno[0], '#TB_inline?height=330&width=530&inlineId=id_display_video', '');
}
function down_video(str_video_id, str_video_link, str_video_lang)
{
	url   = 'online_workshop.php';
    param = 'ajax=true&option=savedowns&video_id='+str_video_id + '&video_link='+str_video_link+'&video_lang'+str_video_lang;
    postDataAjax(url, param, ajax_set_downs);
}
function ajax_set_downs(str_return)
{
	retorno = str_return.split("@@");
	window.location = retorno[0];
}
