﻿function CheckTen(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 11)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckFifteen(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 16)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckTwenty(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 21)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckThirty(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 31)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckFifty(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 51)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckHundred(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 101)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckOneHundredFifty(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 151)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckTwoHundred(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 201)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckFiveHundred(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 501)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckThousand(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 1001)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function Check2Thousand(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 2001)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckTwoFifty(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 2501)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckFiveThousand(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 5001)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function CheckTenThousand(oSrc, args)
{
	//alert(args.Value.length);
	if (args.Value.length >= 10001)
	{
		args.IsValid = false;
	}
	else
	{
		args.IsValid = true;
	}
}

function Display(DivID)
    {
    id = DivID;
	if (document.getElementById)
        {
        if(document.getElementById(id).style.display == "block")
            {
            document.getElementById(id).style.display = "none";
            }
        else
            {
            document.getElementById(id).style.display = "block";
            }
        }
	}


function HideShowRecommendations(outletID)
    {
    id = "btnOutletID" + outletID;
    if(document.getElementById(id).style.display == "block")
        {
        document.getElementById(id).style.display = "none";
        }
    else
        {
        document.getElementById(id).style.display = "block";
        }
    }
    
    
function ValidateAddressContinue(oSrc, args)
    {
    var str1 = document.getElementById("ctl00_ContentPlaceHolder1_ucCreateUserProfile21_txtHouseNo").value
    //var str2 = document.getElementById("ctl00_ContentPlaceHolder1_ucCreateUserProfile21_txtStreet").value
    var str3 = document.getElementById("ctl00_ContentPlaceHolder1_ucCreateUserProfile21_txtTown").value
    var str4 = document.getElementById("ctl00_ContentPlaceHolder1_ucCreateUserProfile21_txtPostcode").value
    var str5 = document.getElementById("ctl00_ContentPlaceHolder1_ucCreateUserProfile21_txtAddressLabel").value


    var int1 = str1.length
    //var int2 = str2.length
    var int3 = str3.length
    var int4 = str4.length
    var int5 = str5.length
    
    if (int1 == 0 && int3 == 0 && int4 == 0 && int5 == 0)
        {
        args.IsValid =  true
        return true;
        }
    else if (int1 > 0 && int3 > 0 && int4 > 0 && int5 > 0)
        {
        args.IsValid =  true
        return true;
        }
    else
        {        
        if (int1 == 0){document.getElementById("ctl00_ContentPlaceHolder1_ucCreateUserProfile21_RequiredFieldValidator5").style.display = "block";}
        //if (int2 == 0){document.getElementById("ctl00_ContentPlaceHolder1_ucCreateUserProfile21_RequiredFieldValidator1").style.display = "block";}
        if (int3 == 0){document.getElementById("ctl00_ContentPlaceHolder1_ucCreateUserProfile21_RequiredFieldValidator2").style.display = "block";}
        if (int4 == 0){document.getElementById("ctl00_ContentPlaceHolder1_ucCreateUserProfile21_RequiredFieldValidator4").style.display = "block";}
        if (int5 == 0){document.getElementById("ctl00_ContentPlaceHolder1_ucCreateUserProfile21_RequiredFieldValidator3").style.display = "block";}
        //document.getElementById("ctl00_ContentPlaceHolder1_ucCreateUserProfile21_cmdClearForm").style.display = "block"
        args.IsValid =  false
        return false;
        }
    return true;
    }
    
function backColourOn(el){
    Element.addClassName(el.parentNode, 'over');
}

function backColourOff(el){
    Element.removeClassName(el.parentNode, 'over');
}


//function clearQuantity(el){
//    var textbox = document.getElementById(el);
//    //pause(3000);  
//    textbox.value = "";
//}

// function pause(numberMillis){
//    
//    var now = new Date();
//    var exitTime = now.getTime() + numberMillis;
//    while (true)
//        {
//            now = new Date();
//            if (now.getTime() > exitTime)
//            return;
//        }
//} 

//<!-- More javascripts http:www.hypergurl.com -->
// Original by http://javascript.internet.com --> 

var NS4 = (document.layers);    // Which browser?
var IE4 = (document.all);
var FF2 = (document.getElementById);


var win = window;    // window to search.
var n   = 0;

function findInPage(str) {

  var txt, i, found;

  if (str == "")
    return false;

  // Find next occurance of the given string on the page, wrap around to the
  // start of the page if necessary.

  if (NS4 || navigator.appName == "Netscape") {
    // Look for match starting at the current point. If not found, rewind
    // back to the first match.

    if (!win.find(str))
      while(win.find(str, false, true))
        n++;
    else
      n++;

    // If not found in either direction, give message.

    if (n == 0)
      alert("Not found.");
  }

  if (IE4) {
    txt = win.document.body.createTextRange();

    // Find the nth match from the top of the page.

    for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
      txt.moveStart("character", 1);
      txt.moveEnd("textedit");
    }

    // If found, mark it and scroll it into view.

    if (found) {
      txt.moveStart("character", -1);
      txt.findText(str);
      txt.select();
      txt.scrollIntoView();
      n++;
    }

    // Otherwise, start over at the top of the page and find first match.

    else {
      if (n > 0) {
        n = 0;
        findInPage(str);
      }

      // Not found anywhere, give message.

      else
        alert("Not found.");
    }
  }

  return false;
}
