function noAccept() {
        alert ('To complete your registration, you must agree to the terms of our site.');       
   }
		function noCust() {
document.myaccountform3.custom_college.value = "";
}
function clear_D() {
document.myaccountform3.CollegeID.selectedIndex = 0;
}
		//function to check if item selected from list
function noCustom() {
document.studentcreateeditprofile.custom_college.value = "";
}
function clear_Drop() {
document.studentcreateeditprofile.CollegeID.selectedIndex = 0;
}

      function saverecord(value1,value2) {
        alert ('Save ' + value1 + ' ' + value2);
        
      }
      function deleterecord(value1,value2) {
        alert ('Delete ' + value1 + ' ' + value2);
      }
      
function fnDisableIf(strTest,strObjDisable)
{
	if(strTest!='')
	{
		var x = document.getElementById(strObjDisable)
		if(x){x.disabled=true; x.value='disabled';}
	}
	   else
   {
		var x = document.getElementById(strObjDisable)
		if(x){x.disabled=false; x.value='';}
   }
return;
}
		
function preview() {
		chosen = ""
		len = document.studentcreateeditprofile.ColourSchemeID.length
		
		for (i = 0; i <len; i++) {
			if (document.studentcreateeditprofile.ColourSchemeID[i].checked) {
				chosen = document.studentcreateeditprofile.ColourSchemeID[i].value
			}
		}
		
		window.location = "preview.asp?colour=" + chosen
}

function previewCustomer() {
		chosen = ""
		len = document.customercreateeditcolour.ColourSchemeID.length
		
		for (i = 0; i <len; i++) {
			if (document.customercreateeditcolour.ColourSchemeID[i].checked) {
				chosen = document.customercreateeditcolour.ColourSchemeID[i].value
			}
		}
		
		window.location = "previewCustomer.asp?colour=" + chosen
}

		function OnChange(dropdown)
{
	var myindex  = dropdown.selectedIndex
	var SelValue = dropdown.options[myindex].value
	if (SelValue == 2) {
             document.getElementById("jointTable").style.display = 'block';
	}
   else {
             document.getElementById("jointTable").style.display = 'none';
   }
}
        function runSlideShow1(){
/*
          randomtime=(Math.round((Math.random()*4)+3))*1000
          if (document.all){
            document.images.SlideShow1.style.filter="blendTrans(duration=crossFadeDuration)"
            document.images.SlideShow1.filters.blendTrans.Apply()
          }
          document.images.SlideShow1.src = preLoadImage[j].src
          if (document.all){
            document.images.SlideShow1.filters.blendTrans.Play()
          }
          t = setTimeout('runSlideShow1()', randomtime)
          j = j + 1
          if (j > (p-1)) j=0
*/
        }
        function runSlideShow3(){
/*
          randomtime=(Math.round((Math.random()*4)+3))*1000
          modj=(j+2)%8
          if (document.all){
            document.images.SlideShow3.style.filter="blendTrans(duration=crossFadeDuration)"
            document.images.SlideShow3.filters.blendTrans.Apply()
          }
          document.images.SlideShow3.src = preLoadImage[modj].src
          if (document.all){
            document.images.SlideShow3.filters.blendTrans.Play()
          }
          t = setTimeout('runSlideShow3()', randomtime)
*/
        }
        function runSlideShow5(){
/*
          randomtime=(Math.round((Math.random()*4)+3))*1000
          modj=(j+4)%8
          if (document.all){
            document.images.SlideShow5.style.filter="blendTrans(duration=crossFadeDuration)"
            document.images.SlideShow5.filters.blendTrans.Apply()
          }
          document.images.SlideShow5.src = preLoadImage[modj].src
          if (document.all){
            document.images.SlideShow5.filters.blendTrans.Play()
          }
          t = setTimeout('runSlideShow5()', randomtime)
*/
        }
        function runSlideShow7(){
/*
          randomtime=(Math.round((Math.random()*4)+3))*1000
          modj=(j+6)%8
          if (document.all){
            document.images.SlideShow7.style.filter="blendTrans(duration=crossFadeDuration)"
            document.images.SlideShow7.filters.blendTrans.Apply()
          }
          document.images.SlideShow7.src = preLoadImage[modj].src
          if (document.all){
            document.images.SlideShow7.filters.blendTrans.Play()
          }
          t = setTimeout('runSlideShow7()', randomtime)
*/
        }

var stylesheet = 0
function changestyleSheet(newstylesheet){
    var s = document.styleSheets.length;
    for(i = 0; i < s; i++){
      if(i!=newstylesheet){
        document.styleSheets[i].disabled=true;
      }else{
        document.styleSheets[i].disabled=false;
      }
    }
    stylesheet=(stylesheet+1)%3
}

function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}

