// ajAddress = new Ajax();
var activeField;



function IframeTranslateEditor(inLang, outLang) {
	var st = document.getElementById('translation_box');
	var val = st.value;
	var langpair = inLang.substr(0,2) + "_" + outLang.substr(0,2);
/*	
alert(st);
	
	var stripped;
	

alert(val);

	var agree=confirm("Warning: All formatting will be removed as part of the translation process.\n\nThis automatic translation is a MACHINE TRANSLATION only\n and may produce a low quality translation. All translations should be\n examined to validate results.\n\n If a professional translation is required please contact translations@arkentechnology.com. \n\n\n Are you sure you wish to continue?");
	if (agree == false) {
		return false ;
	}
	*/
	langpair = langpair.toLowerCase();
/*
	stripped = val.replace(/<p>/ig,        " -98765.99 ");
	stripped = stripped.replace(/<\/p>/ig, " -87654.99 ");
	stripped = val.replace(/<form>/ig,        " -98765.54 ");
	stripped = stripped.replace(/<\/form>/ig, " -87654.55 ");
	stripped = stripped.replace(/<br>/ig,  " -76543.99 ");
	stripped = stripped.replace(/<br \/>/ig, " -76543.99 ");
	stripped = stripped.replace(/<ul>/ig,        " -65432.99 ");
	stripped = stripped.replace(/<\/ul>/ig, " -54321.99 ");
	stripped = stripped.replace(/<li>/ig,        " -43210.99 ");
	stripped = stripped.replace(/<\/li>/ig, " -32101.99 ");
	stripped = stripped.replace(/&ldquo;/ig, "-21012.99");
	stripped = stripped.replace(/&rdquo;/ig, "-10123.99");
	stripped = stripped.replace(/&rsquo;/ig, "-01234.99");
	stripped = stripped.replace(/&lsquo;/ig, "-12345.99");

	stripped = stripped.replace(/(<([^>]+)>)/ig,""); 
	stripped = stripped.replace(/&nbsp;/ig, " ");


*/
	ajAddress.call('getTranslation',callTranslateEditor, val, langpair);
	
	
}



function TranslateEditor(inLang, outLang) {
	var st = document.getElementById('fck_editor');
	var val = st.value;
	var stripped;
	var langpair = inLang.substr(0,2) + "_" + outLang.substr(0,2);


	var agree=confirm("Warning: All formatting will be removed as part of the translation process.\n\nThis automatic translation is a MACHINE TRANSLATION only\n and may produce a low quality translation. All translations should be\n examined to validate results.\n\n If a professional translation is required please contact translations@arkentechnology.com. \n\n\n Are you sure you wish to continue?");
	if (agree == false) {
		return false ;
	}
	
	langpair = langpair.toLowerCase();

	stripped = val.replace(/<p>/ig,        " -98765.99 ");
	stripped = stripped.replace(/<\/p>/ig, " -87654.99 ");
	stripped = val.replace(/<form>/ig,        " -98765.54 ");
	stripped = stripped.replace(/<\/form>/ig, " -87654.55 ");
	stripped = stripped.replace(/<br>/ig,  " -76543.99 ");
	stripped = stripped.replace(/<br \/>/ig, " -76543.99 ");
	stripped = stripped.replace(/<ul>/ig,        " -65432.99 ");
	stripped = stripped.replace(/<\/ul>/ig, " -54321.99 ");
	stripped = stripped.replace(/<li>/ig,        " -43210.99 ");
	stripped = stripped.replace(/<\/li>/ig, " -32101.99 ");
	stripped = stripped.replace(/&ldquo;/ig, "-21012.99");
	stripped = stripped.replace(/&rdquo;/ig, "-10123.99");
	stripped = stripped.replace(/&rsquo;/ig, "-01234.99");
	stripped = stripped.replace(/&lsquo;/ig, "-12345.99");

	stripped = stripped.replace(/(<([^>]+)>)/ig,""); 
	stripped = stripped.replace(/&nbsp;/ig, " ");

alert(callTranslateEditor);
alert(stripped);
alert(langpair);

	ajAddress.call('getTranslation',callTranslateEditor, stripped, langpair);
	
}

