function isEmpty(str){
	if (str.length == 0){ return true; }
	if (str.search(/\S/) == -1){ return true; }
	return false;
}

function onError(form_object, input_object, object_value, error_message)
    {
	alert(error_message);
       	return false;	
    }

function hasValue(obj, obj_type){
	 if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX"){
		if (obj.checked)
			return true;
		else
			return false;}
	else if (obj_type == "RADIO" || obj_type == "CHECKBOX"){
		for (i=0; i < obj.length; i++){
			if (obj[i].checked)
				return true;
			}
			return false;
		}
}

function isValidURL(str,blnRequired){
	if (isEmpty(str) && (blnRequired)){ return false; }
	if (!isEmpty(str)){
		if (str.search(" ") > -1){ return false; }
		if (str.search(/\./) == -1){ return false; }
		for(i=0;i<=str.length;i++){ if(str.charCodeAt(i) > 128){ return false; } }
	}
	// List of invalid extensions separated by "|"
	var strArray = "avi|css|doc|exe|gif|jpeg|jpg|js|mpg|mpeg|pdf|swf|rar|rtf|wav|zip"
	var extArray = strArray.split("|");
	for (var i=0; i < extArray.length; i++)	{
		if (str.substring(str.length-extArray[i].length-1, str.length) == "."+extArray[i]) {
			return false;
		}
	}
	return true;
}

