﻿function playVideo (fileName, linkId)
{
	var parent=document.getElementById("videoLinks");

	// change all the DIVs inVideoLinks to off state
	var i=0;
	var child=parent.firstChild;
	//alert("child" + );
	while (child)
	{
		child.className="videoLinkOff";
		i++;
		child=parent.childNodes[i];
	}
	
	// change specified link to on state
	currLink=document.getElementById(linkId);
	currLink.className="videoLinkOn";
	
	wasp_loadAndPlay(fileName);
}

function validateForm(theForm)
{
var reason = "";

  reason += validateEmpty(theForm.name,"Name");
  reason += validateEmpty(theForm.email,"Email");
  reason += validateEmpty(theForm.country,"Country");
  reason += validateEmpty(theForm.topic,"Subject");
  reason += validateEmpty(theForm.message,"Message");
      
  if (reason != "")
  {
    alert(reason);
    return false;
  }

  return true;
}

function validateFormChinese(theForm)
{
var reason = "";

  reason += validateEmptyChinese(theForm.name,"姓名");
  reason += validateEmptyChinese(theForm.email,"电子邮件地址");
  reason += validateEmptyChinese(theForm.country,"国家名称");
  reason += validateEmptyChinese(theForm.topic,"项目名称");
  reason += validateEmptyChinese(theForm.message,"消息");
      
  if (reason != "")
  {
    alert(reason);
    return false;
  }

  return true;
}

function validateEmpty(fld,name)
{
    var error = "";
 
    if (fld.value.length == 0)
	{
        error = "The field '" + name + "' is required.\n"
    }
	
    return error;  
}

function validateEmptyChinese(fld,name)
{
    var error = "";
 
    if (fld.value.length == 0)
	{
        error = "'" + name + "'地方为必填信息。\n"
    }
	
    return error;  
}