/*********************
	NavRollOver()
	Rollover function for the navigation.
*********************/
function NavRollOver(navId,navState){
	if(navState=='Over'){
		document.getElementById('div' + navId).className='NavigationOn';
		document.getElementById('hyp' + navId).className='NavigationOn';
	}else{
		document.getElementById('div' + navId).className='Navigation';
		document.getElementById('hyp' + navId).className='Navigation';
	}
}

/*********************
	NavHyperLink()
	Javascript link that works for all browser clients.
*********************/
function NavHyperLink(navId){
	var navURL = document.getElementById('hyp' + navId).href;
	
	window.location.href=navURL;
	window.navigate(navURL);
}

/*********************
	WinResize()
	Resize the popup window to fit the image being displayed
*********************/
function WinResize(){
	self.resizeTo(document.images['imgGallery'].width + 40, document.images['imgGallery'].height + 150)
}

/*********************
	Confirm Delete()
	Confirm if user wants to delete item
*********************/
function ConDelete(URL){
	if(confirm('Delete Item?')){
		window.location.href=URL;
		window.navigate(URL);
	}
}

/*********************
	Confirm Send()
	Send Newsletter
*********************/
function ConSend(){
	if(confirm('Once newsletter is sent it cannot be edited. Do you wish to continue')){
		return true;
	}else{
		return false;
	}
}

/*********************
	Confirm Delete()
	Confirm if user wants to delete item
*********************/
function NewsletterPopup(URL){
	window.open(URL,'NewsletterView', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=650,height=550')
}

/*********************
	Change Form()
	Set the for url for Securetrading
*********************/
/*function ChangeForm(idForm){
	document.getElementById(idForm).action = 'https://securetrading.net/authorize/form.cgi';
	document.getElementById(idForm).submit();
}
function SendForm(idForm){
	document.getElementById(idForm).action = 'https://www.nochex.com/nochex.dll/checkout';
	document.getElementById(idForm).submit();
}*/
function ChangeForm(idForm){
	document.getElementById(idForm).action = 'https://select.worldpay.com/wcc/purchase';
	document.getElementById(idForm).submit();
}

function SendForm(idForm){
	document.getElementById(idForm).action = 'https://select.worldpay.com/wcc/purchase';
	document.getElementById(idForm).submit();
}

//////////////////////////////////////////////////////////////////////////////////////
// Name			: OpenWindow														//
// Description	: Create a popup window without all the fancy trimmings.			//
// Parameters	:-																	//
//	        URL : URL of page to display in popup.									//
// Author		: Brett Schumann (brett@nakedvision.co.uk)							//
// Date			: 20 / 02 / 2004													//
// Copyright	: © Naked Vision													//
//////////////////////////////////////////////////////////////////////////////////////
function OpenWindow(URL){
	windowA = window.open(URL,"windowA","toolbar=no,width=330,height=310,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no");
}

//==========================================================================================================
//	AJAX FUNCTIONS
//==========================================================================================================
/*********************
	loadXMLDoc()
	Ajax function that is to get the data without reloading the page.
*********************/
var req;

function loadXMLDoc(url){
	// branch for native XMLHttpRequest object
	if(window.XMLHttpRequest){
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send(null);
	// branch for IE/Windows ActiveX version
	}else if(window.ActiveXObject){
		req = new ActiveXObject('Microsoft.XMLHTTP');
		if (req) {
			req.onreadystatechange = processReqChange;
			req.open("GET", url, true);
			req.send();
		}
	}
	return false;
}

function processReqChange() 
{
	// only if req shows "complete"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {
			eval(req.responseText);
		} else {
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}

function HideLogin(sName){
	document.getElementById('LoginBox').className='LoginBoxHide';
	document.getElementById('LoginMsg').className='ErrorHide';
	document.getElementById('LoggedInBox').className='LoginBoxShow';
	document.getElementById('LoggedInBox').innerHTML='<b>Welcome back<br/>' + sName + '</b>';
	
	if(document.getElementById('btnRegister')){
		document.getElementById('btnRegister').src='/images/ck_contiue.gif';
	}
}

function LoginMsgShow(){
	document.getElementById('LoginMsg').className='ErrorShowLogin';
}

function UsernameTaken(){
	document.getElementById('divError').className='ErrorShow';
	document.getElementById('divError').innerHTML = document.getElementById('divError').innerHTML + '<li>Username already taken</li>';
}
