// JavaScript Document
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){
     alert("Please enter a valid email address!")
     return false
  }
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr || str.indexOf(at) <3){
     alert("Please enter a valid email address!")
     return false
  }
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
      alert("Please enter a valid email address!")
      return false
  }
   if (str.indexOf(at,(lat+1))!=-1){
      alert("Please enter a valid email address!")
      return false
   }
   if (str.indexOf(dot,(lat+3))==-1){
      alert("Please enter a valid email address!")
      return false
   }
  
   if (str.indexOf(" ")!=-1){
      alert("Please enter a valid email address!")
      return false
   }
  
   if ((str.length - str.lastIndexOf(".")) < 3)
   {
      alert("Please enter a valid email address!")
      return false
   }
    return true     
 }	

//***********//

function check_capslock(e) {

var myKeyCode=e.keyCode;
var myShiftKey=false;
var myMsg='Caps Lock is On.\n\nTo prevent entering your password incorrectly,\nyou should press Caps Lock to turn it off.';

 // Upper case letters are seen without depressing the Shift key, therefore Caps Lock is on
	if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) {
		alert( myMsg );
		window.event.returnValue = null;
// Lower case letters are seen while depressing the Shift key, therefore Caps Lock is on
	} 
	
	else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) {
		alert( myMsg );
		window.event.returnValue = null;
	}
 
}

//***********//

function CheckNumeric()
{
   // Get ASCII value of key that user pressed
   var key = window.event.keyCode;
	//alert(key);
   // Was key that was pressed a numeric character (0-9)?
   if (( key > 47 && key < 58 )||(key == 46))
      return; // if so, do nothing
   else
      window.event.returnValue = null; // otherwise, discard character
}

function CheckPhone()
{
   // Get ASCII value of key that user pressed
   var key = window.event.keyCode;
	//alert(key);
   // Was key that was pressed a numeric character (0-9)? , -
   if (( key > 47 && key < 58 )||(key == 46)||(key == 45))
      return; // if so, do nothing
   else
      window.event.returnValue = null; // otherwise, discard character
}
//***********//

function Block_Special_char()
{
   
	var key = window.event.keyCode;
	// Was key that was pressed a numeric character (0-9)?
	if ( key != 61 && key != 37 )
		return; // if so, do nothing
	else
		window.event.returnValue = null; // otherwise, discard character
}


function setCookie(cookie_name, cookie_value, cookie_life, cookie_path) {
  var today = new Date()
  var expiry = new Date(today.getTime() + cookie_life * 24*60*60*1000)
  if (cookie_value != null && cookie_value != ""){
    var cookie_string =cookie_name + "=" + escape(cookie_value)
    if(cookie_life){ cookie_string += "; expires=" + expiry.toGMTString()}
    if(cookie_path){ cookie_string += "; path=" + cookie_path}
 	document.cookie = cookie_string
  }
}

function getCookie(name) {
  var index = document.cookie.indexOf(name + "=")
  if (index == -1) { return null}
  index = document.cookie.indexOf("=", index) + 1
  var end_string = document.cookie.indexOf(";", index)
  if (end_string == -1) { end_string = document.cookie.length }
  return unescape(document.cookie.substring(index, end_string))
}
////////////
function delete_checker(msg)
{
return confirm(msg);	
}
//onClick="return delete_checker('Are you sure you want to delete this classified permanently ?');"