// JavaScript Document

/******************************************/
/*       IWEB JAVASCRIPT POLICY           */
/******************************************/
/*It is reccomended that JavaScript only be used sparingly to enhance usability 
and ONLY if it does not affect core functionality!
Regularly test the website with JavaScript disabled to make sure that it is stil functional
Use attributes.add for ASP.NET form controls in order to add JavaScript function calls to the rendered page*/

/******************************************/
/******************************************/
/*This is temporarily hard wired until a VB ImageRandomiser() exists*/
function GetRandomHomePageImage(){
images = new Array(5);
alt = 'The appropriate textual equivelant of this image is missing'

images[0]="<img align='left' src='images/banner.jpg' alt='Quality Operations Live - Effective Management, Better Control' width='588' height='192' border='0' />";

images[1]="<img align='left' src='images/banner2.jpg' alt='Innovate' title='Innovate - Cost effective tool that has significantly improved the delivery of innovation' width='588' height='192' border='0' />";

images[2] = "<img src='images/banner3.jpg' alt='Tials Costing Framework' title=''Tials Costing Framework - Unraveling the complication of costing and managing research trials' width='588' height='192' border='0' />";

images[3] = "<img src='images/banner4.jpg' alt='Finance and Resource Management for Departments' title='Finance and Resource Management for Departments - Management tool developed in collaboration with the NHS for the NHS' width='588' height='192' border='0' />";

images[4] = "<a href='act_by_sage.asp' title='ACT! CRM by SAGE - Powerful Contact & Customer Management for your business'><img src='images/banner5.jpg' alt='ACT! CRM by SAGE' title='ACT! CRM by SAGE - Powerful Contact & Customer Management for your business' width='588' height='192' border='0' /></a>";
/*
images[4] = "<img src='images/SSHAFrontPageImages/corsers_court_exterior.jpg' alt='Coursers Court Sheltered Scheme' title='Coursers Court Sheltered Scheme' />";

images[5] = "<img src='images/SSHAFrontPageImages/DLO_cat_team_with_paint.jpg' alt='Two members of our Communal Areas Team with tins of paint' title='Two members of our Communal Areas Team with tins of paint' />";

images[6] = "<img src='images/SSHAFrontPageImages/essington_development.jpg' alt='Essigngton development' title='Essigngton development' />";

images[7] = "<img src='images/SSHAFrontPageImages/family_with_new_house.jpg' alt='Family pictured with their new house' title='Family pictured with their new house' />";

images[8] = "<img src='images/SSHAFrontPageImages/girl_with_balloon.jpg' alt='Girl with baloon' title='Girl with balloon' />";

images[9] = "<img src='images/SSHAFrontPageImages/huntington_kitchen.jpg' alt='Tenant in Huntington with new kitchen' title='Tenant in Huntington with new kitchen' />";

images[10] = "<img src='images/SSHAFrontPageImages/moving_in.jpg' alt='Tenants moving in' title='Tenants moving in' />";

images[11] = "<img src='images/SSHAFrontPageImages/property_care_employee.jpg' alt='Property Care employee pictured with van' title='Property Care employee pictured with van' />";

images[12] = "<img src='images/SSHAFrontPageImages/property_care_employee_with_tenant.jpg' alt='Property Care employee pictured with tenant' title='Property Care employee pictured with tenant' />";

images[13] = "<img src='images/SSHAFrontPageImages/property_care_employees.jpg' alt='Property Care employees pictured with van' title='Property Care employees pictured with van' />";

images[14] = "<img src='images/SSHAFrontPageImages/road_show_face_painting.jpg' alt='Girl with her face pained at SSHA roadshow' title='Girl with her face pained at SSHA roadshow' />";

images[15] = "<img src='images/SSHAFrontPageImages/tenant_from_bilbrook.jpg' alt='Tenants from Bilbrook' title='Tenants from Bilbrook' />";

images[16] = "<img src='images/SSHAFrontPageImages/tenant_gardening.jpg' alt='Tenant gardening' title='Tenant gardening' />";

images[17] = "<img src='images/SSHAFrontPageImages/tenant_support_cup_of_tea.jpg' alt='Tenant support employee pictured with elderly customer' title='Tenant support employee pictured with elderly customer' />";

images[18] = "<img src='images/SSHAFrontPageImages/tenant_with_dogs.jpg' alt='Tenant with dogs' title='Tenant with dogs' />";

images[19] = "<img src='images/SSHAFrontPageImages/tenants_from_billbrook.jpg' alt='Tenants from Billbrook' title='Tenants from Billbrook' />";

images[20] = "<img src='images/SSHAFrontPageImages/tenants_from_codsall.jpg' alt='Tenants from Codsall' title='Tenants from Codsall' />";

images[21] = "<img src='images/SSHAFrontPageImages/tenants_from_shareshill.jpg' alt='Tenants from Shareshill' title='Tenants from Shareshill' />";

images[22] = "<img src='images/SSHAFrontPageImages/tenants_from_wombourne.jpg' alt='Tenants from Wombourne' title='Tenants from Wombourne' />";

images[23] = "<img src='images/SSHAFrontPageImages/tenants_gardening.jpg' alt='Tenants gardening' title='Tenants gardening' />";

images[24] = "<img src='images/SSHAFrontPageImages/tenants_gardening_old_school_court.jpg' alt='Tenants gardening at Old School Court' title='Tenants gardening at Old School Court' />";

images[25] = "<img src='images/SSHAFrontPageImages/tenants_with_grand_children_huntington.jpg' alt='Tenants in Huntington pictured with grandchildren' title='Tenants in Huntington pictured with grandchildren' />";

images[26] = "<img src='images/SSHAFrontPageImages/tenants_with_grandchild_codsall.jpg' alt='Tenants in Codsall pictured with granddaughter' title='Tenants in Codsall pictured with granddaughter' />";
*/


index = Math.floor(Math.random() * images.length);
document.write(images[index]);
//document.write(images[0]);
//document.write ('test');
}

