/*----Form validating-----------------------------*/ function check_email(mail){ var pos1; var pos2; var pos3; pos1 = mail.indexOf('.'); pos2 = mail.indexOf('@'); pos3 = mail.indexOf(' '); if(pos1<0 || pos2<0 || pos3>0) return false; return true; } function validating_required(form_elm,compare){ /* Ham nhan vao array cac form element (vd document.f1.name) va gia tri can so sanh -> Tra ve true neu tat ca elm thoa (!=compare) -> Tra ve mot array chua cac form_elm khong thoa */ var invalid = new Array(); for(i=0;i<form_elm.length;i++){ if(form_elm[i].value==compare) invalid.push(form_elm[i]); } if(invalid.length>0) return invalid; else return true; } function multi_select(val_arr,obj){ /* Ham nhan vao mot arr va multiselect object, se selected cac item co val trong array */ for(i=0;i<val_arr.length;i++){ for(j=0;j<obj.length;j++){ if(obj[j].value==val_arr[i]){ obj[j].selected=true; break; } } } } function checkbox_checkall(obj,checklist){ if(obj.checked) mycheck = true; else mycheck = false;
for(i=0;i<checklist.length;i++) checklist[i].checked = mycheck; } function check_num(obj,length,e){ var key = window.event ? e.keyCode : e.which; var len = obj.value.length + 1; if(length<=3) begin=48; else begin = 45; if(key>=begin && key<=57 && len <= length || (key==8 || key==0)){ /*var keychar = String.fromCharCode(key); reg = /\d/; return reg.test(keychar);*/ } else return false; } function check_length(obj,length,e){ var key = window.event ? e.keyCode : e.which; var len = obj.value.length + 1; if(len <= length || (key==8 || key==0)){} else return false; }
function share_twitter() { u = location.href; t = document.title; window.open("http://twitter.com/home?status=" + encodeURIComponent(u)); }
function share_facebook() { u = location.href; t = document.title; window.open("http://www.facebook.com/share.php?u=" + encodeURIComponent(u) + "&t=" + encodeURIComponent(t)); }
function share_google() { u = location.href; t = document.title; window.open("http://www.google.com/bookmarks/mark?op=edit&bkmk=" + encodeURIComponent(u) + "&title=" + t + "&annotation=" + t); }
function share_buzz() { u = location.href; t = document.title; window.open("http://buzz.yahoo.com/buzz?publisherurn=Vinabook&targetUrl=" + encodeURIComponent(u)); }
function share_linkhay(){
	u = location.href; window.open("http://linkhay.com/submit?link_url=" + encodeURIComponent(u));
}

