function voice_it_init() {
	try{

		comment_textarea = document.getElementById('comment');
		if(comment_textarea!=null){
			
			if(voice_it_record_and_send_voice_language===undefined){
				voice_it_record_and_send_voice_language="en-EN";
			}
		
			var htmlstring=' <img src="http://www.voice-it.biz/files/getbyname/ico_registra.gif"> ';
			htmlstring+='<a href="#" onclick="voice_it_switch_plugin();return false;">'+voice_it_labels["leave_a_message"]+'</a>';
			htmlstring+=voice_it_create_plugin(voice_it_record_and_send_voice_language);

			var new_element2  = document.createElement('div');
                        new_element2.setAttribute("class","voice_it_leave_audio");
			new_element2.innerHTML=htmlstring;
			comment_textarea.parentNode.insertBefore(new_element2,comment_textarea);
		}


	}catch(ex){
// alert("V="+ex);
		// error during voice_it_init
	}
	
}

function voice_it_message_confirmed(token) {
	try{
		document.getElementById('voiceit_container').style.display="none"
		comment_textarea = document.getElementById('comment');
		comment_textarea.value += '\n[voice_it]' + token + '[/voice_it]\n';		

			var new_element  = document.createElement('div');
                        new_element.setAttribute("id","voice_it_info");
                        new_element.innerHTML="<small>"+voice_it_labels["info_after_message"]+"</small>";
			comment_textarea.parentNode.insertBefore(new_element,comment_textarea);

	}catch(ex){
// alert("err="+ex);
	}
}

function voice_it_switch_plugin(){
	try{
		if(document.getElementById('voiceit_container').style.display=="none"){
			document.getElementById('voiceit_container').style.display="";
		}else{
			document.getElementById('voiceit_container').style.display="none";
		}
	}catch(ex){

	}
}

function voice_it_create_plugin(v_lang) {
	if(v_lang===undefined){
		v_lang='en-EN';
	}
	
	var v_host = document.location.hostname;
	var v_version = 'wordpress'
	var v_other = '';

	var v_txt = '';
	v_txt = v_txt + '<div id="voiceit_container" style="display:none;">\n';
	v_txt = v_txt + '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.#version=10,0,0,0" height="163" width="233">\n';
	v_txt = v_txt
			+ '<param name="movie" value="http://www.voice-it.biz/files/getbyname/VOICE-IT.swf?PARAM_host='
			+ v_host + '&PARAM_cliversion=' + v_version
			+ '&PARAM_localization=' + v_lang + '&' + v_other + '">';
	v_txt = v_txt + '<param name="id" value="movie">';
	v_txt = v_txt + '<param name="quality" value="best">';
	v_txt = v_txt + '<param name="play" value="true">';
	v_txt = v_txt + '<param name="wmode" value="transparent">';
	v_txt = v_txt + '<param name="AllowScriptAccess" value="always">';

	v_txt = v_txt
			+ '<embed height="163" AllowScriptAccess="always" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" src="http://www.voice-it.biz/files/getbyname/VOICE-IT.swf?PARAM_host='
			+ v_host
			+ '&PARAM_cliversion='
			+ v_version
			+ '&PARAM_localization='
			+ v_lang
			+ '&'
			+ v_other
			+ '" type="application/x-shockwave-flash" width="233" quality="best" name="movie" id="movie" wmode="transparent">\n';
	v_txt = v_txt + '</object>\n';
	v_txt = v_txt + '</div>\n';
	return unescape(v_txt);
}

if (window.attachEvent) {
	window.attachEvent("onload", voice_it_init);
} else if (window.addEventListener) {
	window.addEventListener("DOMContentLoaded", voice_it_init, false);
}