function isEmail(s)
{   
  if (s=="") return false;
  if(s.indexOf(" ")>0) return false;
  if(s.indexOf("@")==-1) return false;
  var i = 1;
  var sLength = s.length;
  if (s.indexOf(".")==-1) return false;
  if (s.indexOf("..")!=-1) return false;
  if (s.indexOf("@")!=s.lastIndexOf("@")) return false;
  if (s.lastIndexOf(".")==s.length-1) return false;
  var str="0123456789abcdefghikjlmnopqrstuvwxyz-@._"; 
  for(var j=0;j<s.length;j++)
	{
		if(str.indexOf(s.charAt(j))==-1) return false;
	}
  return true;
}

function isURL(s)
{
  if (s=="") return false;
	s= toLowerCase(s);
  if(s.indexOf(" ")>0) return false;
  var i = 1;
  var sLength = s.length;
  if (s.indexOf(".")==-1) return false;
  if (s.indexOf("..")!=-1) return false;
  if (s.lastIndexOf(".")==s.length-1) return false;
  var str="0123456789abcdefghikjlmnopqrstuvwxyz-._:/"; 
  for(var j=0;j<s.length;j++)
	if(str.indexOf(s.charAt(j))==-1) return false;
  return true;
}

function FileName(strFile)
{
	if(strFile=="") return "";
	var pos = strFile.lastIndexOf("/") + 1;
	var filename = strFile.substr(pos);
	return filename;
}

function isEmpty(s)
{   
	return ((s == null) || (s.length == 0))
}

function isWhitespace (s)
{   
	var whitespace = " \t\n\r";
	var i;

  if (isEmpty(s)) return true;
  for (i = 0; i < s.length; i++)
  {   
    var c = s.charAt(i);
    if (whitespace.indexOf(c) == -1) return false;
  }
  return true;
}

function isNumber(num)
{
	if(num=="") return false;
	var str="0123456789";
	var len = num.length;
	for(var i=0;i<len;i++)
	{
		if(str.indexOf(num.charAt(i))==-1) return false;
	}
	return true;
}

function checkTelNum(num)
{
	if(num!="")
	{
		if(!isNumber(num)) return false;
		if(num.length<7) return false;
	}
	return true;
}

function checkDate(s_d,s_m,s_y,e_d,e_m,e_y)
{
	s_d = parseInt(s_d);
	s_m = parseInt(s_m);
	s_y = parseInt(s_y);
	
	e_d = parseInt(e_d);
	e_m = parseInt(e_m);
	e_y = parseInt(e_y);
	
	if(e_y<s_y) return false;
	else if(e_y==s_y)
	{
		if(e_m<s_m) return false;
		else if(e_m==s_m)
		{
			if(e_d<=s_d) return false;
		}
	}
	return true;
}

function jumpTop()
{
		window.scrollTo(0,0);
}

function docheck(status)
{
	var alen=document.frmList.elements.length;
	alen=(alen>5)?document.frmList.chkid.length:0;
	if (alen>0)
	{
			for(var i=0;i<alen;i++)
			document.frmList.chkid[i].checked=status;
	}
					else
	{
			document.frmList.chkid.checked=status;
	}
}

function calculatechon()
{
	var strchon="";
	var alen=document.frmList.elements.length;
	//var buttons=(document.frmaction.cbtype.value=="")?6:7;

	alen=(alen>6)?document.frmList.chkid.length:0;
	if (alen>0)
	{
			for(var i=0;i<alen;i++)
			if(document.frmList.chkid[i].checked==true)
				strchon+=document.frmList.chkid[i].value+",";
	}else
	{
		if(document.frmList.chkid.checked==true)
			strchon=document.frmList.chkid.value;
	}
	document.frmList.chon.value=strchon;
}

function checkInput()
{
	var alen=document.frmList.elements.length;
	//var buttons=(document.frmaction.cbtype.value=="")?6:7;
	var isChecked=false;
	alen=(alen>6)?document.frmList.chkid.length:0;
	if (alen>0)
	{
		for(var i=0;i<alen;i++)
			if(document.frmList.chkid[i].checked==true) isChecked=true;
	}
	else
	{
		if(document.frmList.chkid.checked==true) isChecked=true;
	}
	
	if (!isChecked) alert("Please select at least one of them");
	else
	{
		if(!confirm("Are you sure want to delete them")) isChecked=false;
		else calculatechon();
	}
	return isChecked;
}

