   function getxml(ref,node,ss,language){
      var route = '';
      if(ref!='province'&&ref!='city'){
        route= '/xml?ref='+ref+'&language='+language;
	
      } else if(ref=='province'){
        route= '/xml?ref=province&country='+ss+'&language='+language;
      } else if(ref=='city'){
        route= '/xml?ref=city&province='+ss+'&language='+language;
      }

       $.ajax({  
          url: route,
          dataType: 'xml',
          type: 'GET',
          timeout: 60000,
          async: false,
          error: function(xml){
        },
          success: function(xml){
          $(node).find("option:ss").remove();
          $(xml).find("item").each(function(i){
          var Reference = $(this).children("Reference");
          var description=$(this).children("description");
          var ReferenceValue = Reference.text();
	      var descriptionValue=description.text();
		  if(descriptionValue=="Unknown"){
			 descriptionValue="Please Select ...";
		  }
          $("<option value='" +ReferenceValue + "'></option>").html(descriptionValue).appendTo(node);
              }) ;
            }
         });
	}
function showLoadingIcons(id, show) {
	var handle = $(id);
	var loadingHandle = handle.next();

	var className = loadingHandle[0].className;
	if ('loadingcv' != className) {
	loadingHandle = loadingHandle.next();
		//alert(loadingHandle);
	}

	if (show) {
		loadingHandle.show();
	} else {
                 loadingHandle.hide();

	}
	return true;
}
function addContactPerson(object)
{
	var objectHTML = "<li class='contactperson' style='margin:5px;'><label></label><a class='minus' onclick='javascript:removeContactPerson(this);'></a><div class=contactpersonname style='display:inline;'>" + $(object.options[object.selectedIndex]).html() + "</div></li>";
	if($(".contactperson").size()<=1)
	{
		if($(".contactperson").size()==0)
			$(object).parent().after(objectHTML);
		else
			$(".contactperson").eq($(".contactperson").size()-1).after(objectHTML);
	}else
	{
		alert("you can only select 2 contact person");
		return false;
	}
	calContactPerson();

}
function removeContactPerson(object)
{
	$(object).parent().remove();
	calContactPerson();
	return false;
}
function calContactPerson()
{
	$("#contactPerson").val('');
	$(".contactperson").each(function(){
		if($("#contactPerson").val() != '')
			$("#contactPerson").val($("#contactPerson").val() + ", " + $(this).find(".contactpersonname").html());
		else
			$("#contactPerson").val($(this).find(".contactpersonname").html());
	});
}
function setContactPerson(object)
{
	var objectHTML = "";
	if($("#contactPerson").val() !=''){
		var personlist = $("#contactPerson").val().split(", ");
		for(var i=0; i<personlist.length;i++)
		{
			objectHTML = "<li class='contactperson' style='margin:5px;'><label></label><a class='minus' onclick='javascript:removeContactPerson(this);'></a><div class=contactpersonname style='display:inline;'>" + personlist[i] + "</div></li>";
			if($(".contactperson").size()==0)
				$(object).parent().after(objectHTML);
			else
				$(".contactperson").eq($(".contactperson").size()-1).after(objectHTML);
		}
	}
}

function checkform(formid)
{
	var error=false;
	
	$("#" + formid + " label").filter(".required").each(function(){
		$(this).nextAll("span").remove();
		if($(this).next().val() == "")
		{
			$(this).next().after("<br/><span class='form_error'>&nbsp;&nbsp;" + errorMessege[0] + "</span>");
			error = true;
		}
	});
	if(error) return false;
	
    var search_str = /^(.+)@(.+)$/;
	if($("#" + formid + " .email").val() !="")
	{
		$("#" + formid + " .email").nextAll("span").remove();
		if(!$("#" + formid + " .email").val().match(search_str)){
			error = true;
			$("#" + formid + " .email").after("<span class='form_error'>&nbsp;&nbsp;" + errorMessege[1] + "</span>");
		}
	}

    if(error) {
    	return false;
	} else {
		return true;
	}
}
function sendScheduleMeeting(formid){
    if(checkform(formid))
    {
    	$("#" + formid + " .meeting_date").val($("#" + formid + " .month").val() + " " + $("#" + formid + " .day").val());
    	var url = $("#" + formid).attr("action");
    	$("#" + formid + " button").after("<div class='index_meeting_loadicon'>&nbsp;</div>");
    	$.post(url, $("#" + formid).serialize(), function(data){
    		if(data == "success"){
    			$("#meeting_info").show();
    			$(".index_meeting").css("border-color","#2f9905");
    			$(".index_meeting_title").css('background','#2f9905');
    			$("#" + formid + " .index_meeting_loadicon").remove();
				$("#" + formid).hide();
    		}
    	});    	
    }    	
}
function mainmeetingsubmit()
{
	checkform('main_meeting');
}
$(function(){

		if($("#contactPersonList").size()>0)
			setContactPerson($("#contactPersonList"));

});