// date stuff used in cached pages
dayofweek= new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
dayofmonth= new Array("","1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st");
months= new Array("January","February","March","April","May","June","July","August","September","October","November","December");

// returns todays date as a formated string
function theDate(){
	var mydate=new Date();
	var year=mydate.getYear();
	if (year < 1000) year+=1900;
	var day=mydate.getDay();
	var month=mydate.getMonth();
	var daym=mydate.getDate();
	todaysDate="  "+dayofweek[day]+" "+dayofmonth[daym]+" "+months[month]+" "+year;
	return todaysDate;
}

//for opening video window
var newwindow;

function newvideo(url)
{
	newwindow=window.open(url,'videowindow','status=no,width=575,height=480');
	if (window.focus) {newwindow.focus()}
}

// returns todays date as a formated string
function theYear(){
	var mydate=new Date();
	var year=mydate.getYear();
	if (year < 1000) year+=1900;
	return year;
}
// Search box validation used for both the search box and the main search page
function searchpagevalidate(ref)
{
	var space_re = new RegExp('\\s+');
	var isEmpty = (ref.keyword.value.replace(space_re, '') == '') ? 1 : 0;
	if (!isEmpty)
		{
		return true;
		}
	else
		{
		alert('Need a keyword to \nsearch on!');
		return false;
		}		
}
function gotoarticle(sel)
	{
		artID=sel.options[sel.selectedIndex].value;
		if (artID.length > 0){
			aURL="index.aspx?articleid="+artID;
			window.location.href = aURL;
		}
	}
	
//scripts used in the forum template
// check all fields have been entered.
function  _forum_checkThreadForm(_forum_this){
    if  (_forum_this.forum_topic.value.length ==0){
		alert("You must enter a Title.");
		return false;
	}
    if  (_forum_this.forum_username.value.length ==0){
		alert("You must enter your name to post to the forum.");
		return false;
	}
    if  (_forum_this.forum_body.value.length ==0){
		alert("In order to post you need to enter text into the message.");
		return false;
	}
	return true;
} 
//variables and functions used in the calendar template
var Days_in_Month = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
function monthchange(sel){
	mnth=sel.options[sel.selectedIndex].value;
	aform=sel.form;
	if(aform.aday != null){
		if (mnth =='2'){
			theYear=aform.ayear.options[aform.ayear.selectedIndex].value;
			Days_in_Month[1] = ((theYear % 400 == 0) || ((theYear % 4 == 0) && (theYear % 100 !=0))) ? 29 : 28;
		}
		for(i=27; i < Days_in_Month[mnth-1]; i++){
			aform.aday.options[i].text=i+1;
		}
		for(i=Days_in_Month[mnth-1]; i < 31; i++){
			aform.aday.options[i].text='';
		}
		checkday(aform);
	}
	changer(sel);	
}

function checkday(aform){
	if (aform.aday.options[aform.aday.selectedIndex].text==''){
		aform.aday.options[eval(Days_in_Month[aform.amonth.selectedIndex]-1)].selected=true;
		aform.aday.focus();
	}
}

function changer(sel)
{
	aform=sel.form;
	dy=(aform.aday != null)?aform.aday.options[aform.aday.selectedIndex].value:1;
	mnth=aform.amonth.options[aform.amonth.selectedIndex].value;
	yer=aform.ayear.options[aform.ayear.selectedIndex].value;
	aid=aform.articleid.value;
	aURL="index.aspx?articleid="+aid+"&ayear="+yer+"&amonth="+mnth+"&aday="+dy;
	window.location.href = aURL;
}

function PopulatePropertyForm()
    {
      
      n = 0;
      str = window.location;
      referenceid = "";
      
     
      if (n > String(str).length)
          referenceid = str;
      else
        {
          var iLen = String(str).length;
          referenceid = String(str).substring(iLen, iLen - n);
        }



        document.getElementById("PROPERTYHELPDESKSURVEY_REFERENCENUMBER").value = referenceid;
	

    }

    function querySt(ji) {
        hu = window.location.search.substring(1);
        gy = hu.split("&");
        for (i = 0; i < gy.length; i++) {
            ft = gy[i].split("=");
            if (ft[0] == ji) {
                return ft[1];
            }
        }
    }

// automatic print function
// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header

function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}
//used by video player
function resize()
	{
 	 var wide = window.screen.availWidth
  	var high = window.screen.availHeight
  	var maxh = 600 // your max height here; enter 0 if not used
  	var maxw = 600 // your max width here; enter 0 if not used
  	var content = document.getElementById('content')
  	content.style.position = 'absolute'
  	if(maxh > 0 && high <= maxh)
  	{
  	content.style.height = high
  	}
  	if(maxw > 0 && wide <= maxw)
  	{
  	content.style.height = high
  	}
  	if(maxh > 0 && high > maxh)
  	{
  	content.style.height = maxh
  	high = (high - maxh) / 2
  	content.style.top = high
  	}
  	if(maxw > 0 && wide > maxw)
  	{
  	content.style.width = maxw
  	wide = (wide - maxw) / 2
  	content.style.left = wide
 	 }
  	// Do not remove line below
  	content.innerHTML = content.innerHTML + "<p style='position:absolute;top:95%;width:40%;left:30%;'>provided by: <a href='http://ls-design.forthelads.net'>liveing_sacrifice</a></p>"
	}
	//-->