function delCurObj(val)
{
	var frm = eval('document.frmList');
	alen = frm.chkid.length;
	if(alen>0)
	{
		for(i=0;i<alen;i++)
		{
			if(frm.chkid[i].value==val) frm.chkid[i].checked = true;
			else frm.chkid[i].checked = false;
		}
	}
	else
	{
		frm.chkid.checked = true;
	}
	if(checkInput()) frm.submit();
}

function chgLang(val) 
{
	if(val==null) val = 'E';
	document.frmLang.lang.value = val;
	document.frmLang.submit();
}

function insImg(img,scalew,scaleh,others)
{
	var str = '';
	var image = new Image();
	image.src = img;
	
	if(scalew==0||scaleh==0) return false;
	if(scalew==null) scalew = 0.01;
	if(scaleh==null) scaleh = 0.01;
	
	w = (screen.width)*scalew;
	h = (screen.height)*scaleh;
	
	if(img!=null)
	{
		str += '<img src="'+img+'" width="'+w;
		str += '" height="'+h+'" '+others+'>';
	}
	document.write(str);
}

function showImg(image,maxW,maxH,others)
{
	var str = '';
	var img = new Image();
	img.src = image;
	
	var imgW = img.width;
	var imgH = img.height;
	
	if(maxW==0||maxH==0) return false;
	if(maxW==null) maxW = 500;
	if(maxH==null) maxH = 400;	
	var ratio = Math.min(maxW/imgW,maxH/imgH);
	if(ratio < 1)
	{
		imgW = imgW*ratio;
		imgH = imgH*ratio;
	}

	if(image!=null)
	{
		str += "<img src="+image+" width="+imgW;
		str += " height="+imgH+" "+others+">";
	}
	document.write(str);
}

function high(which2)
{
	theobject = which2;
	highlighting = setInterval("highlightit(theobject)",50);
}
function low(which2)
{
	clearInterval(highlighting);
	opaStart = 0;
	which2.filters.alpha.opacity = opaStart;
}
function highlightit(curObj)
{	
	if (opaStart<100)
	{
		opaStart += step;
		curObj.filters.alpha.opacity = opaStart;
	}
	else if(window.highlighting) clearInterval(highlighting);
}

function SHOW_WEATHER()
{
	step = 5;
	opaStart = 0;
	if(cur_weather_obj>len-2)
	{
		cur_weather_obj = 0;
		loop_weather_show++;
	}
	if(cur_weather_obj>0) 
	{
		weather_obj[cur_weather_obj-1].style.display = 'none';
		low(weather_obj[cur_weather_obj-1]);
		clearInterval(weather_interval);
	}
	else if(loop_weather_show>0)
	{
		weather_obj[len-2].style.display = 'none';
		low(weather_obj[len-2]);
		clearInterval(weather_interval);
	}
	weather_obj[cur_weather_obj].style.display = '';
	weather_obj[cur_weather_obj].filters.alpha.opacity = 0;
	high(weather_obj[cur_weather_obj]);	
	if(loop_weather_show<10){weather_interval = setInterval("SHOW_WEATHER()",10000);}
	else if(window.weather_interval){clearInterval(weather_interval);}
	cur_weather_obj++;
}

function rect(text,width,height,clr,style)
{	
	var s = null;
	var nowrap = null;
	if(width==null)
	{
		width = 200;
		nowrap = 'nowrap';
	}
	if(height==null) height = 25;
	if(clr==null) clr = '#FFFFFF';
	if(style==null) style = 'textbox';
	
	s  = '<table width='+width+' height='+height+'><tr>';
	s += '<td '+nowrap+' bgcolor='+clr+' height="100%" valign=top';
	s += 'width=100% class='+style+'><div align=justify>'+text+'</div></td></tr></table>';
	document.write(s);
}
