	var name = false;
	var emailadd = false;
	var services = false;
	var hear = false;
	var message = false;
	mylink = window.location.href;
	
	var a = mylink.split("co.uk");
		
	var link = a[1];

	var a = Array();
	var i = 0;
	var j=0;
	var s=0;
	var whichid = "";
	var classname="";
	var id = "";
	
	var heightarr  = new Array();

$(document).ready(function() { 
	$( "div.newslist-txt" ).each(function( intIndex )
	{
		var sLink = $(this).html();
		a[i] = sLink;
		heightarr[i] = $(this).css("height");
		//alert(heightarr[i]);
		i++;
	} 
	);
	animateNews();
	//populateManufacturers();
	//populateConditions();
	//highlightmenu();
});

function animateNews() {
	if (j == a.length) { j = 0; }
	var h = a[j];
	$('#scrollercontainer').html(h);
	j++;
	setTimeout("animateNews()",8000);
}

/*function highlight2() {
	
	if (link.indexOf("singlenews.aspx") > 0) {
		link = '/singlenews.aspx';
	}
	
	if (link.indexOf("searchresults.aspx") > 0) {
		link = '/searchresults.aspx';
	}
	
	if (link.indexOf("page=contactus") > 0) {
		link = 'contactus';
	}
	
	switch (link) {
		case '/default.aspx':
		case '/Default.aspx':
		case '/': whichid = "0"; classname="mnuhome"; break;
		case '/services/tapedriveandlibrarysolutions/':
		case '/services/recordsmanagement':
		case '/services/offsitestorage':
		case '/services/archivedocumentstorage/': 
		case '/services/tapemediastorage/':
		case '/services/scanondemand/':
		case '/services/onlinedocumentviewing/':
		case '/services/confidentialdestruction/':
		case '/services/supplies/':
		case '/services/collectionanddeliveries/':
		case '/services/deeparchivestorage/':
		case '/services/barcodetracking/':
		case '/services/tapedrivesales/':
		case '/services/librarysystemsales/':
		case '/services/partssupplies/':
		case '/services/installation/':
		case '/services/repairandrefurbishment/':
		case '/services/libraryrepair/':
		case '/services/technicalsupport/':
		case '/services/onlinedatabackup/':
		case '/services/datacontigencyplanning/':
		case '/services/remotemanagedbackup/':
		case '/services/documentstorage/':
		case '/services/': whichid = "1"; classname="mnuservices"; break;
		case '/stocklist/': 
		case '/searchresults.aspx':
		case '/default.aspx?page=stocklist':
		case '/products/': whichid = "23"; classname="mnuproducts"; break;
		case '/aboutus/': whichid = "24"; classname="mnuaboutus"; break;
		case '/findus/':
		case '/how-to-find-us/': whichid = "27"; classname="mnuhowtofindus"; break;
		case '/singlenews.aspx':
		case '/news/': whichid = "28"; classname="mnunews"; break;
		case '/sponsorship/': whichid = "29"; classname="mnusponsorship"; break;
		case 'contactus':
		case '/Default.aspx?page=contactus':
		case '/contactus/': whichid = "30"; classname="mnucontactus"; break;
		default: whichid = "0"; classname='mnuhome'; break;
	}

	if (whichid != "") {
		//alert(whichid);
		id = "pageViwer_menubar_ctl00_menu_"+whichid;
	}
	else {  }

	//document.getElementById(id).setAttribute("onmouseout","ComponentArt_Menu_Support.ComponentArt_Menu_ItemMouseOut(this,event);");//getselected('"+id+"','"+classname+"');");
	getselected();

}*/

function getselected() { 
	$(document.getElementById(id)).addClass(classname+'hover');
	$(document.getElementById(id)).removeClass(classname);
	setTimeout('getselected()',1);
}//alert(i+"\n"+c); }

function getstocklist() {
	var url = "/data/ajax/dataspace.php?method=getstocklist";
	var pars = "";
	$.post(url,
		   {}, function(data) {  displaystocklist(data.returnedValue); }, "json"
	);
}

function displaystocklist(d) {
	var insplit = d.split('~');
	var html = '<table width="100%" border="1"><tr><th>Part Number</th><th>Manufacturer</th><th>Condition</th><th>Quantity</th><th>Description</th></tr>';
	
	var i=0;
	while (i<insplit.length) {
		var prodsplit = insplit[i].split('$%');
		html += '<tr>';
		var j=0;
		while (j<prodsplit.length) {
			html += '<td>'+prodsplit[j]+'</td>';
			j++;
		}
		html += '</tr>';
		i++;
	}
	//alert(j);
	html += '</table>';
	document.getElementById('stocklistdiv').innerHTML = html;
}
function replacecommas(d) {
	d = d.replace(/@commas@/g,",");
}

function eraseDropDown(form){
	for(var i=form.length-1;i>0;i--){
		//alert(form.options[i]);
		form.options[i] = null;
		
	}
}


function populateManufacturers() {
	var url = "/data/ajax/dataspace.php?method=populateManufacturers";
	$.post(url,
		   {}, function(data) {  displaymanufacturers(data.returnedValue); }, "json"
	);
}

