
/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
//open new window when user click on submenu
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//end

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate
//for loading i
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//for index.html
function onchangeWebsite(){		
 	var webObj = document.getElementById('websiteId'); 	
 	var webIndex=webObj.selectedIndex;
 	var webValue=webObj.options[webIndex].value; 
 	document.getElementById("vnexpressId").style.display ="none";
 	document.getElementById("ngoisaoId").style.display="none";
 	if(webValue==null||webValue=='')
 		webValue='Vnexpress';
 	if(webValue=='Vnexpress'){ 		
 		hidden('Vnexpress'); 		
 		document.getElementById("vnexpressId").style.display ="inline"; 
 		//set default displaying for Vnexpress
 		document.getElementById("VneLargeLogo1Id").style.display ="inline"; 		
 			
 	}else{ 	
 		hidden('Ngoisao'); 		
 		document.getElementById("ngoisaoId").style.display="inline";
 		//set default displaying for Ngoi sao
 		document.getElementById("LeaderboardId").style.display ="inline"; 
 		document.getElementById("NgoisaodefaultId").selected ="true"; 
 		
  	} 		
 }
 /*------Vitri process---*/
 function onchangeVitri(){ 
 	// get website type, get wesite element
 	var webObj = document.getElementById('websiteId'); 	
 	var webIndex=webObj.selectedIndex;
 	var webValue=webObj.options[webIndex].value;
 	hidden('Vnexpress');
 	hidden('Ngoisao'); 	
 	//for ngoi sao news
 	if('Ngoisao'==webValue){
 		//get vitri element
 		var vitriObj = document.getElementById('NgoisaoVitriId');
 		var vitriIndex=vitriObj.selectedIndex; 
 		var vitriValue=vitriObj.options[vitriIndex].value; 		
	 	if(vitriValue==null||vitriValue=='')
	 		vitriValue='1';
	 	if(vitriValue=='1'){ 		
	 		document.getElementById("LeaderboardId").style.display ="inline"; 		
	 	}else if(vitriValue=='2'){ 	
	 		
	 		document.getElementById("MediumrectangleId").style.display="inline";
	 		
	 	}else if(vitriValue=='3'){ 	
	 
	 		document.getElementById("BreakPageId").style.display="inline";
	 		
	 	}else if(vitriValue=='4'){ 	
	 	
	 		document.getElementById("SquarePopUp1Id").style.display="inline";
	 		
	 	}else if(vitriValue=='5'){ 
	 	
	 		document.getElementById("SquarePopUp2Id").style.display="inline";
	 		
	 	}else if(vitriValue=='6'){ 	
	 	
	 		document.getElementById("SkycraperId").style.display="inline";
	 		
	 	}else if(vitriValue=='7'){ 	
	 		document.getElementById("RichmediaId").style.display="inline";
	 		
	 	}else if(vitriValue=='8'){ 	
	 		document.getElementById("BasicId").style.display="inline";
	 		
	 	}else if(vitriValue=='9'){ 	
	 		document.getElementById("BottomId").style.display="inline";
	 		
	 	}else if(vitriValue=='10'){ 	
	 		document.getElementById("BrandnameId").style.display="inline";
	 		
	 	}else if(vitriValue=='11'){ 	
	 		document.getElementById("ArticleId").style.display="inline";
	 		
	 	}else if(vitriValue=='12'){
	 		document.getElementById("LogotinnoibatId").style.display="inline";
	 	}	 	 	 	 	 	 	 	 	 	
 	}else if('Vnexpress'==webValue){
 		//get vitri element
 		var vitriObj = document.getElementById('VneVitriId');
 		var vitriIndex=vitriObj.selectedIndex; 
 		var vitriValue=vitriObj.options[vitriIndex].value;
 		//alert(vitriValue); 		 	  	
	 	if(vitriValue==null||vitriValue=='')
	 		vitriValue='1';
	 	if(vitriValue=='1'){ 		
	 		document.getElementById("VneLargeLogo1Id").style.display ="inline"; 		
	 	}else if(vitriValue=='2'){ 	
	 		document.getElementById("VneLargeLogo2Id").style.display="inline";
	 		
	 	}else if(vitriValue=='3'){ 	
	 		document.getElementById("VneLogotinnoibatId").style.display="inline";
	 		
	 	}else if(vitriValue=='4'){ 	
	 		document.getElementById("VneBigLogo1Id").style.display="inline";
	 		
	 	}else if(vitriValue=='5'){ 	
	 		document.getElementById("VneBigLogo2Id").style.display="inline";
	 		
	 	}else if(vitriValue=='6'){ 	
	 		document.getElementById("VneBigLogo3Id").style.display="inline";
	 		
	 	}else if(vitriValue=='7'){ 	
	 		document.getElementById("VneBigLogo4Id").style.display="inline";
	 		
	 	}else if(vitriValue=='8'){ 	
	 		document.getElementById("VneBigLogo5Id").style.display="inline";
	 		
	 	}else if(vitriValue=='9'){ 	 			
	 		document.getElementById("VneBasicLogoId").style.display="inline";
	 		
	 	}else if(vitriValue=='10'){ 	
	 		document.getElementById("VneRightLogo1Id").style.display="inline";
	 		
	 	}else if(vitriValue=='11'){ 	
	 		document.getElementById("VneRightLogo2Id").style.display="inline";
	 		
	 	}else if(vitriValue=='12'){ 	
	 		document.getElementById("VneLargeLogo3Id").style.display="inline";
	 		
	 	}else if(vitriValue=='13'){ 	
	 		document.getElementById("VneLargeLogo4Id").style.display="inline";
	 		
	 	}else if(vitriValue=='14'){ 		
	 		document.getElementById("VneFooterBannerId").style.display ="inline"; 		
	 	}else if(vitriValue=='15'){ 	
	 		//document.getElementById("VneFooterExpandId").style.display="inline";
	 		
	 	}else if(vitriValue=='16'){ 	
	 		document.getElementById("VnePopUnderId").style.display="inline";
	 		
	 	}else if(vitriValue=='17'){ 	
	 		document.getElementById("VneTopBannerId").style.display="inline";
	 		
	 	}else if(vitriValue=='18'){ 	
	 		//document.getElementById("VneExpandBannerId").style.display="inline";
	 		
	 	}else if(vitriValue=='19'){ 	
	 		document.getElementById("VneBasicCodinh1Id").style.display="inline";
	 		
	 	}else if(vitriValue=='20'){ 	
	 		document.getElementById("VneBasicCodinh2Id").style.display="inline";
	 		
	 	}else if(vitriValue=='21'){ 	
	 		document.getElementById("VneBasicCodinh3Id").style.display="inline";
	 		
	 	}else if(vitriValue=='22'){ 	
	 		document.getElementById("VneArticleBannerId").style.display="inline";
	 		
	 	} 	 
 	}
 }
 
 function view(){
 	// get website type, get wesite element
 	var webObj = document.getElementById('websiteId'); 	
 	var webIndex=webObj.selectedIndex;
 	var webValue=webObj.options[webIndex].value;
 	//for ngoi sao news 	
 	if('Ngoisao'==webValue){	
 		//get vitri element
 		var vitriObj = document.getElementById('NgoisaoVitriId');
 		var vitriIndex=vitriObj.selectedIndex; 
 		var vitriValue=vitriObj.options[vitriIndex].value; 	
	 	if(vitriValue==null||vitriValue=='')
	 		vitriValue='1';	 	
	 	if(vitriValue=='1'){ 	 		
	 		MM_openBrWindow('vitringoisao/ngoisao_leaderboard.html#1','NgoisaoLeaderboard','');	
	 	}else if(vitriValue=='2'){
	 		MM_openBrWindow('vitringoisao/ngoisao_mediumrectangle.html#1','NgoisaoMediumrectangle','');
	 		
	 	}else if(vitriValue=='3'){ 	
	 		
	 		MM_openBrWindow('vitringoisao/ngoisao_breakpage.html#1','NgoisaoBreakpage','');
	 		
	 	}else if(vitriValue=='4'){ 	
	 		
	 		MM_openBrWindow('vitringoisao/ngoisao_squarepopup1.html#1','NgoisaoSquarepopup1','');
	 		
	 	}else if(vitriValue=='5'){ 	
	 		
	 		MM_openBrWindow('vitringoisao/ngoisao_squarepopup2.html#1','NgoisaoSquarepopup2','');
	 		
	 	}else if(vitriValue=='6'){ 	
	 		
	 		MM_openBrWindow('vitringoisao/ngoisao_skyscraper.html#1','NgoisaoSkyscraper','');
	 		
	 	}else if(vitriValue=='7'){ 	
	 	
	 		MM_openBrWindow('vitringoisao/ngoisao_richmedia.html#1','NgoisaoRichmedia','');
	 		
	 	}else if(vitriValue=='8'){ 	
	 		
	 		MM_openBrWindow('vitringoisao/ngoisao_basic.html#1','NgoisaoBasic','');
	 		
	 	}else if(vitriValue=='9'){ 	
	 		
	 		MM_openBrWindow('vitringoisao/ngoisao_bottom.html#1','NgoisaoBottom','');
	 		
	 	}else if(vitriValue=='10'){ 	
	 		
	 		MM_openBrWindow('vitringoisao/ngoisao_brandname.html#1','NgoisaoBrandname','');
	 		
	 	}else if(vitriValue=='11'){ 	 		
	 		MM_openBrWindow('vitringoisao/ngoisao_article.html#1','NgoisaoArticle','');
	 		
	 	}else if(vitriValue=='12'){ 	 		
	 		MM_openBrWindow('vitringoisao/topstory_ngoisao.html#1','Logotinnoibat','');
	 		
	 	}  	 	 	 	 	 	 	 	 	 	
 	}else if('Vnexpress'==webValue){
 		//get vitri element
 		var vitriObj = document.getElementById('VneVitriId');
 		var vitriIndex=vitriObj.selectedIndex; 
 		var vitriValue=vitriObj.options[vitriIndex].value; 	
 		if(vitriValue==null||vitriValue=='')
	 		vitriValue='1';
	 	if(vitriValue=='1'){
	 		MM_openBrWindow('vitrivnexpress/Vnehome_large1.html#1','VneHomeLarge1','');	
	 	}else if(vitriValue=='2'){ 
	 		MM_openBrWindow('vitrivnexpress/Vnehome_large2.html#1','VneHomeLarge2','');	 		
	 	}else if(vitriValue=='3'){
	 		MM_openBrWindow('vitrivnexpress/topstory.html#1','LogoTinnoibat','');	 		
	 	}else if(vitriValue=='4'){
	 		MM_openBrWindow('vitrivnexpress/Vnehome_big1.html#1','VnehomeBig1','');	 		
	 	}else if(vitriValue=='5'){
	 		MM_openBrWindow('vitrivnexpress/Vnehome_big2.html#1','VnehomeBig2','');
	 	}else if(vitriValue=='6'){ 	
	 		MM_openBrWindow('vitrivnexpress/Vnehome_big3.html#1','VnehomeBig3','');	 		
	 	}else if(vitriValue=='7'){ 	
	 		MM_openBrWindow('vitrivnexpress/Vnehome_big4.html#1','VnehomeBig4','');	 		
	 	}else if(vitriValue=='8'){ 	
	 		MM_openBrWindow('vitrivnexpress/Vnehome_big5.html#1','VnehomeBig5','');
	 	}else if(vitriValue=='9'){
	 		MM_openBrWindow('vitrivnexpress/Vnehome_basic.html#1','BasicLogo','');
	 	}else if(vitriValue=='10'){
	 		MM_openBrWindow('vitrivnexpress/Vnehome_right1.html#1','RightLogo1','');
	 	}else if(vitriValue=='11'){ 	
	 		MM_openBrWindow('vitrivnexpress/Vnehome_right2.html#1','RightLogo2','');	 		
	 	}else if(vitriValue=='12'){
	 		MM_openBrWindow('vitrivnexpress/Vnehome_large3.html#1','LargeLogo3','');
	 		
	 	}else if(vitriValue=='13'){
	 		MM_openBrWindow('vitrivnexpress/Vnehome_large4.html#1','LargeLogo4','');
	 	//lacking...begin
	 	}else if(vitriValue=='14'){
	 		MM_openBrWindow('vitrivnexpress/Vnehome_footer.html#1','FooterBanner','');
	 		
	 	}else if(vitriValue=='15'){
	 		//MM_openBrWindow('vitrivnexpress/Vnehome_footer.html#1','TopBanner','');
	 		
	 	}else if(vitriValue=='16'){
	 		MM_openBrWindow('vitrivnexpress/Vnehome_popunder.htm#1','BasicCodinh1','');
	 		
	 	}else if(vitriValue=='17'){
	 		MM_openBrWindow('vitrivnexpress/vitrivne_inside_top.html#1','BasicCodinh2','');
	 	//lacking...end	
	 	}else if(vitriValue=='18'){
	 		//MM_openBrWindow('vitrivnexpress/Vnehome_popunder.htm','PopUnder','');
	 		
	 	}else if(vitriValue=='19'){
	 	MM_openBrWindow('vitrivnexpress/vitrivne_inside_basic01.html#1','BasicCodinh1','');
	 		
	 	}else if(vitriValue=='20'){
	 		MM_openBrWindow('vitrivnexpress/vitrivne_inside_basic02.html#1','BasicCodinh2','');
	 		
	 	}else if(vitriValue=='21'){
	 		MM_openBrWindow('vitrivnexpress/vitrivne_inside_basic03.html#1','BasicCodinh3','');
	 		
	 	}else if(vitriValue=='22'){
	 		MM_openBrWindow('vitrivnexpress/vitrivne_inside_articlebanner.html#1','ArticleBanner','');
	 		
	 	} 	 	 	 	 	 	 	 	 	 	 	
 	}
 	
 }
 function hidden(type){ 	
 	if('Vnexpress'==type){ 	
 		/*hidden all size*/
	 	document.getElementById("VneLargeLogo1Id").style.display="none";
	 	document.getElementById("VneLargeLogo2Id").style.display="none";
	 	document.getElementById("VneLogoTinNoiBatId").style.display="none";
	 	document.getElementById("VneBigLogo1Id").style.display="none";
	 	document.getElementById("VneBigLogo2Id").style.display="none";
	 	document.getElementById("VneBigLogo3Id").style.display="none";
	 	document.getElementById("VneBigLogo4Id").style.display="none"; 
	 	document.getElementById("VneBigLogo5Id").style.display="none";
	 	document.getElementById("VneBasicLogoId").style.display="none";
	 	document.getElementById("VneRightLogo1Id").style.display="none";
	 	document.getElementById("VneRightLogo2Id").style.display="none";
	 	document.getElementById("VneLargeLogo3Id").style.display="none";
	 	document.getElementById("VneLargeLogo4Id").style.display="none";	 	
	 	document.getElementById("VneFooterBannerId").style.display="none";
	 	//document.getElementById("VneFooterExpandId").style.display="none";
	 	document.getElementById("VnePopUnderId").style.display="none";	 	
	 	document.getElementById("VneTopBannerId").style.display="none";
	 	//document.getElementById("VneExpandBannerId").style.display="none";
	 	document.getElementById("VneBasicCodinh1Id").style.display="none";
	 	document.getElementById("VneBasicCodinh2Id").style.display="none"; 
	 	document.getElementById("VneBasicCodinh3Id").style.display="none";
	 	document.getElementById("VneArticleBannerId").style.display="none";	
	 	
 	}else if('Ngoisao'==type){
 		/*hidden all size*/
	 	document.getElementById("LeaderboardId").style.display="none";
	 	document.getElementById("LogotinnoibatId").style.display="none";
	 	document.getElementById("MediumrectangleId").style.display="none";
	 	document.getElementById("BreakPageId").style.display="none";
	 	document.getElementById("SquarePopUp1Id").style.display="none";
	 	document.getElementById("SquarePopUp2Id").style.display="none";
	 	document.getElementById("SkycraperId").style.display="none"; 
	 	document.getElementById("RichmediaId").style.display="none";
	 	document.getElementById("BasicId").style.display="none";
	 	document.getElementById("BottomId").style.display="none";
	 	document.getElementById("BrandnameId").style.display="none";
	 	document.getElementById("ArticleId").style.display="none"; 
 	}
 } 

 function displaySendTo(valueType){ 
 	document.getElementById("vneDisplayId").style.display="none";
 	document.getElementById("ngoisaoDisplayId").style.display="none"; 
 	if(valueType=='Vnexpress'||valueType=='Sohoa'||valueType=='Gamethu'||valueType=='Vieclam'){
 		document.getElementById("vneDisplayId").style.display="inline";
 	}else{
 		document.getElementById("ngoisaoDisplayId").style.display="inline";
 	} 	
 }
 
 function sendToOnchange(){ 	
 	// get website type, get wesite element
 	var sendToObj = document.getElementById('sendToId'); 	
 	var sendToIndex=sendToObj.selectedIndex; 
 	var sendToValue=sendToObj.options[sendToIndex].value; 	
 	displaySendTo(sendToValue); 	
 }
 //verify email
 function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){		  
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){		  
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){		   
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){		    
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){		   
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){		   
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){		   
		    return false
		 }

 		 return true					
	}
 
 function isValidEmail(field){ 
	if (echeck(field.value)==false){
		field.value=""
		field.focus()
		return false
	}
	return true 
 }
 function isEmpty(field){
 	if(field.value==null||field.value==''||field.value==""){ 		
		return true;
 	} 	
 	return false;
 }
 //for check numeric
 
 
// calculate the ASCII code of the given character
function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);

  /* Check if the keyed in character is a number
     do you want alphabetic UPPERCASE only ?
     or lower case only just check their respective
     codes and replace the 48 and 57 */

  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}
//validate lien he
function verifySenToForm(form){
	var name=form.name;
	var phone=form.phone;
	var email=form.email;
	var content=form.content;
	if(isEmpty(name)){
		alert('Họ tên là bắt buộc.');
		name.focus();
		return false;
	}
	if(isEmpty(phone)){
		alert('Điện thoại là bắt buộc.');
		phone.focus();
		return false;
	}
	if(isEmpty(email)){
		alert('Email là bắt buộc.');
		email.focus();
		return false;
	}
	if(!echeck(email.value)){
		alert('Không đúng định dạng Email,xin hãy nhập lại.');
		email.value="";
		email.focus();
		return false;
	}
	if(isEmpty(content)){
		alert('Nội dung là bắt buộc.');
		content.focus();
		return false;
	}
	form.cn.value="1";
}