function toggleTalkingGem(togglestatus) {
	if(togglestatus==1) //Show
	{
		//document.getElementById('talkinggem').style.visibility = 'visible';
		document.getElementById('talkinggem').style.display = 'block';
	}
	else
	{
		//alert('hide');
		//document.getElementById('talkinggem').style.visibility = 'hidden';
		document.getElementById('talkinggem').style.display = 'none';
	}
}

    theDate= new Date(); 
    var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December'); 
    var day = theDate.getDate(); 
    var textdate = 0; 
    // textdate = day + ' ' + months[theDate.getMonth()] + ' ' + (theDate.getYear() + textdate); 
    textdate = day + ' ' + months[theDate.getMonth()] + ' ' + (theDate.getFullYear()); 
	

function welcomestring(username) {
  var hour = theDate.getHours();
  var welcomestring = '';
  if(hour >= 6 && hour < 12) {
    welcomestring = 'Good morning ' + username;
  }
  else if (hour >= 12 && hour < 18) {
    welcomestring = 'Good afternoon ' + username;
  }
  else if (hour >= 18 && hour < 22) {
    welcomestring = 'Good evening ' + username;
  }
  else if (hour >= 22 || hour < 2) {
    welcomestring = 'Hello ' + username;
  }
  else {
    welcomestring = 'Hello '+username + ', you should be in bed..';
  }
  document.write (welcomestring);
}

function login(username,password,reqpage) {

	if(reqpage == undefined)
	{
		window.location="login.asp?username=" + username + "&password=" + password;
	}
	else
	{
		window.location="login.asp?username=" + username + "&password=" + password + "&ReqPage=" + reqpage;
	}
}

function checkcustomerloggedin(sgsessionid,sgtype) {
  if (sgsessionid.length == 0) {
    if (sgtype != "C") {
      alert ('You must be logged in as a customer to post a new task');
      window.location="login_or_reg.asp";
    }
  }
}

function checklevel2(caller,username,TaskTypeL1ID,milesfrom,postcode,startday,startmonth,startyear,endday,endmonth,endyear,dateposted,CollegeID,CourseAreaID,YearsStudied,CourseLevelID,GradeID) {
  window.location="searchtab"+caller+"b.asp?username="+username+"&TaskTypeL1ID="+TaskTypeL1ID+"&milesfrom="+milesfrom+"&postcode="+postcode+"&startday="+startday+"&startmonth="+startmonth+"&startyear="+startyear+"&endday="+endday+"&endmonth="+endmonth+"&endyear="+endyear+"&dateposted="+dateposted+"&CollegeID="+CollegeID+"&CourseAreaID="+CourseAreaID+"&YearsStudied="+YearsStudied+"&CourseLevelID="+CourseLevelID+"&GradeID="+GradeID
}

function checklevel3(caller,username,TaskTypeL1ID,TaskTypeL2ID,milesfrom,postcode,startday,startmonth,startyear,endday,endmonth,endyear,dateposted,CollegeID,CourseAreaID,YearsStudied,CourseLevelID,GradeID) {
  window.location="searchtab"+caller+"c.asp?username="+username+"&TaskTypeL1ID="+TaskTypeL1ID+"&TaskTypeL2ID="+TaskTypeL2ID+"&milesfrom="+milesfrom+"&postcode="+postcode+"&startday="+startday+"&startmonth="+startmonth+"&startyear="+startyear+"&endday="+endday+"&endmonth="+endmonth+"&endyear="+endyear+"&dateposted="+dateposted+"&CollegeID="+CollegeID+"&CourseAreaID="+CourseAreaID+"&YearsStudied="+YearsStudied+"&CourseLevelID="+CourseLevelID+"&GradeID="+GradeID
}

function checklevel4(caller,username,TaskTypeL1ID,TaskTypeL2ID,TaskTypeL3ID,milesfrom,postcode,startday,startmonth,startyear,endday,endmonth,endyear,dateposted,CollegeID,CourseAreaID,YearsStudied,CourseLevelID,GradeID) {
  window.location="searchtab"+caller+"d.asp?username="+username+"&TaskTypeL1ID="+TaskTypeL1ID+"&TaskTypeL2ID="+TaskTypeL2ID+"&TaskTypeL3ID="+TaskTypeL3ID+"&milesfrom="+milesfrom+"&postcode="+postcode+"&startday="+startday+"&startmonth="+startmonth+"&startyear="+startyear+"&endday="+endday+"&endmonth="+endmonth+"&endyear="+endyear+"&dateposted="+dateposted+"&CollegeID="+CollegeID+"&CourseAreaID="+CourseAreaID+"&YearsStudied="+YearsStudied+"&CourseLevelID="+CourseLevelID+"&GradeID="+GradeID
}

function checklevel5(caller,username,TaskTypeL1ID,TaskTypeL2ID,TaskTypeL3ID,TaskTypeL4ID,milesfrom,postcode,startday,startmonth,startyear,endday,endmonth,endyear,dateposted,CollegeID,CourseAreaID,YearsStudied,CourseLevelID,GradeID) {
  window.location="searchtab"+caller+"e.asp?username="+username+"&TaskTypeL1ID="+TaskTypeL1ID+"&TaskTypeL2ID="+TaskTypeL2ID+"&TaskTypeL3ID="+TaskTypeL3ID+"&TaskTypeL4ID="+TaskTypeL4ID+"&milesfrom="+milesfrom+"&postcode="+postcode+"&startday="+startday+"&startmonth="+startmonth+"&startyear="+startyear+"&endday="+endday+"&endmonth="+endmonth+"&endyear="+endyear+"&dateposted="+dateposted+"&CollegeID="+CollegeID+"&CourseAreaID="+CourseAreaID+"&YearsStudied="+YearsStudied+"&CourseLevelID="+CourseLevelID+"&GradeID="+GradeID
}

