// filename:		generic.js
// author:			Dean Pollard / Rob Jones
// copyright:		Sunday Launch Limited www.sundaylaunch.co.uk
// description:		this is a javascript file that is included in each web page to
//					ensure all the functions are available throughout and thus will
//					assist in development

// global variables

// this array is used for the scrolling text function and contains the text that is
// to appear as if it is being typed. each array element will be displayed in turn
var arrMsg=new Array();
arrMsg[0]="Website design and development";
arrMsg[1]="Basic and bespoke websites";
arrMsg[2]="Maintenance packages";
arrMsg[3]="Basic Computer Training";
arrMsg[4]="Website marketing";
arrMsg[5]="Consultancy";
intSpeed=200;				// the speed that the letters are 'typed'
intChrPos=0;				// the current character position
strTemp="";					// temporary string variable
intArrLen=arrMsg.length;	// gets the length of the array
intArrPos=0;				// the current position in the array

function fullwin(targeturl)
{
	if (targeturl == null)
		targeturl = "http://www.sundaylaunch.co.uk";
	window.open(targeturl,"","scrollbars,toolbar,resizable,status,location")
}
// function name: 	RunGenericFunctions()
// author:			Dean Pollard / Rob Jones
// copyright:		Sunday Launch Limited www.sundaylaunch.co.uk
// description:		this function is called from every web page and is the place to 
//					put code, calls to other functions that need to be run when each
//					page is loaded.
// parameters:		none
// return value:	none
// global refs:		none
function RunGenericFunctions()
{
	// this should turn the right mouse click off, can be annoying
	window.document.oncontextmenu=new Function("return false;");
	
}

var LargeImageWin; 
	
// function name: 	bigImage()
// author:			Dean Pollard / Rob Jones
// copyright:		Sunday Launch Limited www.sundaylaunch.co.uk
// description:		this function is called from hyperlinks over an image
//					to display a larger image of itself, passing the
//					image name and the width and height
// parameters:		strImageName - the image name (including location)
//					w - width
//					h - height
// return value:	none
// global refs:		LargeImageWin - the name of the window to open, tested against
//					to enusre that not more than one window gets opened
function bigImage(strImageName,w,h)
{
	//idBigImage.src = strImageName; 
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	w+=20;
	h+=20;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,status=no,toolbar=no,menubar=no,location=no';
	if (LargeImageWin != null)
		LargeImageWin.close();
			
	LargeImageWin=window.open(strImageName,"LargeImageWin",settings);
	LargeImageWin.focus();
}

// function name: 	Scrollbox()
// author:			Rob Jones
// copyright:		Sunday Launch Limited www.sundaylaunch.co.uk
// description:		this function basically 'types' out the text put in a global array,
//					one letter at a time into a span with an id 'scrolltext' in each page.
//					NOTE: <span id="scrolltext">&nbsp;</span> needs to be in each page
//					for this function to work.
// parameters:		none
// return value:	none
// global refs:		intChrPos, intArrPos, intArrLen, arrMsg, strTemp, intSpeed
function Scrollbox()
{
	if(intArrPos>=intArrLen) 
	{
		intArrPos=0;
	}
	intLen=arrMsg[intArrPos].length;

	strTemp = strTemp + arrMsg[intArrPos].substr(intChrPos,1);

	/* If you want a different font and color then change the syle in the stylesheet */
	if(document.getElementById)
	{
		// IE
		objElm=document.getElementById("scrolltext");
		objElm.innerHTML=strTemp;
	}
	else
	{
		// Netscape
		if(document.layers)
		{
			document.scrolltext.document.write(strTemp);
			document.scrolltext.document.close();
		}
	}
	intChrPos++;
	if(intChrPos<intLen)
	{
		intCounts=setTimeout("Scrollbox()",intSpeed);
	}
	else
	{
		intChrPos=0;
		strTemp="";
		intArrPos++;
		intCounts=setTimeout("Scrollbox()",(intSpeed * 5));
	}
}


function getElementNoForm(strID)
{	// get an element object regardless of browser...
	var obj = document.layers ? document.layers[strID] : document.getElementById ? document.getElementById(strID) : document.all[strID];
	return obj;
}

function getElement(strFormName, strID)
{	// get an element in the form name supplied...
	var obj = null;
	if (strFormName.length > 0)
	{
		obj = document.forms[strFormName].elements[strID];
	}
   return obj;
}

function MM_findObj(n, d) { //v4.01
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);
if(!x && d.getElementById) x=d.getElementById(n); 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 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];}}
}