// 
function preventSelection(){
	if (navigator.userAgent.indexOf('Win') >= 0 && 
		navigator.userAgent.indexOf('MSIE') >= 0)
		document.selection.empty();
	return;
}

// Navigation Rollovers
img1_off = new Image(); img1_off.src = "images/home.gif";
img2_off = new Image(); img2_off.src = "images/gates.gif";
img3_off = new Image(); img3_off.src = "images/windows.gif";
img4_off = new Image(); img4_off.src = "images/furniture.gif";
img5_off = new Image(); img5_off.src = "images/ironmongery.gif";
img6_off = new Image(); img6_off.src = "images/doors.gif";
img7_off = new Image(); img7_off.src = "images/contact.gif";

img1_on = new Image(); img1_on.src = "images/home_on.gif";
img2_on = new Image(); img2_on.src = "images/gates_on.gif";
img3_on = new Image(); img3_on.src = "images/windows_on.gif";
img4_on = new Image(); img4_on.src = "images/furniture_on.gif";
img5_on = new Image(); img5_on.src = "images/ironmongery_on.gif";
img6_on = new Image(); img6_on.src = "images/doors_on.gif";
img7_on = new Image(); img7_on.src = "images/contact_on.gif";

function imgOn(img) {
	document[img].src = eval(img + "_on.src");
}
function imgOff(img) {
	document[img].src = eval(img + "_off.src");
}

// Control Messages
function msgAlert(msgIndex,msgType) {
	// msgType of 1 gives an alert, 0 gives a confirm
	arAlert = new Array();
	arAlert[20] = "Are you sure you want to delete this article?";
	arAlert[21] = "The article was deleted as requested";
	arAlert[22] = "This article does not exist.";
	arAlert[23] = "Are you sure you want to delete this file?";
	arAlert[24] = "The file was deleted successfully";
	arAlert[25] = "There was a problem deleting the file.\nPlease wait for a minute and try again.\n\nIf the problem persists then please \ncall e-mango support.";
	arAlert[26] = "Your changes have been saved.";
	arAlert[27] = "The article has been added.\n\nYou can now add more documents if you wish.";
	arAlert[0] = "empty";
	arAlert[1] = "Your changes have been Saved.";
	arAlert[2] = "Please enter your Username";
	arAlert[3] = "Please enter your Password";
	arAlert[10] = "Please complete the Name field.";
	arAlert[11] = "Please complete the First Address field";
	arAlert[12] = "Please complete the Post Code field";
	arAlert[13] = "Please complete the Telephone Number field";
	arAlert[14] = "Please complete the E-mail field";
	arAlert[100] = "Your image has been uploaded successfully";
	arAlert[101] = "Your image has been edited successfully";
	arAlert[102] = "Are you sure you want to delete this image? This can not be undone.";
	arAlert[103] = "Your image has been deleted successfully";
	arAlert[201] = "Your price file has been uploaded successfully";
	if (parseInt(msgType)) {
		alert(arAlert[msgIndex]);
	} else {
		return confirm(arAlert[msgIndex]);
	}
}

// Login Form Field Check
function chkLoginForm() {
	var retval = 1;
	with (document.loginform) {
		if (!username.value.length) {
			retval = 0;
			msgAlert(2, 1);
			username.focus()
		} else if (!password.value.length) {
			retval = 0;
			msgAlert(3, 1);
			password.focus()
		}
	}
	if (retval) {
		return true;
	} else {
		return false;
	}
}

// Contact Form Field Check
function chkContactForm() {
	var retval = 1;
	with (document.contactform) {
		if (!yourname.value.length) {
			retval = 0;
			msgAlert(10, 1);
			yourname.focus()
		} else if (!address.value.length) {
			retval = 0;
			msgAlert(11, 1);
			address.focus()
		} else if (!postcode.value.length) {
			retval = 0;
			msgAlert(12, 1);
			postcode.focus()
		} else if (!telno.value.length) {
			retval = 0;
			msgAlert(13, 1);
			telno.focus()
		} else if (!email.value.length) {
			retval = 0;
			msgAlert(14, 1);
			email.focus()
		}
	}
	if (retval) {
		return true;
	} else {
		return false;
	}
}

//pop up function
function popup(pageitem) {
	window.open(pageitem, "name", "location=0,menubar=0,resizable=1,scrollbars=0,status=1,height=400,width=600");
}


function toggleLayer( whichLayer ){  
var elem, vis;  
if( document.getElementById ) // this is the way the standards work    
	elem = document.getElementById( whichLayer );  
else if( document.all ) // this is the way old msie versions work      
	elem = document.all[whichLayer];  else if( document.layers ) // this is the way nn4 works    
	elem = document.layers[whichLayer];  vis = elem.style;  
// if the style.display value is blank we try to figure it out here  
if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)    
	vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  
	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}





function randomizeContent(classname){
var contents=randomizeContent.collectElementbyClass(classname)
contents.text.sort(function() {return 0.5 - Math.random();})
var tbodyref=contents.ref[0].tagName=="TR"? contents.ref[0].parentNode : new Object()
for (var i=0; i<contents.ref.length; i++){
if (tbodyref.moveRow) //if IE
tbodyref.moveRow(0, Math.round(Math.random()*(tbodyref.rows.length-1)))
else
contents.ref[i].innerHTML=contents.text[i]
contents.ref[i].style.visibility="visible"
}
}

randomizeContent.collectElementbyClass=function(classname){ 
var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)", "i") 
var contentobj=new Object()
contentobj.ref=new Array() 
contentobj.text=new Array() 
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (var i=0; i<alltags.length; i++){
if (typeof alltags[i].className=="string" && alltags[i].className.search(classnameRE)!=-1){
contentobj.ref[contentobj.ref.length]=alltags[i]
contentobj.text[contentobj.text.length]=alltags[i].innerHTML
}
}
return contentobj
}