function displaymanufacturers(d) {
	var sp = d.split('~');
	eraseDropDown($('manufactureddl'));
	document.getElementById('manufactureddl').options[0] = new Option("Manufacturer",-1);
	var i = 0;
	while (i < sp.length) {
		document.getElementById('manufactureddl').options[i+1] = new Option(sp[i],sp[i]);
		i++;
	}
}

function populateConditions() {
	var url = "/data/ajax/dataspace.php?method=populateCondition";
	$.post(url, {}, function(data) { displaycondition(data.returnedValue); }, "json");
}

function displaycondition(d) {
	var sp = d.split('~');
	eraseDropDown(document.getElementById('conditionddl'));
	document.getElementById('conditionddl').options[0] = new Option("Condition",-1);
	var i = 0;
	while (i < sp.length) {
		document.getElementById('conditionddl').options[i+1] = new Option(sp[i],sp[i]);
		i++;
	}
}

function clearbox(b) {
	document.getElementById(b).value ="";
}

function searchforparts() {
	var s = document.getElementById('searchbox').value;
	var m = document.getElementById('manufactureddl').value;
	var c = document.getElementById('conditionddl').value;
	if (s == "Search..." && m == "-1" && c == "-1") { window.location.href = "/products/"; } else {
		window.location.href = "/searchresults.aspx?search="+s+"&manufacturer="+m+"&condition="+c;
	}
}

function searchforpartsajax(s,m,c) {
	var url = "/data/ajax/dataspace.php?method=searchforparts";
	$.post(url, { search: s, manufacturer: m, condition: c }, function (data) { gotopage(data.returnedValue,data.count); }, "json");
}

function gotopage(d,c) {
	if (d == "") {
		var html = "No products found, please refine your search";
	} else {
		var insplit = d.split('~');
		var html = '<table width="100%" border="1"><tr><th>Part Number</th><th>Manufacturer</th><th>Condition</th><th>Quantity</th><th>Description</th></tr>';
		
		var i=0;
		while (i<insplit.length) {
			var prodsplit = insplit[i].split('$%');
			html += '<tr>';
			var j=0;
			while (j<prodsplit.length) {
				html += '<td>'+prodsplit[j]+'</td>';
				j++;
			}
			html += '</tr>';
			i++;
		}
		html += '</table>';
	}
	
	var count = "Display <strong>"+c+"</strong> results<hr>";
	setdivs(count,html);
}

function setdivs(c,h) {
	//alert("Loading Results");
	document.getElementById('countdiv').innerHTML = c;
	document.getElementById('searchdiv').innerHTML = h;
}

function webtrack() {
	var u = document.getElementById('wslusername').value;
	var p = document.getElementById('wslpassword').value;
	var s = document.getElementById('wslsubmit').value;
	window.location.href = "/php/webtrack.php?username="+u+"&password="+p+"&submitted="+s;
}

