function showSafeCode() {	
	var iCode = Math.floor(900000*Math.random()) + 100000;
	document.write('<img id="vcodeimg" src="/common/safeCode.asp?s=' + iCode + '" style="cursor:hand;border:1px solid #ccc;vertical-align:top;" onclick="refreshSafeCode(' + iCode + ');" alt="" />');
	document.write('<input type="hidden" name="SafeCodeName" value="' + iCode + '" />');
}

function refreshSafeCode(iRnd) {
	var eImg = document.getElementById("vcodeimg");
	var eImgsrc = null;
	eImgsrc = '/common/safeCode.asp?s=' + iRnd + '&t='+ Math.random();
	eImg.src = eImgsrc;
	setInterval('eImg.src=eImgsrc',600000); 
}

function checkLogin(oSrc) {
	if (oSrc.username.value==""){
		alert("Please fill a member name!");
		oSrc.username.select();
		oSrc.username.focus();
		return false;
	}
	if (oSrc.passwd.value==""){
		alert("Please input your password!");
		oSrc.passwd.select();
		oSrc.passwd.focus();
		return false;
	}
	return true;
}

function editCorpInfo(u){
	var url = "/editCorpInfo.asp?u=" + u;
	var pop=new Popup({ contentType:1, isReloadOnClose:true, width:600, height:400 });
	pop.setContent("title","Edit company profile");
	pop.setContent("contentUrl",url);
	pop.build();
	pop.show();
	return;
}
function editContactInfo(u){
	var url = "/editContactInfo.asp?u=" + u;
	var pop=new Popup({ contentType:1, isReloadOnClose:true, width:560, height:400 });
	pop.setContent("title","Modify contact information");
	pop.setContent("contentUrl",url);
	pop.build();
	pop.show();
	return;
}

function addProduct(u){
	var url = "/productPost.asp?u=" + u;
	var pop=new Popup({ contentType:1, isReloadOnClose:true, width:700, height:850 });
	pop.setContent("title","Add a New Product");
	pop.setContent("contentUrl",url);
	pop.build();
	pop.show();
	return;
}
function editProduct(u,iid){
	var url = "/productPost.asp?u=" + u + "&id=" + iid;
	var pop=new Popup({ contentType:1, isReloadOnClose:true, width:680, height:750 });
	pop.setContent("title","Modify product information");
	pop.setContent("contentUrl",url);
	pop.build();
	pop.show();
	return;
}
function orderProduct(u,iid,subject){
	var url = "/orderProduct.asp?u=" + u + "&pid=" + iid + "&subject=" + subject;
	var pop=new Popup({ contentType:1, isReloadOnClose:true, width:700, height:400 });
	pop.setContent("title","Order a product");
	pop.setContent("contentUrl",url);
	pop.build();
	pop.show();
	return;
}
function editLip(u){
	var url = "/editLip.asp?u=" + u;
	var pop=new Popup({ contentType:1, isReloadOnClose:true, width:530, height:300 });
	pop.setContent("title","Upload business licence");
	pop.setContent("contentUrl",url);
	pop.build();
	pop.show();
	return;
}

function readAgreement(){
	window.open("/agreement.asp",null,"width=800,height=600,status=yes,toolbar=no,menubar=no,location=no");
}

function textCounter(oInputContral,oTipsContral,maxlimit) { 
	if (oInputContral.value.length > maxlimit){
		alert("You have typed too many words, please click on confirm to cut some of them.");
		oInputContral.value = oInputContral.value.substring(0, maxlimit); 
	}else{ 
		oTipsContral.value = oInputContral.value.length;
	}
}

function defaultSelected(oFormItem,defaultValue){
	//var oFormItem = document.getElementsByName(strFormItemName);
	//alert(typeof(oFormItem));
	if(typeof(oFormItem)!="undefined" && typeof(defaultValue)!="undefined"){
		for (var i=0;i<oFormItem.options.length;i++) {
		  if (oFormItem.options[i].value==defaultValue) {
			oFormItem.options[i].selected=true;
			break;
		  }
		}
	}
}

function addProductT(u,iid){
	var url = "/appPT.asp?u=" + u + "&id=" + iid;
	var pop=new Popup({ contentType:1, isReloadOnClose:true, width:600, height:400 });
	pop.setContent("title","I want to order product translation service");
	pop.setContent("contentUrl",url);
	pop.build();
	pop.show();
	return;
}

function checkspace(checkstr) {
	//return Boolean
	return Boolean( /^\s*$/.test( checkstr ) );
}

function NotInput(FormItemName,cnItemName){
	//return Boolean
	if(typeof(FormItemName) == "undefined")alert(FormItemName + "undifined");
	if (checkspace(FormItemName.value)){
		alert("Please enter a " + cnItemName);
		FormItemName.focus();
		FormItemName.select();
		return true;
	}
	return false;
}

function BeyondMaxLength(FormItemName,MaxLength,cnItemName) {
	if(typeof(FormItemName) == "undefined")alert(FormItemName + "undifined");
	if (FormItemName.value.length > MaxLength) {
	  alert("The length of " + cnItemName + " should be with in " + MaxLength + " words.");
	  FormItemName.focus();
	  FormItemName.select();
	  return true;
	}
}
function closes(){
	parent.dialogCase.style.display='none';
	parent.window.location.reload();
}
