/*
$Id: cp.js,v 1.00 2007/06/26 
(c) 2007 The China Post
*/

function test()

{
   if (! document.forms[1].dateRange[3].checked)
     {
      alert ("Specific - From sould be checked")
      document.forms[1].dateRange[3].focus();
      return false;
     } 
   else
      return true;
  }

function EWindow(sTarget)
{
//window.open(sTarget,"Photo","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=600,height=500,resizable=no");
	var emailWindow = window.open(sTarget,'Email','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=700,height=550,resizable=no');
	emailWindow.focus();
	return true;
}

function MWindow(sTarget)
{
//window.open(sTarget,"Photo","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=600,height=500,resizable=no");
	var movieWindow = window.open(sTarget,'movie','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=640,height=480,resizable=no');
	movieWindow.focus();
	return true;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MaxWindow() { //v2.0
  self.moveTo(0,0)
	self.resizeTo(screen.availWidth,screen.availHeight)
}

  
function diggit() {
 url1="http://digg.com/submit?phase=2&url=";
 url2=window.location.href;
 //location=url1+url2;
 ttt=url1+url2
 window.open(ttt);
 }	

function WPhotos(sTarget)
{
//window.open(sTarget,"Photo","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=674,height=768,resizable=no");
	var photoWindow = window.open(sTarget,'Photo','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,width=528,height=600,resizable=no');
	photoWindow.focus();
	return true;
}

function NewWindow(sTarget)
{
//window.close();
window.opener.open(sTarget,'Article','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,,,resizable=no');
}

function PrintWindow(sTarget)
{
//window.close();
window.open(sTarget,'Print','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,,,resizable=no');
}

function Clear_email() {
  var str=document.forms[1].email.value ;
  if (str == "Enter email (only the first half of email will be shown)")
  {  
	document.forms[1].email.value="";
	document.getElementById('email').style.color='#000000';
	document.forms[1].email.focus();
	}
}

function Clear_commentstxt() {
  var str=document.forms[1].commentstxt.value ;
  if (str == "Enter your comments - 3000 characters max")
  {
	document.forms[1].commentstxt.value="";
	document.getElementById('commentstxt').style.color='#000000';
	document.forms[1].commentstxt.focus();
	}
}


function CheckLen_c() {
	if (document.forms[1].commentstxt.value.length > 3000){
		L1=document.forms[1].commentstxt.value.length;
		str1=document.forms[1].commentstxt.value;
		str2=str1.substr(0,3000);
		alert("Your comments : "+L1+"\r\rexceed 3000 characters");
	  document.forms[1].commentstxt.value=str2;
	  document.forms[1].commentstxt.focus();	
	  return false
	}
	else {
	  return true;
	}	
}


function Clear_code() {
  var str=document.forms[1].CaptchaCode.value ;
  if (str == "Type the code in the image")
  {  
	document.forms[1].CaptchaCode.value="";
	document.getElementById('CaptchaCode').style.color='#000000';
	document.forms[1].CaptchaCode.focus();
	}
}

function Clear_code1() {
  var str=document.forms[0].CaptchaCode.value ;
  if (str == "Type the code in the image")
  {  
	document.forms[0].CaptchaCode.value="";
	document.getElementById('CaptchaCode').style.color='#000000';
	document.forms[0].CaptchaCode.focus();
	}
}

function Check_Comments()
  {

	if ( (is_email()) && (is_commentstxt()) )
      return true;
   else
      return false;
  }

function is_email()
{
	var str=document.forms[1].email.value;
	if ((str!== null) && (str.indexOf('@',0) == -1 || str.indexOf('.',0) == -1 ))
	{
	 alert ("Please enter a valid email address.");
   document.forms['comments'].email.focus();
	 return false;
	}
	else
	return true;
}     

function is_commentstxt()
{
  var str=document.forms[1].commentstxt.value;
  if ((str == "") || (str == "Enter comments here"))
  {
   alert ("Please input your comments")
   document.forms[1].commentstxt.focus();
   return false;
  }
  else
     return true;
}
   
function WReply(sTarget)
{
	var photoWindow = window.open(sTarget,'Reply','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width=400,height=270,resizable=no');
	photoWindow.focus();
	return true;
}


function Clear_Reply_email() {
  var str=document.forms[0].Reply_email.value ;
  if (str == "Enter email (only the first half of email will be shown)")
  {  
	document.forms[0].Reply_email.value="";
	document.getElementById('Reply_email').style.color='#000000';
	document.forms[0].Reply_email.focus();
	}
}

function Clear_Reply_txt() {
  var str=document.forms[0].Reply_txt.value ;
  if (str == "Enter your reply - 3000 characters max")
  {
	document.forms[0].Reply_txt.value="";
	document.getElementById('Reply_txt').style.color='#000000';
	document.forms[0].Reply_txt.focus();
	}
}


function CheckLen_r() {
	if (document.forms[0].Reply_txt.value.length > 3000){
		L1=document.forms[0].Reply_txt.value.length;
		str1=document.forms[0].Reply_txt.value;
		str2=str1.substr(0,3000);
		alert("Your reply : "+L1+"\r\rexceed 3000 characters");
	  document.forms[0].Reply_txt.value=str2;
	  document.forms[0].Reply_txt.focus();	
	  return false
	}
	else {
	  return true;
	}	
}


function Check_Reply()
  {

	if ( (is_reply_email()) && (is_reply_txt()) )
      return true;
   else
      return false;
  }

function is_reply_email()
{
	var str=document.forms[0].Reply_email.value;
	if ((str!== null) && (str.indexOf('@',0) == -1 || str.indexOf('.',0) == -1 ))
	{
	 alert ("Please enter a valid email address.");
   document.forms[0].Reply_email.focus();
	 return false;
	}
	else
	return true;
}     

function is_reply_txt()
{
  var str=document.forms[0].Reply_txt.value;
  if ((str == "") || (str == "Enter reply here"))
  {
   alert ("Please input your reply")
   document.forms[0].Reply_txt.focus();
   return false;
  }
  else
     return true;
}

function back_email() {
  //var str=document.forms['comments'].email.value ;
  //if (str == "Enter email (only the first half of email will be shown)")
  //{  
	//document.forms['comments'].email.value="";
	//document.getElementById('email').style.color='#000000'
	//document.forms['comments'].email.focus();
	//}
	document.forms['comments'].email.focus();

}



function show_it(){
	document.getElementById('popupHealth').style.visibility='visible'
}

function hide_it(){
	document.getElementById('popupHealth').style.visibility='hidden'
}
 