function setCookie(strName, strValue){
	var expires=new Date(2015,9,21,12,0,0);
	document.cookie=strName+"="+escape(strValue)+"; expires="+expires.toGMTString()+"; domain=freetranslation.com; path=/";
	// For freetranslation (Live) server freetranslation.com
	// For Portal (Dev) server domain=sdlintl.com
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function printPage(){
	window.focus();
	window.print();
}
function validateForm(form) {
	if (isEmpty(form.SrcText.value)) {
		alert("Your translation request is empty.  Please enter your required text for translation before proceeding.") ;
		form.SrcText.focus() ;
		return false ;
	}
	if (form.SrcText.value.length > 10000) {
		alert("Your translation request exceeds 10,000 characters.  Please reduce the size of your translation request before proceeding.") ;
		form.SrcText.focus() ;
		return false ;
	}
	return true ;
}

var submittedText = false;
function submitText() {
	if (!submittedText) { if (validateForm(document.textform)) { submittedText = true; document.textform.submit(); } }
	else { alert("Your request is being processed. Please wait."); }
}

function validateFormURL(form) {
	return isValidURL(form.Url.value, 1);
}

var submittedURL = false;
function submitURL() {
	if (!submittedURL) {
		if (validateFormURL(document.urlform)) { submittedURL = true; document.urlform.submit(); }
		else { alert("Sorry, but this file extension in not supported."); }
	}
	else { alert("Your request is being processed. Please wait."); }
}
function changeURL(field) {
	if (submittedURL) {
		field.blur();
		alert("Your initial request is being processed. Please wait.");
	}
}

function ClearSrcText() {
	document.textform.SrcText.value = "" ;
	document.textform.SrcText.focus() ;
}

function ClearResultsText() {
	document.tekstvak.inhoud.value = "" ;
	document.tekstvak.inhoud.focus() ;
}

function ClearUrl() {
	document.urlform.Url.value = "" ;
	document.urlform.Url.focus() ;
}

function handleListChange(theList) {
	var numSelected = theList.selectedIndex ;
	if (numSelected != 0) {
		if (document.all){
			document.textform.SrcText.focus();
			var sRange = document.selection.createRange();
			var charToInsert = theList.options[numSelected].value
			sRange.text = charToInsert;
			}
		else{
			textValue = document.textform.SrcText.value ;
			textValue = textValue + theList.options[numSelected].value ;
			document.textform.SrcText.value = textValue ;
			}
		theList.selectedIndex = 0 ;
		document.textform.SrcText.focus() ;
	}
}

function doClipboard(objElement, strCmd) {
	objElement.focus();
	objElement.select();
	if (document.all) {
		var objRange = objElement.createTextRange();
		objRange.execCommand(strCmd);
	}
	else{
		switch(strCmd){
			case 'Copy':
				alert('Deze functie werkt enkel in Internet Explorer.');
			break;
			case 'Cut':
				alert('Deze functie werkt enkel in Internet Explorer.');
			break;
			case 'Paste':
				alert('Deze functie werkt enkel in Internet Explorer.');
			break;
		}
	}
}


if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function Browser(){
  this.dom = document.getElementById?1:0;
  this.ie4 = (document.all && !this.dom)?1:0;
  this.ns4 = (document.layers && !this.dom)?1:0;
  this.ns6 = (this.dom && !document.all)?1:0;
  this.ie5 = (this.dom && document.all)?1:0;
  this.ok = this.dom || this.ie4 || this.ns4;
  this.platform = navigator.platform;
}

function openWindow(url) {
   var browser = new Browser();
   var winl = (screen.width-400)/2;
   var wint = (screen.height-200)/2;
   var obj = document.getElementById("SrcText");
   var iOffSetTop = obj.offsetTop;
   var iOffSetLeft = obj.offsetLeft;
   var iRcts = obj.getClientRects();
   if (browser.dom || browser.ie4) {
    x = 0;
    while (obj.offsetParent != null) {
           x += obj.offsetLeft;
           obj = obj.offsetParent;
           }
   var obj = document.all.SrcText;
//   alert(obj.cols)
    x += obj.offsetLeft;
    x += obj.cols;
    y = 0;
    while (obj.offsetParent != null) {
           y += obj.offsetTop;
           obj = obj.offsetParent;
           }
    y += obj.offsetTop;
    }
//  alert(x + ' and '+  y);
   var obj = document.all.SrcText;
  if (browser.ns4) {
    if (obj.container != null){
      x = obj.container.pageX + obj.x
      y = obj.container.pageY + obj.y
    } 
    else {
      x = obj.x;
      y = obj.y;
    }
    x += obj.width;
  }

   winStats='toolbar=no,location=no,directories=no,menubar=no,'
   winStats+='scrollbars=no,width=450,height=210'
   if (document.all) {
       winStats+=',left=' + x + ',top=' + y
   }else{
       winStats+=',screenX=' + x + ',screenY=' + y
   }
   floater=window.open(url,"",winStats)
}

function show_it(){
document.all.SrcText.style.visibility = "visible";
}

function kickNewSurvey(strReferrer){
	var getSurveyCookie = getCookie('showSurvey')
	if (getSurveyCookie != 'false'){
		window.location.href="indexnew.htm";
	}
}

function kickSurvey(strReferrer){
	var getSurveyCookie = getCookie('showSurvey')
	if (getSurveyCookie != 'false'){
		window.open('http://www.freetranslation.com/survey.asp?referrer='+ escape(strReferrer) , '_blank', 'scrollbars=no,toolbar=no,adress=no,width=450,height=210,top=400,left=300,resizable=no');
	}
}

var strNSHidden = "display:''";

function showHide(){
	var oForm = document.frmSurvey2;
	if (oForm.q1[0].checked){
		document.getElementById("Disp1").style.display = "";}
	else{
		document.getElementById("Disp1").style.display = "none";}
}

function showHide2(x){
	var oForm = document.frmSurvey2;
	if (oForm.q3[oForm.q3.selectedIndex].value == 1){
		document.getElementById("Disp2").style.display = "";
		document.getElementById("Disp3").style.display = "none";}
	else if (oForm.q3[oForm.q3.selectedIndex].value == 5){
		document.getElementById("Disp3").style.display = "";
		document.getElementById("Disp2").style.display = "none";}
	else{
		document.getElementById("Disp2").style.display = "none";}
}

function showHide3(){
	var oForm = document.frmSurvey2;
	if (oForm.q6[oForm.q6.selectedIndex].value == 1){
		document.getElementById("Disp4").style.display = "";
		document.getElementById("Disp5").style.display = "";
		}
	else{
		document.getElementById("Disp4").style.display = "none";
		document.getElementById("Disp5").style.display = "none";
		}
}

function validateSurveyForm(thisForm){
	if (!hasValue(thisForm.q1, "RADIO" )){
		if (!onError(thisForm, thisForm.q1, thisForm.q1.value, "Please select your response to question 1.")){
			return false;}
	}
	if (!hasValue(thisForm.q2, "RADIO" )){
		if (!onError(thisForm, thisForm.q2, thisForm.q2.value, "Please select your response to question 2.")){
			return false;}
	}
	if (!hasValue(thisForm.q3, "RADIO" )){
		if (!onError(thisForm, thisForm.q3, thisForm.q3.value, "Please select your response to question 3.")){
			return false;}
	}
	return true;
}

function checkTextAreaBoxSize() {
	var maxChar = 3000;
	if(document.frmClose.feedback.value.length > maxChar) {
		alert('Too much data in the text box!');
		return false; }
	else
		return true;
}



function combo(inhoud) 
	{
	if (inhoud.style.display=="")
		{
		inhoud.style.display="none";
		}
	else 
		{
		inhoud.style.display="";
		}
	}
	
	
