
var currentTitleLocale = null;
var currentSynopsisLocale = null;
var currentWordsLocale = null;

function initializeLocale(locale) {
    currentTitleLocale = locale;
    currentSynopsisLocale = locale;
    currentWordsLocale=locale;
}

function changeTitleLocale(locale) {
    $("title[" + currentTitleLocale + "]").value = $("temptitle").value;
    $("temptitle").value = $("title[" + locale + "]").value;
    currentTitleLocale = locale;
}


function changeWordsLocale(locale) {
	  
    $("words[" + currentWordsLocale + "]").value = $("tmpWords").value;
    $("tmpWords").value = $("words[" + locale + "]").value;
    currentWordsLocale = locale;
}

/*function changeSynopsisLocale(locale) {
    $("synopsis[" + currentSynopsisLocale + "]").value = FCKeditorAPI.GetInstance("tmpsynopsis").GetHTML();
    FCKeditorAPI.GetInstance("tmpsynopsis").SetHTML($("synopsis[" + locale + "]").value);
    currentSynopsisLocale = locale;
}*/

function changeSynopsisLocale(locale) {
    $("synopsis[" + currentSynopsisLocale + "]").value = $("tmpsynopsis").value;
    $("tmpsynopsis").value = $("synopsis[" + locale + "]").value;
    $("synopsis[" + currentSynopsisLocale + "]").value = document.getElementById('wysiwyg' + 'tmpsynopsis').contentWindow.document.body.innerHTML;
	      
     document.getElementById('wysiwyg' + 'tmpsynopsis').contentWindow.document.body.innerHTML=$("synopsis[" + locale + "]").value;
    currentSynopsisLocale = locale;
}

/*function updateCurrentI18nSelection() {
    $("title[" + currentTitleLocale + "]").value = $("tmptitle").value;
    $("synopsis[" + currentSynopsisLocale + "]").value = FCKeditorAPI.GetInstance("tmpsynopsis").GetHTML();
}*/

function updateCurrentI18nSelection() {
    $("title[" + currentTitleLocale + "]").value = $("temptitle").value;
    $("synopsis[" + currentSynopsisLocale + "]").value = $("tmpsynopsis").value;
}
function updateCurrentI18nSelectionForAdmin() {
    $("title[" + currentTitleLocale + "]").value = $("temptitle").value;
    $("synopsis[" + currentSynopsisLocale + "]").value = document.getElementById('wysiwyg' + 'tmpsynopsis').contentWindow.document.body.innerHTML;
}
function postContributeForm() {
    updateCurrentI18nSelection();
    document.insertListingForm.submit();
}

function updateCurrentI18nSelectionPR(locale) {
	
	  if(viewTextMode == 1){
	        	
	        	if(locale=="en"){
	        		  alert ("The press release area is in HTML Mode, please switch it to TEXT Mode, otherwise the press release cannot be published.");	
	        		  return;}
	        		  if(locale=="fr"){
	        		  alert ("La zone communiqu\351 de presse est en mode HTML, veuillez svp passer en mode TEXT, sinon le communiqu\351 ne pourra pas \352tre publi\351.");	
	        		  return;}
	        		  if(locale=="es"){
	        		  alert ("La zona comunicado de prensa est\341 en modo HTML, por favor, c\341mbialo al modo TXT, aunque el comunicado no podr\341 ser publicado.");	
	        		  return;}
	        	
	        		  
	        	} 
	  
	
	
    $("title[" + currentTitleLocale + "]").value = $("temptitle").value;
    $("summary[" + currentSynopsisLocale + "]").value = $("tmpsummary").value;
    $("synopsis[" + currentSynopsisLocale + "]").value = document.getElementById('wysiwyg' + 'tmpsynopsis').contentWindow.document.body.innerHTML;
    document.insertPReleaseForm.submit();
}
function updateCurrentI18nSelectionContribute() {
    $("title[" + currentTitleLocale + "]").value = $("temptitle").value;
   

    $("synopsis[" + currentSynopsisLocale + "]").value = document.getElementById('wysiwyg' + 'tmpsynopsis').contentWindow.document.body.innerHTML;
    if($("synopsis[" + currentSynopsisLocale + "]").value=="<br>"){
    	$("synopsis[" + currentSynopsisLocale + "]").value="";
    }
    if($("synopsis[" + currentSynopsisLocale + "]").value=="<P>&nbsp;</P>"){
    	$("synopsis[" + currentSynopsisLocale + "]").value="";
    	}
    
    
    $("words[" + currentWordsLocale + "]").value = $("tmpWords").value;
}
function updateCurrentI18nComment(locale,id) {
	
	        if(viewTextMode == 1){
	        	
	        	if(locale=="en"){
	        		  alert ("The comment area is in HTML Mode, please switch it to TEXT Mode, otherwise the comment cannot be published.");	
	        		  return;}
	        		  if(locale=="fr"){
	        		  alert ("La zone commentaire est en mode HTML, veuillez svp passer en mode TEXT, sinon la commentaire ne pourra pas \352tre publi\351e.");	
	        		  return;}
	        		  if(locale=="es"){
	        		  alert ("La zona de comentario esta en modo HTML, por favor, c\341mbialo al modo TEXT, aunque el comentario no podr\341 ser publicado.");	
	        		  return;}
	        	
	        		  
	        	} 
	
	  $("text").value=document.getElementById('wysiwyg' + 'text').contentWindow.document.body.innerHTML;
	  changeFormProperty('commentForm','action','');
	  ajaxSubmitCommentListingForm(id);
    }
function changeSynopsisLocalePR(locale) {

    $("synopsis[" + currentSynopsisLocale + "]").value = document.getElementById('wysiwyg' + 'tmpsynopsis').contentWindow.document.body.innerHTML;
	document.getElementById('wysiwyg' + 'tmpsynopsis').contentWindow.document.body.innerHTML = $("synopsis[" + locale + "]").value;

    $("summary[" + currentSynopsisLocale + "]").value = $("tmpsummary").value;
    $("tmpsummary").value = $("summary[" + locale + "]").value;
	
    currentSynopsisLocale = locale;
}

function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}