function addpicture() {
  addpicture=window.open("addpicture.asp","AddPicture");
}
function addart() {
  addart=window.open("addart.asp","AddArt");
}
function addmusic() {
  addmusic=window.open("addmusic.asp","AddMusic");
}

function profilechecklevel2(TaskTypeL1ID) {
  window.location="studentcreateeditprofile.asp?TaskTypeL1ID="+TaskTypeL1ID+"#skills";
}
function profilechecklevel3(TaskTypeL1ID,TaskTypeL2ID) {
  window.location="studentcreateeditprofile.asp?TaskTypeL1ID="+TaskTypeL1ID+"&TaskTypeL2ID="+TaskTypeL2ID+"#skills";
}
function profilechecklevel4(TaskTypeL1ID,TaskTypeL2ID,TaskTypeL3ID) {
  window.location="studentcreateeditprofile.asp?TaskTypeL1ID="+TaskTypeL1ID+"&TaskTypeL2ID="+TaskTypeL2ID+"&TaskTypeL3ID="+TaskTypeL3ID+"#skills";
}
function profilechecklevel5(TaskTypeL1ID,TaskTypeL2ID,TaskTypeL3ID,TaskTypeL4ID) {
  window.location="studentcreateeditprofile.asp?TaskTypeL1ID="+TaskTypeL1ID+"&TaskTypeL2ID="+TaskTypeL2ID+"&TaskTypeL3ID="+TaskTypeL3ID+"TaskTypeL4ID="+TaskTypeL4ID+"#skills";
}

function showsearchtips() {
  searchtipswindow=window.open("search_tips.asp","SearchTips","width=400,height=300");
  if(!searchtipswindow)
  {
    alert("Please disable your popup blocker to see the tips window");
  }
}



function showprohibitedservices() {
  prohibitedserviceswindow=window.open("prohibited_services.asp","prohibitedservices","width=400,height=300");
  if(!prohibitedserviceswindow)
  {
    alert("Please disable your popup blocker to see the prohibited services window");
  }
}



function filterlist(selectobj) {
  this.selectobj = selectobj;
  // Which parts of the select list do you want to match?
  this.match_text = true;
  this.match_value = false;
  
  this.init = function() {
    // Make a copy of the select list options array
    this.optionscopy = new Array();
    if (this.selectobj && this.selectobj.options) {
      for (var i=0; i < this.selectobj.options.length; i++) {

        // Create a new Option
        this.optionscopy[i] = new Option();

        // Set the text for the Option
        this.optionscopy[i].text = selectobj.options[i].text;

        // Set the value for the Option.
        if (selectobj.options[i].value) {
          this.optionscopy[i].value = selectobj.options[i].value;
        } else {
          this.optionscopy[i].value = selectobj.options[i].text;
        }

      }
    }
  }

  //--------------------------------------------------
  this.reset = function() {
    this.set('');
  }

  //--------------------------------------------------
  this.set = function(pattern) {
    var loop=0, index=0, regexp, e, avaliable=0;
    // Clear the select list so nothing is displayed
    this.selectobj.options.length = 0;

    try {
      // Initialize the regexp
      regexp = new RegExp(pattern, 'i');

    } catch(e) {
      return;
    }
    // Loop through the entire select list and
    // add the matching items to the select list
    for (loop=0; loop < this.optionscopy.length; loop++) {

      // This is the option that we're currently testing
      var option = this.optionscopy[loop];

      // Check if we have a match
      if ((this.match_text && regexp.test(option.text)) ||
          (this.match_value && regexp.test(option.value))) {
		avaliable=1;
        this.selectobj.options[index++] =
          new Option(option.text, option.value, false);
      }
    }
	if (avaliable==0 ) {
	 this.selectobj.options[0] =
	 new Option("Item not found", "", false);
	}
  }
  this.init();
}

function checkKeyPressed(evt , u , p)
{
  evt = (evt) ? evt : (window.event) ? event : null;
  if (evt)
  {
    var charCode = (evt.charCode) ? evt.charCode :
                   ((evt.keyCode) ? evt.keyCode :
                   ((evt.which) ? evt.which : 0));
    if (charCode == 13) login(u,p);
  }    
}

function fnDisableIf(strTest,strObjDisable)
{
	if(strTest!='')
	{
		var x = document.getElementById(strObjDisable)
		if(x){x.disabled=true; x.value='disabled';}
	}
	   else
   {
		var x = document.getElementById(strObjDisable)
		if(x){x.disabled=false; x.value='';}
   }
return;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
