// JavaScript Document
function isValidInput(formName){
	var strTitleENG =formName.strTitleENG.value;
	//alert("strTitleENG ="+strTitleENG);
	var strDescriptionENG=formName.strDescriptionENG.value;
	//alert("strDescriptionENG ="+strDescriptionENG.length);
	var strTitleFR =formName.strTitleFR.value;
	//alert("strTitleFR ="+strTitleFR);
	var strDescriptionFR=formName.strDescriptionFR.value;
	//alert("strDescriptionFR ="+strDescriptionFR.length);
	
	var strTitleCHN =formName.strTitleCHN.value;
	//alert("strTitleFR ="+strTitleCHN);
	var strDescriptionCHN=formName.strDescriptionCHN.value;
	//alert("strDescriptionCHN ="+strDescriptionCHN.length);
	
	var done=false;
	var index=formName.imageName.selectedIndex
	//alert("submit: "+strTitleCHN);
	if(formName.dDate.value == ""){
		alert("Date is empty")
		return false;
	}
	
	if(strTitleENG == "" || strDescriptionENG.length < 100 ){
		alert("News in English is not filled or too short");
		return false;
	}
	if(strTitleFR == "" || strDescriptionFR.length < 100 ){
		alert("News in French is not filled or too short ");
		return false;
	}
	if(strTitleCHN == "" || strDescriptionCHN.length < 100){
		
		alert("News in Chinse is not filled or too short");
		return false;
	}
			
	if(strTitleENG.length > 150 ||strDescriptionENG>65535){
		alert("please check length of title(<150) or description(<65535)")
		return false;
	}
		
	if(strTitleCHN.length > 150 ||strDescriptionCHN>65535){
		alert("please check length of title(<150) or description(<65535)")
		return false;
	}
	if(strTitleFR.length > 150 ||strDescriptionFR>65535){
		alert("please check length of title(<250) or description(<65535)")
		return false;
	}
	
	return true;
}

function clickButton(url){
		document.location.href =url;
}
function preview(idName,target,url,opt){		

	var x=document.getElementById(idName)
	
	var i=x.options[x.selectedIndex].index
	
	if(i == 0){
		alert("please select an image")
		return false;
	}
	else{
		fileName=x.options[x.selectedIndex].text
		path = url + fileName;
		
		window.open(path,target,opt);
	}
}
function popUpWindow(url,target,para){
	var t=window.screenTop;
	var l=window.screenLeft;

	mywindow=window.open(url, target, "width=500,height=400,toolbar=no,resizable=no,scrollbars=yes")
	//mywindow=window.open(url, target,"toolbar=no,resizable=yes");
	mywindow.moveTo(0,0);
	if(para == 1){
		mywindow.resizeTo(screen.availWidth,screen.availHeight);
	}
}
function moveWindow(){
	var y=window.opener.screenTop;
	var x=window.opener.screenLeft;
	
	window.moveTo(x,y);
}
function confirmDelete(){
	var agree=confirm("Are you sure you want to delete this record?");
	if (agree)
		
		return true ;
	else
		return false ;
}
function popWindow(URL,w,h){
  //alert("fullscreen2=1;toolbar=0,location=0,directories=0,menubar=0,resizable=1,scrollbars=1,status=1,top="+((screen.availHeight-h)/2)+",left="+((screen.availWidth-w)/2)+",width="+w+",height="+h);
  if(w==-1){
    w=screen.availWidth;
  }
  if(h==-1){
    h=screen.availHeight;
  }
  var curWin=window.open(URL,"","fullscreen2=1;toolbar=0,location=0,directories=0,menubar=0,resizable=1,scrollbars=1,status=1,top="+((screen.availHeight-h)/2)+",left="+((screen.availWidth-w)/2)+",width="+w+",height="+h)
  if(w==screen.availWidth && h==screen.availHeight){
    curWin.window.moveTo(0,0);
    if (document.all) {
      curWin.window.resizeTo(screen.availWidth,screen.availHeight);
    }else if (document.layers||document.getElementById) {
      if (curWin.window.outerHeight < screen.availHeight||curWin.window.outerWidth < screen.availWidth){
        curWin.window.outerHeight = screen.availHeight;
        curWin.window.outerWidth = screen.availWidth;
      }
    }
  }
}

function openURL(curURL,w,h){
  window.open(curURL,"_self","fullscreen2=1;toolbar=0,location=0,directories=0,menubar=0,resizable=1,scrollbars=1,status=1,top="+((screen.availHeight-h)/2)+",left="+((screen.availWidth-w)/2)+",width="+w+",height="+h)
}
function touchMenu(id1,id2){
 id1.style.background="#a1b6bf";
 id2.style.background="#a1b6bf";
}
function outMenu(id1,id2){
 id1.style.background="c7dae0"
 id2.style.background="c7dae0"
}

function touchButton(id1){
 id1.style.background="#a1b6bf";
}
function outButton(id1){
 id1.style.background="c7dae0";
}

function drawCloseWindow(pos){
  drawButton(pos,122,20,"window.close();","Close Window");
}

function drawSubmit(pos){
  drawButton(pos,60,20,"document.editform.submit();","Submit");
}

function drawReset(pos){
  drawButton(pos,60,20,"document.editform.reset();","Reset");
}

function drawModify(pos,sURL){
  drawButton(pos,60,20,sURL,"Modify");
}

function drawDelete(pos,sURL){
  drawButton(pos,60,20,sURL,"Delete");
}

function drawRefresh(pos,sURL){
  drawButton(pos,60,20,"history.go(0);","Refresh");
}

function drawCloseWinRefresh(pos){
  var tmp="<table border=0 cellpadding=0 cellspacing=0><tr><td>"+getButton(60,20,"history.go(0);","Refresh")+"</td>";
  tmp+="<td width=5></td><td>"+getButton(130,20,"window.close();","Close Window")+"</td></tr></table>";
  pos.innerHTML=tmp;
}

function getButton(iWidth,iHeight,sURL,sCaption){
  var tmp="<TABLE class=st_tbcss id=mainmenu style=\"Z-INDEX: 1000; FILTER: progid:DXImageTransform.Microsoft.Fade(overlap=.5,enabled=0,Duration=0.52) progid:DXImageTransform.Microsoft.Alpha(enabled=false,opacity=100) progid:DXImageTransform.Microsoft.dropshadow(color=#999999,offx=1,offy=1,positive=1); VISIBILITY: visible; WIDTH: 0px; POSITION: static\" cellSpacing=0 cellPadding=0>"
         +"<TR><TD><TABLE cellSpacing=0 cellPadding=0 width="+iWidth+"><TR id=menu3 onclick=\"javascript:"+sURL+"\">"
         +"<TD class=\"menu_bar_rim\" vAlign=center height=\"100%\"><TABLE class=menu_bar_table2 cellSpacing=0 cellPadding=0 width=\"100%\">"
         +"<TR><TD class=menu_bar_td2 vAlign=center align=center height="+iHeight+" onmouseover=\"javascript:touchButton(this);\" onmouseout=\"javascript:outButton(this);\"><FONT style=\"FONT: 8pt Verdana;\">"+sCaption+"</FONT></TD>"
         +"</TR></TABLE></TD></TR></TABLE></TD></TR></TABLE>";
  return tmp;
}

function drawButton(pos,iWidth,iHeight,sURL,sCaption){
  pos.innerHTML=getButton(iWidth,iHeight,sURL,sCaption);
}
	
