ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;

// #############################################################
// Main fn.


// #############################################################
// Check text fields are not blank

function checkForLoginBlanks( theForm )
{
    if( theForm.uName.value == "" || theForm.pWord.value == "" )
	{
    	alert( "Please enter both username and password" );
		return false;
	}
    return true;
}

function checkForPageNameBlanks( theForm )
{
    if( theForm.docName.value == "" )
	{
    	alert( "Please enter a name for your page" );
		return false;
	}
    return true;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function setFocus( formName, fieldName )
{
//	str = eval( "document."+formName+"."+fieldName+".focus();" );
	alert( "got here" );
//	str.focus(); // set initial focus
//	return str;
//	document.frmOrder.Store.focus(); // set initial focus
}

function addChar(input, character) {
if(input.value == null || input.value == "0")
input.value = character
else
input.value += character
}
function cos(form) {
form.display.value = Math.cos(form.display.value);}
function sin(form) {
form.display.value = Math.sin(form.display.value);}
function tan(form) {
form.display.value = Math.tan(form.display.value);}
function sqrt(form) {
form.display.value = Math.sqrt(form.display.value);}
function ln(form) {
form.display.value = Math.log(form.display.value);}
function exp(form) {
form.display.value = Math.exp(form.display.value);}
function sqrt(form) {
form.display.value = Math.sqrt(form.display.value);}
function deleteChar(input) {
input.value = input.value.substring(0, input.value.length - 1)
}
function changeSign(input) {
if(input.value.substring(0, 1) == "-")
input.value = input.value.substring(1, input.value.length)
else
input.value = "-" + input.value
}
function compute(form)  {
form.display.value = eval(form.display.value)}
function square(form)  {
form.display.value = eval(form.display.value) *
eval(form.display.value)}
function checkNum(str)  {
for (var i = 0; i < str.length; i++) {
var ch = str.substring(i, i+1)
if (ch < "0" || ch > "9") {
if (ch != "/" && ch != "*" && ch != "+" && ch !=
"-" && ch != "."
&& ch != "(" && ch!= ")") {
alert("invalid entry!")
return false
         }
      }
   }
return true
}

var answers = new Array(
"Without a doubt", 
"Yes!", 
"Probably so", 
"It isn't likely", 
"it's possible",
"Absolutely", 
"Not a chance",
"Ask again", 
"No", 
"I doubt it", 
"No Way"
);

function fortune() {
num = Math.round( (answers.length - 1) * Math.random());
return answers[num];
}
function showPage( docName, docLocation )
{
	win = window.open("http://homepage.eircom.net/"+docLocation+"/"+docName+".html", ""+docName+"", "scrollbars=yes, location=no, height=600, width=800, titlebar=0,resizable=yes");
	return 1;
}
function openWin( linkName )
{
	win = window.open("http://www.eirco.com", "EircoWebServices", "left=100, top=50, height=600, width=800, titlebar=0,resizable=no");
	return 1;
}

function showSample( tplID )
{
	win = window.open("samples/sample"+tplID+".html", "sample", "left=300, screenY=100, height=425, width=465, titlebar=0,resizable=no");
	return 1;
}
function showHelp(num)
{
//	win = window.open("help/help1.html", "help1", "left=300, screenY=100, height=425, width=465, locationbar=yes, titlebar=0,resizable=no");
	win = window.open("help/help"+num+".html", "help"+num, "left=300, screenY=100, height=550, width=535, scrollbars=yes, titlebar=0,resizable=no");
	return 1;
}
function previewPics(cell)
{
	win = window.open("preview.php3?cell="+cell, "preview", "location=no, menubar=yes, toolbar=0,  titlebar=0,resizable=no");
	return 1;
}

function previewPic1(form) {
document.previewImage1.src = "/eircomnet/imageLibrary/" + form.options[form.selectedIndex].value;
}
function previewPic2(form) {
document.previewImage2.src = "/eircomnet/imageLibrary/" + form.options[form.selectedIndex].value;
}
function previewPic3(form) {
document.previewImage3.src = "/eircomnet/imageLibrary/" + form.options[form.selectedIndex].value;
}
function previewPic4(form) {
document.previewImage4.src = "/eircomnet/imageLibrary/" + form.options[form.selectedIndex].value;
}

function previewSkin(hello) {
//alert( form.options[form.selectedIndex].value );
//alert( this.userinputForm.imageLib3.options[this.userinputForm.imageLib3.selectedIndex].value );
//alert( cell );
//document.previewImage.src = userinputForm.imageLib+cell+.options[userinputForm.imageLib+cell+.selectedIndex];
document.previewBackground.src = "/eircomnet/backgrounds/" + hello.options[hello.selectedIndex].value;
}
function previewSkin2(hello) {
//alert( form.options[form.selectedIndex].value );
//alert( this.userinputForm.imageLib3.options[this.userinputForm.imageLib3.selectedIndex].value );
//alert( cell );
//document.previewImage.src = userinputForm.imageLib+cell+.options[userinputForm.imageLib+cell+.selectedIndex];
document.previewBackground2.src = "/eircomnet/backgrounds/" + hello.options[hello.selectedIndex].value;
}

var hours
var minutes
var seconds

function showtime() {
	var thistime= new Date()
	hours=thistime.getHours()
	minutes=thistime.getMinutes()
	seconds=thistime.getSeconds()
	if (eval(minutes) < 10) {minutes="0"+minutes}
	if (eval(seconds) < 10) {seconds="0"+seconds}
	if (eval(hours) < 10) {hours="0"+localhours}
	thistime = hours+":"+minutes+":"+seconds
    document.bigwatch.button.value=thistime
    var timer= setTimeout("showtime()",1000)
}
function openWordWin( url )
{
//	win = window.open("help/help1.html", "help1", "left=300, screenY=100, height=425, width=465, locationbar=yes, titlebar=0,resizable=no");
	win = window.open( url, "preview", " height=600, width=800, scrollbars=yes, locationbar=yes, titlebar=0,resizable=no");
	return 1;
}