/*function checkform() {
	if (name && emailadd && services && hear && message) { 
		document.getElementById('submitrow').style.display = 'block'; }
	else { 
		document.getElementById('submitrow').style.display = 'none';
	}
}*/
function checkemail(t) {
	var email = t.value;
	var hide = false;
	if (email == "") {
		document.getElementById('firstemail').style.display = 'block';
		document.getElementById('firstemail').innerHTML = '<span style="color:red">Please enter an email address</span>';
		document.getElementById('pageViwer_sompo_content_2_ctl00_fpcFormPresentation_ctl04_Input').focus();
	}
	else {
		var filter = /^([a-zA-Z0=9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(email)) { 
			document.getElementById('firstemail').style.display = 'block';
			document.getElementById('firstemail').innerHTML = '<span style="color:red">Please enter a valid email address</span>';
			document.getElementById('pageViwer_sompo_content_2_ctl00_fpcFormPresentation_ctl04_Input').focus();
			document.getElementById('pageViwer_sompo_content_2_ctl00_fpcFormPresentation_ctl04_Input').highlight();
		}
		else { hide = true; }
	}
	if (hide) {
		document.getElementById('firstemail').style.display = 'none';
		emailadd = true;
	}
	else { emailadd = false; }
	checkform();
}

function checkname(t) {
	var n = t.value;
	var hide = false;
	var filter = /^([a-zA-Z])[-a-zA-Z]+\ ([a-zA-Z])[-a-zA-Z]/;
	if (!filter.test(n)) {
		alert("Please enter a valid name in the following formats:\n\n\tFirstname Surname\n\tFirst-name Surname\n\tFirst Sur-name\n\tFirst-name Sur-name");
		hide = false;
	}
	else {
		hide = true;
	}
	if (hide) {
		name = true;
	}
	else { name = false; }
	checkform();
}

function checkservices(t) {
	var s = t.value;
	(s=="-1") ? services = false : services = true;
	checkform();
}

function checkhear(t) {
	var s = t.value;
	(s=="-1") ? hear = false : hear = true;
	checkform();
}

function checkmessage(t) {
	var m = t.value;
	var hide = false;
	var msplit = m.split(' ');
	var num=0;
	var a = Array('anal','anus','arse','ass','ballsack','balls','bastard','bitch','biatch','bloody','blowjob','blow job','bollock','bollok','boner','boob','bugger','bum','butt','buttplug','clitoris','cock','coon','crap','cunt','damn','dick','dildo','dyke','fag','feck','fellate','fellatio','felching','fuck','f u c k','fudgepacker','fudge packer','flange','Goddamn','God damn','hell','homo','jerk','jizz','knobend','knob end','labia','lmao','lmfao','muff','nigger','nigga','omg','penis','piss','poop','prick','pube','pussy','queer','scrotum','sex','shit','s hit','sh1t','slut','smegma','spunk','tit','tosser','turd','twat','vagina','wank','whore','wtf');
	
	
	for (var i=0;i<msplit.length;i++) {
		var w = msplit[i];
		if (a .indexOf(w)>-1) {
			num=1;
		}
	}
	if (num==0) {
		message = true;
	}
	else {
		alert("Your message contains inappropriate words, please review your message");
		message = false;
		//t.focus();
	} 
	checkform();
}

$(document).ready(function() {
	var id = "";
	var className = "";
	switch (link) {
		case "/":
		case "/default.aspx":
		case "/Default.aspx":
			id = "#pageViwer_menubar_ctl00_menu_0";
			className = "mnuhomehover";
			break;
		case "/services/archivedocumentstorage/": /* old */
		case "/services/documentstorage/":
		case "/services/document-storage/":
		case "/services/tapemediastorage/": /* old */
		case "/services/mediastorage/":
		case "/services/media-storage/":
		case "/services/scanondemand/": /* old */
		case "/services/documentscanondemand/":
		case "/services/document-scan-on-demand/":
		case "/services/onlinedocumentviewing/": /* old */
		case "/services/onlinedocumentmanagement/":
		case "/services/online-document-management/":
		case "/services/confidentialdestruction/": /* old */
		case "/services/documentdestruction/":
		case "/services/document-destruction/":
		case "/services/supplies/": /* old */
		case "/services/storagesupplies/":
		case "/services/storage-supplies/":
		case "/services/collectionanddeliveries/": /* old */
		case "/services/delivery/":
		case "/services/barcodetracking/":
		case "/services/barcode-tracking/":
		case "/services/tapedrivesales/":
		case "/services/tape-drive-sales/":
		case "/services/librarysystemsales/": /* old */
		case "/services/tapelibrarysales/":
		case "/services/tape-library-sales/":
		case "/services/partssupplies/":
		case "/services/parts-supplies/":
		case "/services/installation/":
		case "/services/repairandrefurbishment/": /* old */
		case "/services/tapedriverepair/":
		case "/services/tape-drive-repair/":
		case "/services/libraryrepair/":
		case "/services/library-repair/":
		case "/services/technicalsupport/":
		case "/services/technical-support/":
		case "/services/remote-managed-backup/":
		case "/services/remotemanagedbackup/":
		case "/services/onlinedatabackup/":
		case "/services/online-data-backup/":
		case "/services/datacontigencyplanning/":
		case "/services/data-contigency-planning/":
		case "/Cloud-Document-Storage/":
		case "/services/Cloud-Document-Storage/":
			id = "#pageViwer_menubar_ctl00_menu_1";
			className = "mnuserviceshover";
			break;
		case "/stocklist/":
		case "/stock-list/":
			id = "#pageViwer_menubar_ctl00_menu_24";
			className = "mnuproductshover";
			break;
		case "/aboutus/":
		case "/about-us/":
			id = "#pageViwer_menubar_ctl00_menu_25";
			className = "mnuaboutushover";
			break;
		case "/news/":
			id = "#pageViwer_menubar_ctl00_menu_26";
			className = "mnunewshover";
			break;
		case "/sponsorship/":
			id = "#pageViwer_menubar_ctl00_menu_27";
			className = "mnusponsorshiphover";
			break;
		case "/findus/":
		case "/how-to-find-us/":
			id = "#pageViwer_menubar_ctl00_menu_28";
			className = "mnuhowtofindushover";
			break;
		case "/contactus/":
		case "/contact-us/":
			id = "#pageViwer_menubar_ctl00_menu_29";
			className = "mnucontactushover";
			break;
		default:
			id = "#pageViwer_menubar_ctl00_menu_24";
			className = "mnuproductshover";
			break;
	}
	
	if (link.substring(0,16) == '/singlenews.aspx') {
		id = "#pageViwer_menubar_ctl00_menu_26";
		className = "mnucontactushover";
	}
	
	$(id).addClass(className);
	$(id).removeAttr("onmouseout");
});

$(document).ready(function() {
	$("#sfp input[type=text]").css("width","173px");
	$("#sfp div input[type=submit]").css("margin","0px 6px 0px 0px");
	$("#sfp select").css("width","178px");
	
	
	switch (link) {
		case '/contactus/':
			$("table td input[type=text]").css("width","220px");
			$("table td select").css("width","220px");
			$("table td textarea").css("width","220px");
			break;
	}
});