/******************************************/
/*        SEARCH FIELD MIN VALUE          */
/******************************************/
function SearchMinCharLen()
{
if (getElementById("txtSearch").value.length < 4)
{
alert("Enter 3 or more characters")
}
}

/******************************************/
/*     SET SEARCH FIELD TO DEFAULT        */
/******************************************/
//Call on JavaScript page load - set the default form value
function DefaultFormFields()
{
txtSearchDefault="Enter search term"
document.getElementById("txtSearch").value=txtSearchDefault
}

/******************************************/
/*          CLEAR SEARCH FIELD            */
/******************************************/
//Called on click  - only clear the field if it is equal to the default value
function CleartxtSearch()
{
if (document.getElementById("txtSearch") .value==txtSearchDefault)
{document.getElementById("txtSearch").value="";}
}

/******************************************/
/*          RESET SEARCH FIELD            */
/******************************************/
//Called on blur - only reset the fields if they are empty
function ResettxtSearch()
{
if (document.getElementById("txtSearch").value=="")
{document.getElementById("txtSearch").value=txtSearchDefault;}
}

/******************************************/
/*             GET FOCUS                  */
/******************************************/
/*Declare a variable which holds the name of the element that has focus, 
and then monitor it using onFocus() and onBlur() event handlers to keep the variable updated.
var FocusedObjName
/*Get the name of the object now in focus by calling onfocus="GetFocusName(this.name)" */
function GetFocusName(MyName)
{
FocusedObjName=MyName
/*alert("The name of the object now in focus is: " + FocusedObjName)*/
}

/******************************************/
/*            CLEAR FOCUS                 */
/******************************************/
/*Clear the FocusedObjName global variable by calling onBlur="ClearFocus()" */
function ClearFocus()
{
FocusedObjName=""
}

/******************************************/
/*       SEARCH IF ENTER PRESSED          */
/******************************************/
/*If enter key is pressed and focused object is txtSearch or btn, put focus on the Search button*/
function CheckKey() {
if (event.keyCode == 13 && FocusedObjName == 'txtSearch' || event.keyCode == 13 && FocusedObjName == 'btnSearch') {
	document.getElementById("btnSearch").focus();
}
}

function FocusOnSearch()
{
document.getElementById("txtSearch").focus();
}

/******************************************/
/*           SIMPLE ROLLOVERS             */
/******************************************/
function KASwapFunc(KAImageVariable, KASourceVariable)

{
var KAobjectString,KAobj;
if(document.images)
{

KAobjectString = 'document.' + KAImageVariable;
KAobj = eval(KAobjectString);
KAobj.src = KASourceVariable;

}
}