function callTranslateEditor(obj) {
/*
alert("callTranslateEditor");
	var i = 0;
	var formStart = "<form>";
	var formEnd = "<\/form>";

	var paraStart = "<p>";
	var paraEnd = "<\/p>";
	var lineBreak = "<br>";

	var listStart = "<ul>";
	var listEnd = "<\/ul>";
	
	var listitemStart = "<li>";
	var listitemEnd = "<\/li>";

	var lqou = "&ldquo;";
	var rqou = "&rdquo;";

	var lsquo = "&lsquo;";
	var rsquo = "&rsquo;";

var result = '';
	var inString = obj;
	*/
	var st = document.getElementById('translation_box');
/*
	inString = inString.replace(/-98765.99/g, paraStart);
	inString = inString.replace(/-87654.99/g, paraEnd);
	inString = inString.replace(/-98765.54/g, formStart);
	inString = inString.replace(/-87654.55/g, formEnd);

	inString = inString.replace(/-76543.99/g, lineBreak);
	inString = inString.replace(/-65432.99/g, listStart);
	inString = inString.replace(/-54321.99/g, listEnd);
	inString = inString.replace(/-43210.99/g, listitemStart);
	inString = inString.replace(/-32101.99/g, listitemEnd);
	
	inString = inString.replace(/-21012.99/g, lqou);
	inString = inString.replace(/-10123.99/g, rqou);
	inString = inString.replace(/-01234.99/g, rsquo);
	inString = inString.replace(/-12345.99/g, lsquo);
	
	obj = inString; */

	st.value = obj;	
}

function TranslateText(txt,inLang, outLang) {
	alert(txt);
	var st = document.getElementById(txt);
	alert(st);
	var val = st.value;
	var langpair = inLang.substr(0,2) + "_" + outLang.substr(0,2);
	activeField = txt;
	langpair = langpair.toLowerCase();
	


	ajAddress.call('getTranslation',callTranslateText, val, langpair);
}

function callTranslateText(obj) {

	var st = document.getElementById(activeField);
	st.value = obj;
	
}

function ShowCities(cus) {
	var st = document.getElementById('state_list');
	var val = st.options[st.selectedIndex].value;
		
		if (val.length > 0)
		{
			ajAddress.call('getCityList',callShowCitiesResponse, val, cus);
		}
}

function callShowCitiesResponse(obj)
{
	var i = 0;
	var citylist = document.getElementById('city_frame');
	var result = 'Select City : ';
	
	prospectlist = '';
	
	result += '<select onClick="ShowFranchisees(); " id="city_list" > <br>';
	result += '<option value=""></option> <br><option value="ALL">ALL</option> <br>';

	
		for (i = 0; i < obj.getRowCount(); i++) 
		{
			result += '<option value="' + obj.getField(i,'city') + '" >' + obj.getField(i,'city') + '</option><br>	';
		}
		
	result += '</select>';
	
	citylist.innerHTML = result;
	
}

function ShowFranchisees()
{
	var city = document.getElementById('city_list');
		
	var val = city.options[city.selectedIndex].value;

		
		if (val.length > 0)
		{
			ajAddress.call('getFranList',callShowFranResponse, val);
		}
}

function callShowFranResponse(obj)
{


	var i = 0;
	var franlist = document.getElementById('fran_frame');
	var result = '';
	
	prospectlist = '';
	
	for (i = 0; i < obj.getRowCount(); i++) 
	{
		result += "<a href=\"" + obj.getField(i,'home_page') + "\" target=new>";
		result += obj.getField(i,'address') + "</a>";
		result += " : " + obj.getField(i,'city') + ", " + obj.getField(i,'state') + "<br />";
	}
	
		
	result += '<br />';
	
	franlist.innerHTML = result;

}

function saveData(frm)
{
	alert("saving data");
	document.useredit.submit();
}


