function GoSearch()
	{
		if(document.searchform.w.value.substr(0,5) == ' By k')
		{
			alert('You have not entered any search criteria, please enter your description and try again');
			return false;
		}
		else
		{
			return true;
		}
	}

function openWin(URL,aName,wName,Scroll,W,H,T,L)
	{
		window.name = aName
		aWindow = window.open(URL,wName,"toolbar=no,location=no,directories=no,status=no,,scrollbars="+ Scroll +",width="+ W +",height="+ H +",top="+ T +",left="+ L +",resizable=no,menubar=no");
	}
function fullScreen(URL,aName,wName,W,H)
	{
		window.name = aName
		aWindow = window.open(URL,wName,"toolbar=yes,location=no,directories=no,status=no,,scrollbars=yes,width=1024,height=768,top=10,left=10,resizable=yes,menubar=yes");
	}

function LaunchPage(d,flg,action)
	{
		document.PageGo.action=action;
		document.PageGo.d.value=d;
		document.PageGo.Flg.value=flg;
		document.PageGo.submit();
	}

function menuOverA(menuNumber)
	{
	var menunme1;
	var menunme2;
	var menunme3;
	var menunme4;

	menunme1 = 'menuA' + menuNumber;
	menunme2 = 'menuB' + menuNumber;
	menunme3 = 'menuC' + menuNumber;
	menunme4 = 'menuD' + menuNumber;


	window.activeMenuItem = document.getElementById(menunme1);
	window.activeMenuItem.className = 'menuhigh';

	window.activeMenuItem = document.getElementById(menunme2);
	window.activeMenuItem.className = 'menuhigh';

	window.activeMenuItem = document.getElementById(menunme3);
	window.activeMenuItem.className = 'menuhigh';

	window.activeMenuItem = document.getElementById(menunme4);
	window.activeMenuItem.className = 'menuhigh';
	window.activeMenuItem.src = '/images/arrow_white.gif';
	}
	
function menuOutA(menuNumber)
	{
	var menunme1;
	var menunme2;
	var menunme3;
	var menunme4;

	menunme1 = 'menuA' + menuNumber;
	menunme2 = 'menuB' + menuNumber;
	menunme3 = 'menuC' + menuNumber;
	menunme4 = 'menuD' + menuNumber;


	window.activeMenuItem = document.getElementById(menunme1);
	window.activeMenuItem.className = 'catstxt';

	window.activeMenuItem = document.getElementById(menunme2);
	window.activeMenuItem.className = 'catstxt';

	window.activeMenuItem = document.getElementById(menunme3);
	window.activeMenuItem.className = 'catstxt';

	window.activeMenuItem = document.getElementById(menunme4);
	window.activeMenuItem.className = 'catstxt';
	window.activeMenuItem.src = '/images/trans.gif';
}
	
function BFPOCustomer(ID,url)
	{
	document.submitdetails.bfpo.value=ID;
	
	switch (ID)
	{
		case "b" :
		document.submitdetails.action=url+'/login.asp';
		break;
		
		case "n" :
		document.submitdetails.action=url+'/postcodenotknown.asp';
		break;
		
		case "y" :
		break;
		
		default:
		document.submitdetails.action=url+'/login.asp';
		break;
	}
	
	document.submitdetails.submit();
}
	
function GoClear(ID)
	{
	document.submitdetails.CL.value=ID;
	document.submitdetails.submit();
	}
function GoClearMail()
	{
	document.formApply.QAS.value = '';
	document.formApply.CL.value='All';
	document.formApply.submit();
	}
function GoCP(ID)
	{
	document.submitdetails.page.value=ID;
	document.submitdetails.submit();
	}
function GoCPAY(ID)
	{
	document.submitdetails.action='/redirect_customerprofiles.asp'
	document.submitdetails.page.value=ID;
	document.submitdetails.submit();
	}
function GoCPAction(ID)
	{
	document.submitdetails.action=ID;
	document.submitdetails.submit();

	}
function GoCPClEmail(ID)
	{
	document.submitdetails.email.value='';
	document.submitdetails.action=ID;
	document.submitdetails.submit();
	}
function GoForm()
	{
	document.submitdetails.submit();
	}
function GoUpDateAction(ID)
	{
	document.submitdetails.updateaction.value=ID;
	document.submitdetails.action='/redirect_navigate.asp';
	document.submitdetails.submit();
	}
function GoPrint()
	{
	parent.MainText.focus();
	parent.MainText.print();
	}
function GoCPUpdate(ID)
	{
	//document.submitdetails.action='/redirect_mpi.asp';
	document.submitdetails.update.value=ID;
	document.submitdetails.submit();
	}
function GoCPPAY(ID)
	{
	document.submitdetails.action='/redirect_payment.asp';
	document.submitdetails.update.value=ID;
	document.submitdetails.submit();
	}
function GoDirCom(ID)
	{
	switch (ID)
	{
		case "accept" :
			document.submitdetails.action='banner_directory.asp';
			break;
		case "change" :
			document.submitdetails.action='directory.asp';
			break;
	}
	document.submitdetails.submit();
	}

