// JavaScript Document

//new Window
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
	win.focus();
}
//new window onLoad function
function windowSize(window) 
  {
	if (!document.all) {
		window.sizeToContent();
		window.sizeToContent();	// for reasons beyond understanding,
								// only if we call it twice we get the
								// correct size.
		// center on parent
		var x = (screen.width - window.outerWidth) / 2;
		var y = (screen.height - window.outerHeight) / 2;
		window.moveTo(x, y);
        // resize ie
		window.resizeTo(540, 300);
	} else {
		window.resizeTo(540, 400);

		var ch = body.clientHeight;
		var cw = body.clientWidth;
		var W = body.offsetWidth; 
	}
}
//function for an unspammable email address.

function email(x){
	var name = x;
	var domain = "rapidlabels.com.au";
	var address = '<a href=\"mailto:' + name + '@' + domain + '\">' + name + '@' + domain + '</a>';
	return address;
	}

//script to validate Enq form
function validateEnq(form) {
	
	if (form.name.value == "" ) { 
		alert('Please enter your name.'); 
		form.name.focus(); 
		form.name.select();
		return false;
	}

	
	if ((form.TelBH.value == "" || form.TelBH.value.length < 8) && (form.TelMO.value == "" || form.TelMO.value.length < 10)) { 
		alert('Please enter your telephone number.'); 
		form.TelBH.focus(); 
		form.TelBH.select();
		return false;
	}	
	
	var email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;  <!-- reg. expression for email address -->
	if(email.test(form.email.value) == false){ 
		alert('Please enter a valid e-mail.'); 
		form.email.focus(); 
		form.email.select();
		return false;
	}

	if (form.enq.value == "" ) { 
		alert('Please enter your enquiry.'); 
		form.enq.focus(); 
		form.enq.select();
		return false;
	}	
	
	return true;
} 
//end Enq form validation

 
//Uberlink Script
function P7_Uberlink(cl,d){
	var i,ob,tA,h=document.location.href;
	if(document.getElementById){
	ob=(d)?document.getElementById(d):document;
	if(ob){
	tA=ob.getElementsByTagName('A');
	for(i=0;i<tA.length;i++){
	if(tA[i].href==h){
	tA[i].className=cl;
}}}}}
//end Uberlink Script