// form_functions.js

function drawCountryOptionList(argCountry, fieldName, isViper, soleCountry) {
  var size = CountryList.length;
  var rtn = "";

  rtn = '<select name="' + fieldName + '" class="hform">';
  rtn += '<option value="">&mdash;</option>';

	if (CountryList.length > 0) { // make sure CountryList has been defined
		for(var i = 0; i < size; i++) {
			if( 
				(isViper && CountryList[i].isViper) || (!isViper) ) {
					if ( (soleCountry == CountryList[i].cName) || (soleCountry =='')) {
						if (soleCountry !='') {
						var langs = CountryList[i].cLangs;
						}
						if( argCountry == CountryList[i].cCode ){
							rtn += '<option value=\'code="' + CountryList[i].cCode + '"|' + CountryList[i].cName + '\' selected>' + CountryList[i].cName + '</option>';
						} else {
							rtn += '<option value=\'code="' + CountryList[i].cCode + '"|' + CountryList[i].cName + '\'>' + CountryList[i].cName + '</option>';
						}
					}
			}
		} 
	}
  rtn += '</select>';
  if (soleCountry !='') {
	rtn += '<script type="text/javascript" language="javascript">var langs = "'+langs+'";</script>';
  }
  return rtn;
}

function drawLanguageOptionList(argLanguage, fieldName, argLangList) {
  var size = LanguageList.length;
  var rtn = ""
  var dispLang = 0;
  rtn = "<select name=\"" + fieldName + "\" class=\"hform\">";
  rtn += "<option value=\"\">&mdash;</option>";

  if ( LanguageList.length > 0 ) {
    for( var i=0; i < size; i++ ) { 
	    if((argLangList.indexOf(LanguageList[i].lCode) > 0)||(argLangList =="")){
		    
		    if( LanguageList[i].lActive ){
			    dispLang = 1;
	
			    if(argLanguage==LanguageList[i].cCode){
				    rtn += "<option value='code=\"" + LanguageList[i].lCode + "\"|" + LanguageList[i].lName + "' selected>" + LanguageList[i].lName + "</option>";

			    }else{
				    rtn += "<option value='code=\"" + LanguageList[i].lCode + "\"|" + LanguageList[i].lName + "'>" + LanguageList[i].lName + "</option>";
			    }
		    }
	    }
    }
    if(dispLang == 0) {
    rtn += "<option value='code=\"en\"|English'>English</option>";
    }
  }
  rtn += "</select>";
  return rtn;
}


function dumpArray(obj) {
  for (var i=0 ; i < obj.length; i++) {
    document.writeln (obj[i] + "<br />");
  }
}