function GoAddress(ID)
	{
		window.name = "QAS";
		aWindow = window.open("/test/popup.asp","QASWin","toolbar=no,location=no,directories=no,status=no,,scrollbars=NO,width=552,height=430,top=10,left=10,resizable=no,menubar=no");
	}
function GoSubmit(id,action)
{
	switch (id)
	{
		case "postcode" :
			document.submitdetails.postcode.value = action;
			break;
		case "nopostcode" :
			document.submitdetails.postcode.value = '';
			document.submitdetails.nopostcode.value = action;
			break;
		case "nosearch" :
			document.submitdetails.nopostcode.value = '';
			document.submitdetails.nosearch.value = action;
			break;
		case "clearpl" :
			document.submitdetails.nosearch.value = '';
			document.submitdetails.select.value = '';
			document.submitdetails.searchPostcode.value = action;
			break;
		case "All" :
			document.submitdetails.postcode.value = '';
			document.submitdetails.nopostcode.value = '';
			document.submitdetails.nosearch.value = '';
			document.submitdetails.select.value = '';
			document.submitdetails.searchPostcode.value = action;
			document.submitdetails.CL.value=id;		
	}
	document.submitdetails.submit();
}
function chghdr(location)
{
document.getElementById('Womenswear').className='navbar';
document.getElementById('Menswear').className='navbar';
document.getElementById('Childrenswear').className='navbar';
document.getElementById('Homeware').className='navbar';
document.getElementById('qs').className='navbar';
document.getElementById('ya').className='navbar';

document.getElementById('Womenswear1').className='navbarli';
document.getElementById('Menswear1').className='navbarli';
document.getElementById('Childrenswear1').className='navbarli';
document.getElementById('Homeware1').className='navbarli';
document.getElementById('qs1').className='navbarli';
document.getElementById('ya1').className='navbarli';

document.getElementById(location).className='navbar rollover';
document.getElementById(location+1).className='navbarli lirollover';

}

function chgdirhdr(location)
{
document.getElementById('Womenswear').className='navbar';
document.getElementById('Menswear').className='navbar';
document.getElementById('Childrenswear').className='navbar';
document.getElementById('Homeware').className='navbar';
document.getElementById('Corporate').className='navbar';
document.getElementById('Stores').className='navbar';

document.getElementById('Womenswear1').className='navbarli';
document.getElementById('Menswear1').className='navbarli';
document.getElementById('Childrenswear1').className='navbarli';
document.getElementById('Homeware1').className='navbarli';
document.getElementById('Corporate1').className='navbarli';
document.getElementById('Stores1').className='navbarli';

document.getElementById(location).className='navbar rollover';
document.getElementById(location + '1').className='navbarli lirollover';

}

function chgpreviewhdr(location)
{
/*document.getElementById('Womenswear').className='navbar';
document.getElementById('Menswear').className='navbar';
document.getElementById('Childrenswear').className='navbar';
document.getElementById('Homeware').className='navbar';

document.getElementById('Womenswear1').className='navbarli';
document.getElementById('Menswear1').className='navbarli';
document.getElementById('Childrenswear1').className='navbarli';
document.getElementById('Homeware1').className='navbarli';

document.getElementById(location).className='navbar rollover';
document.getElementById(location + '1').className='navbarli lirollover';*/

}
function chgpresshdr(location)
{
document.getElementById('Womenswear').className='navbar';
document.getElementById('Menswear').className='navbar';
document.getElementById('Childrenswear').className='navbar';
document.getElementById('Homeware').className='navbar';

document.getElementById('Womenswear1').className='navbarli';
document.getElementById('Menswear1').className='navbarli';
document.getElementById('Childrenswear1').className='navbarli';
document.getElementById('Homeware1').className='navbarli';

document.getElementById(location).className='navbar rollover';
document.getElementById(location + '1').className='navbarli lirollover';

}

function QASTryAgain()
{
document.formApply.PLSelected.value='';
document.formApply.Postcode.value='';
document.formApply.QAS.value='';
document.formApply.submit();
}

function QASCompleteCL()
{
document.formApply.QAS.value='';
document.formApply.submit();
}

function QASNoPostCode()
{
document.formApply.Postcode.value='';
document.formApply.QAS.value='2';
document.formApply.submit();
}

function QASFullAddress()
{
document.formApply.QAS.value='4';
document.formApply.submit();
}
function newsletterStatus(message) {
	switch (message) {
		case "invalid":
			alert('The email address entered is incomplete or invalid. \nPlease re-enter your email address to receive updates from the Next Directory.');
		break;
		case "exists":
			alert('The email address entered is already in our database and \nwill automatically receive updates from the Next Directory.');
		break;
		case "sent":
			alert('Your email address has been added to our mailing list.\nAn email will be sent to your address confirming these details.\nNext Group plc will not share your information with companies outside of the group for marketing purposes.');
		break;
	}
}

function openNewWindow(myURL, target) {
	  window.open(myURL, "_self");
}

