function NewCal(x,y,z)
{
	window.open(x+"calendar.php?form="+y+"&fld="+z,"_himangshu","width=200,height=200,addressbar=no,scrollbars=no");
}
function redirect(x)
{
 window.location.href=x;
}
function isDate(Dt)
{
  if(isNaN(Dt.substr(0,4)-0)||!(Dt.substr(5,2)-0)||(Dt.substr(5,2)-0>12)||isNaN(Dt.substr(5,2)-0)||!(Dt.substr(8,2)-0)||(Dt.substr(8,2)-0>31)||isNaN(Dt.substr(8,2)-0)||(Dt.substr(8,2)-0>30 && (Dt.substr(5,2)-0==4 || Dt.substr(5,2)-0==6 || Dt.substr(5,2)-0==9 ||Dt.substr(5,2)-0==11))||(Dt.substr(5,2)-0==2 && (Dt.substr(0,4)-0)%4==0 && Dt.substr(8,2)-0>29)||(Dt.substr(5,2)-0==2 && (Dt.substr(0,4)-0)%4!=0 && Dt.substr(8,2)-0>28)||Dt.substr(4,1)!="-"||Dt.substr(7,1)!="-")
  {
      return false;
  }
  else
  {
      return true
  }
}

function doBlink() {
  var blink = document.all.tags("BLINK")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  if (document.all)
    setInterval("doBlink()",1000)
}
window.onload = startBlink;


function isEmail(Ml)
{
  if(!Ml){return true}
  if(Ml.indexOf("@")<=0 || Ml.indexOf("@")==Ml.length-1 || Ml.indexOf(".")<=0 || Ml.indexOf(".")==Ml.length-1 || Ml.indexOf("..")!=-1 || Ml.indexOf("@@")!=-1 || Ml.indexOf("@.")!=-1 || Ml.indexOf(".@")!=-1)
  {
      return false
  }
  else
  {
      return true
  }
}

function Trim (s){return LTrim(RTrim(' '+s));}
function LTrim (s)
{
    if(!s){return '';}
    while(s.charAt(0)==' ')
        s = s.substring(1,s.length);
    return s;
}
//..............

function RTrim (s)
{
    if(!s || s==' '){return '';}
    if (s.length > 1)
    {
        while(s.charAt(s.length-1)==' ')
            s = s.substring(0,s.length-2);
        return s;
    }
}

function makeArray(n) 
{
this.length = n
return this
}
monthNames = new makeArray(12)
monthNames[1] = "January"
monthNames[2] = "February"
monthNames[3] = "March"
monthNames[4] = "April"
monthNames[5] = "May"
monthNames[6] = "June"
monthNames[7] = "July"
monthNames[8] = "August"
monthNames[9] = "September"
monthNames[10] = "October"
monthNames[11] = "November"
monthNames[12] = "December"

dayNames=new makeArray(7)
dayNames[1]="Sunday";
dayNames[2]="Monday";
dayNames[3]="Tuesday";
dayNames[4]="Wednesday";
dayNames[5]="Thursday";
dayNames[6]="Friday";
dayNames[7]="Saturday";

function dateString(oneDate) 
{
	var theDay = dayNames[oneDate.getDay() + 1]
	var theMonth = monthNames[oneDate.getMonth() + 1]
	var theYear = oneDate.getFullYear()
	return theDay +" "+ theMonth + " " + oneDate.getDate() + ", " + theYear
}
function isDate(Dt)
{
  if(isNaN(Dt.substr(0,4)-0)||!(Dt.substr(5,2)-0)||(Dt.substr(5,2)-0>12)||isNaN(Dt.substr(5,2)-0)||!(Dt.substr(8,2)-0)||(Dt.substr(8,2)-0>31)||isNaN(Dt.substr(8,2)-0)||(Dt.substr(8,2)-0>30 && (Dt.substr(5,2)-0==4 || Dt.substr(5,2)-0==6 || Dt.substr(5,2)-0==9 ||Dt.substr(5,2)-0==11))||(Dt.substr(5,2)-0==2 && (Dt.substr(0,4)-0)%4==0 && Dt.substr(8,2)-0>29)||(Dt.substr(5,2)-0==2 && (Dt.substr(0,4)-0)%4!=0 && Dt.substr(8,2)-0>28)||Dt.substr(4,1)!="-"||Dt.substr(7,1)!="-")
  {
      return false;
  }
  else
  {
      return true
  }
}



function ValidPro(frm)
{
    var txt="";
	
	 if(!frm.title.value) 
	{
	   txt+="     Property Title should not be blank.\n";
	}	
    if(!frm.propertyref.value) 
	{
	   txt+="     Property Reference should not be blank.\n";
	}	
	/*if(!frm.cat_id.value) 
	{
	   txt+="     Please select any Property Category.\n";
	}	
	if(!frm.location.value) 
	{
	   txt+="     Location should not be blank.\n";
	}*/
	if(!frm.description.value) 
	{
	   txt+="     Description should not be blank.\n";
	}	
	
 	if(txt)
	{
   	  alert("Sorry. The following errors have occured :\n\n"+ txt +"\n     Please Check");
  	  return false
	}
    return true	
}
function ValidSet(frm)
{
	var txt="";
   
    if(!frm.site_title.value)
	{   
	   txt+="     Site Title should not be blank.\n";
	}
	if(!frm.admin_mail.value)
	{
	   txt+="     Admin Email Address should not be blank.\n";
	}
	if(!frm.meta_keys.value) 
	{
	   txt+="     Meta Keys should not be blank.\n";
	}
	if(!frm.meta_desc.value) 
	{
	   txt+="     Meta Description should not be blank.\n";
 	}
	if(txt)
	{
   	  alert("Sorry. The following errors have occured :\n\n"+ txt +"\n     Please Check");
  	  return false
	}
    return true	
}