function getURLParam(strParamName) {
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ) {
	var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
	var aQueryString = strQueryString.split("&");
	for ( var iParam = 0; iParam < aQueryString.length; iParam++ ) {
	  if (
		aQueryString[iParam].indexOf(strParamName + "=") > -1 ) {
		var aParam = aQueryString[iParam].split("=");
		strReturn = aParam[1];
		break;
	  }
	}
  }
  return strReturn;
}
function _getSource(e) {
	
	if (typeof e == 'undefined') {
		e = window.event;
	}
	var source;
	if (typeof e.target != 'undefined') {
		if (e.target.nodeType == 3) {
			source = e.target.parentNode; }
		else {
			source = e.target;}
	}
	else if (typeof e.srcElement != 'undefined') {
		source = e.srcElement;
	}
	else {
		return null;
	}
	return source;
}

function addEvent(obj, evType, fn){
	if (obj && obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	}
	else if (obj && obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else {
		return false;
	}
}

function _cancelEvent(e)  {
	if (e) {
		e.cancelBubble = true;
		if(e.preventDefault) {
			e.preventDefault();
		} else {
			e.returnValue = false;
		}
	}
	
}

function openNewWin(URL,aName,wName,Scroll,W,H,T,L){
	newWin = window.open(URL,null,"height=" + H + ",width=" + W + ",left=" + L + ",top=" + T + ",scrollbars=" + Scroll + ",directories=0,menubar=0,status=0,toolbar=0");
	if(window.focus){newWin.focus();}
	}

function openHelpWin(e) {
	var source = _getSource(e);
	if (source) {
		var href = source.href;
		if (href) {
			var result = openNewWin(href, 'help', 'help', '1', 700, 397, 10, 10);
			_cancelEvent(e);
			return false;
		}
	}
}
function openShotWin(e) {
	var source = _getSource(e);
	if (source) {
		var href = source.href;
		if (href) {
			var result = openNewWin(href, 'feature', 'feature', '1', 720, 516, 15, 15);
			_cancelEvent(e);
			return false;
		}
	}
}

function submitbag(e){
	var source = _getSource(e);
	if (source) {
		source.form.target='MainWindow';
		if (window.name == 'shotview'){
			setTimeout('window.close()',100)
		}
		if (window.name == 'feature'){
			if (parent.opener){
			parent.opener.close()}
			setTimeout('window.close()',100)
		}
	}
}

function init() {
	var aNodes = document.getElementsByTagName("a");
	var bNodes = document.getElementsByTagName("button");
	if (aNodes) {
		var aNode
		for (var i = 0; (aNode = aNodes[i]); i++) {
			if (aNode.className.indexOf('new-win') >= 0) {
				addEvent(aNode, 'click', openHelpWin);
			}
			if (aNode.className.indexOf('new-shot') >= 0) {
				addEvent(aNode, 'click', openShotWin);
			}
		}
	}
	if (bNodes) {
		var bNode
		for (var z = 0; (bNode = bNodes[z]); z++) {
			if (bNode.className.indexOf('close-win') >= 0) {	
				addEvent(bNode, 'click', submitbag);
			}
		}
	}
	
}

addEvent(window, 'load', init);


function openWin(URL,aName,wName,Scroll,W,H,T,L)
	{
		window.name = aName;
		aWindow = window.open(URL,wName,"toolbar=no,location=no,directories=no,status=no,,scrollbars="+ Scroll +",width="+ W +",height="+ H +",top="+ T +",left="+ L +",resizable=no,menubar=no");
	}
	


//Declare and init vars
var defaultSearchText = "Search the Next Directory";

//Clear the search input control when it recieves focus
function onFocus_SearchBox(obj) {
    //Declare and init vars
    var strVar = obj.value;

    if (strVar.toLowerCase() == defaultSearchText.toLowerCase())
        obj.value = "";

}

//Re-instate the default text in the search input control if nothing has been entered when it loses focus
function onBlur_SearchBox(obj) {
    //Declare and init vars
    var strVar = obj.value;

    if (strVar.replace(/^\s+|\s+$/g, '') == "")
        obj.value = defaultSearchText;

}

//Footer Flag Image Change On Select
function flagval() {
if(document.images)
{
build = new Array()
for(i=0;i<17;i++)
	{
	build[i] = new Image()
	build[i].src = "../SECURE/images/flags/flag" + i + ".gif" 
	}
}
{
if(document.images)
	{
	buildval=document.countries.flag.options[document.countries.flag.selectedIndex].value
	document.flagswitch.src = "../SECURE/images/flags/flag"+buildval+".gif"
	}
}
window.onerror = null;
}

// Used To Create Uppercase Text In Input Fields
function upperCase()
{
	var x=document.getElementById("accountno").value;
	document.getElementById("accountno").value=x.toUpperCase();
}

// Used To pass LID value
function passLID() 
{
	var url = location.hash;
	
	if (url != '')
	{
		document.CustomerProfiles.action = document.CustomerProfiles.action + url;
		document.CustomerProfiles.submit();
	}
	else
	{
		document.CustomerProfiles.submit();
	}
}