function ValidCon(frm)
{
    var txt="";
	
	if(!frm.name.value)
	{
		txt+="     Name should not be empty.\n"
	}
	if(!Trim(frm.email.value) || !isEmail(frm.email.value))
	{
	   txt+="     Enter valid Email Address.\n"
       
 	}
	if(!frm.message.value)
	{
		txt+="     You did not put any Description.\n"
	}  
   	if(txt)
	{
   		alert("Sorry. The following errors have occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	
}

function ValidPass(frm)
{
    var txt="";   
    if(!frm.pass.value || frm.pass.value.length<4) 
	{
	   txt+="     Password should not be blank or password less than 4 chars.\n"
	}	
 	if(txt)
	{
   		alert("Sorry. The following errors have occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidCat(frm)
{
    var txt="";   
    if(!frm.cat_name.value) 
	{
	   txt+="     Category Name should not be blank.\n"
	}	
 	if(txt)
	{
   		alert("Sorry. The following errors have occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidSubcat(frm)
{
    var txt="";   
    if(!frm.sub_cat_name.value) 
	{
	   txt+="     Sub Category Name Name should not be blank.\n"
	}	
 	if(txt)
	{
   		alert("Sorry. The following errors have occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidEditor(frm)
{
    var txt="";   
    if(!frm.cont_title.value) 
	{
	   txt+="     Title should not be blank.\n"
	}	
 	if(txt)
	{
   		alert("Sorry. The following errors have occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidFpass(frm)
{
    var txt="";   
	
    if(!Trim(frm.admin_mail.value) || !isEmail(frm.admin_mail.value))
	{
	   txt+="     Enter valid email address\n"
       
 	}
 	if(txt)
	{
   		alert("Sorry. The following errors have occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidAlogin(frm)
{
    var txt="";   
	
    if(!Trim(frm.pass.value))
	{
	   txt+="     Password should not be blank.\n"
       
 	}
 	if(txt)
	{
   		alert("Sorry. The following errors have occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidateEn(frm)
{
    var txt="";   
    if(!Trim(frm.Name.value)) 
	{
	   txt+="     Name should not be blank\n"
	}
	if(!Trim(frm.Email.value) || !isEmail(frm.Email.value))
	{
	   txt+="     Enter valid email address\n"
       
 	}
	if(!Trim(frm.Telephone.value))
	{
	   txt+="     You have not entered Telephone Number\n"
	}
	
	
	if(!Trim(frm.Bedrooms.value)) 
	{
	   txt+="     Minimum Bedrooms should not be blank\n"
	}
	
	if(!Trim(frm.Price.value))
	{   
	   txt+="     Maximum Price should not be blank\n"
	}
	
	
 	if(txt)
	{
   		alert("Sorry. the Following errors have occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidNews ( form ) 
{
	if (form.news_title.value == "") 
	{	
		window.alert('Enter News Title please!');
		form.news_title.focus();
		return false;
	}			
	if (form.short_news.value == "")
	{
		window.alert('Enter Abstract News please!');
		form.short_news.focus();
		return false;
	}			
	
		
			
	return true;
}
function ValidContact(frm)
{
    var txt="";
	
	if(!frm.fname.value)
	{
		txt+="     Please put your first name.\n"
	}
	if(!frm.lname.value)
	{
		txt+="     Please put your last name.\n"
	}	
	
	if(!frm.email.value || !isEmail(frm.email.value))
	{
	   txt+="     Please enter valid email address.\n"
       
 	}
	 
	if(!frm.message.value)
	{
		txt+="     Please enter  message.\n"
	} 
	
	
   	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	
}

var resetRolls = new Object();

function resetimage(src)
{
this.src=src;
this.confirm=true;
this.alt="Reset";
this.write=resetimage_write;
}

function resetimage_write()
{
document.write('<a ');
if (this.rollover)
    {
    if (! this.name)
        {
        alert('to create a rollover you must give the image a name');
        return;
        }

    resetRolls[this.name] = new Object();
    resetRolls[this.name].over = new Image();
    resetRolls[this.name].over.src=this.rollover;
    resetRolls[this.name].out = new Image();
    resetRolls[this.name].out.src=this.src;
    document.write(
        ' onMouseOver="if (document.images)document.images[\'' + 
        this.name + '\'].src=resetRolls[\'' + this.name + '\'].over.src"' + 
        ' onMouseOut="if (document.images)document.images[\'' + 
        this.name + '\'].src=resetRolls[\'' + this.name + '\'].out.src"'
        );
    }
document.write(' HREF="javascript:');
if (this.confirm)
    document.write('if(confirm(\'Are you sure you want to reset?\'))');
document.write(
    'document.forms[' + 
    (document.forms.length - 1) + '].reset();void(0);">');
document.write('<img src="' + this.src + '" alt="' + this.alt + '"');
document.write(' border=0');
if (this.name)document.write(' NAME="' + this.name + '"');
if (this.height)document.write(' HEIGHT=' + this.height);
if (this.width)document.write(' WIDTH=' + this.width);
if (this.otheratts)document.write(' '+ this.otheratts);
document.write('></a>');
}


function ValidateEn2(frm)
{

	var txt="";
	
	if(!frm.Name.value)
	{
		txt+="     Name should not be empty.\n"
		
	}
	if(!frm.Email.value || !isEmail(frm.Email.value))
	{
		txt+="     E-Mail address should not be empty.\n"
		
	}
	if(!frm.Telephone.value)
	{
		txt+="     Phone No. should not be empty.\n"
		
	}
	
	
	

	
	
	if(txt)
	{
		alert("Sorry.  You left out some mandatory fields. :\n\n"+ txt +"\n     Please Check");
		return false
	}
return true	
}

