	function ResizeFeatAdWin()	{
		var me=window.name;
		//alert("window = " + me);
		if(me=="win2"){return;}
		var ie7up=IsIE7up();
		if(ie7up){
			IE7OpenWin(self); //determine correct size then open new window with correct size and close this window!
		}else{			
			ResizeWin(self);
		}
	}

	
	function IsIE(){
		var browserName = navigator.appName;	 	 
		if (browserName == "Microsoft Internet Explorer"){return true;}
		else{return false;};
	}
	
	function getElementStyle(elemID, IEStyleProp, CSSStyleProp, win) {
		if(!win) win = window;
		doc = win.document;
		var elem = getEl(elemID,doc);
		if (elem.currentStyle) {
			return elem.currentStyle[IEStyleProp];
		}else if (win.getComputedStyle) {
			var compStyle = win.getComputedStyle(elem, "");
			return compStyle.getPropertyValue(CSSStyleProp);
		}
		return "";
	}


	// RJR 21-Feb-08
	// In IE 7 you cannot resize pop ups on the fly with resizeTo unless tabbed browsing is diabled
	// Only call this if you know its IE
	function IsIE7up()
	{
		var agt=navigator.userAgent.toLowerCase();
		var appVer = navigator.appVersion.toLowerCase();
		var is_mac = (agt.indexOf("mac")!=-1);	
		var iePos  = appVer.indexOf('msie');
		if (iePos !=-1) {
		   if(is_mac) {
			   var iePos = agt.indexOf('msie');
			   is_minor = parseFloat(agt.substring(iePos+5,agt.indexOf(';',iePos)));
		   }
		   else is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
		   is_major = parseInt(is_minor);
		}else{return false;}
		if (is_minor>=7){return true;}
		else{return false;}
	}

	// RJR function to convert em to px incase widths are done in em
	function ConvertEmToPX(em, win)
	{
		if(!win){win = window}
		var doc = win.document;
		var fs, fspx, elem;
		if(doc.body.fontSize){
			fs = doc.body.fontSize;
		}else{
			elem = doc.body;
			if (elem.currentStyle) {					
				fs = elem.currentStyle["fontSize"];							
			}else if (win.getComputedStyle) {
				var compStyle = win.getComputedStyle(elem, "");					
				fs = compStyle.getPropertyValue("font-size");
			}					
		}
		//if in points needs pixels
		fpt = fs.toString()
		pt = fpt.substring(fpt.length-2,fpt.length)				
		if(pt=="pt"){					
			fspx = 1.3333*parseInt(fs)
		}else if(pt=="px"){
			fspx = parseFloat(fs)
		}				
		return fspx*em
	}


	function IE7OpenWin(winX)
	{
		//alert("IN IE 7 Open Win")
		if(!winX) return;
		//will try and access a div container called featuredjob first if not then JBcontent and then content
		var el = getEl( 'featuredjob', winX.document ); 
		if(!el){ el = getEl( 'content', winX.document ) };
		if(!el){ el = getEl( 'JBcontent', winX.document ) };
		//alert("use " +el.id)
		if(!el) {return;} //could not find any known div containers so keep original size

		var width=getWidth(el.id);
		var height=getHeight(el.id);

		//alert("w="+width+" h="+height)
		if(width==0||height==0){var d = winX.document.documentElement, b = winX.document.body;}
		if(width==0){
			if( winX.innerWidth ) { width = winX.innerWidth;}
			else if( d && d.clientWidth ) { width = d.clientWidth;}
			else if( b && b.clientWidth ) { width = b.clientWidth;}
			if( window.opera && !document.childNodes ) { width += 16; }
		}else if(height==0){
			if( winX.innerHeight ) {  height = winX.innerHeight; }
			else if( d && d.clientHeight ) { height = d.clientHeight; }
			else if( b && b.clientHeight ) { height = b.clientHeight; }
		}
		//alert("2 w="+width+" h="+height)
		var scW = screen.availWidth ? screen.availWidth : screen.width;
		var scH = screen.availHeight ? screen.availHeight : screen.height;	
		//if height or width are over the available screen space we want scrollbars on new win and allow resize
		var scroll=0;
		if(width>=scW) scroll=1;
		if(height>=scH) scroll=1;
		//alert("do open win = " + window.location.href)
		//alert("open w = " + width +" h = "+ height)
		var win2=OpenNewWin('win2',width+150,height,0,0,scroll,0,scroll,0,0,0,window.location.href,'win2',"");	
		if(win2){
			//alert("open")
			if(win2.focus){win2.focus()};
			//alert("close")
			self.close();
		}
		//alert("done")
		return false
	}


	function test()
	{
		alert("in test")

		var x = self
		alert("self.offsetWidth = " + x.offsetWidth)// + " document.clip.width = " + x.clip.width)
		
		x = x.document;
		alert("document.body.offsetWidth = " + x.body.offsetWidth + " style.width = " + x.body.style.width)
		
		var el = getEl( 'featuredjob', x );
		if(el){ alert("robs func = " + getWidth(el.id) + " " + el.id+".offsetWidth = " +  el.offsetWidth+ " " + el.id + ".style.width = " + el.style.width + " getElementStyle = " + getElementStyle(el.id, "width", "width"));}
		return
		el = getEl( 'content', x );
		if(el){ alert("robs func = " + getWidth(el.id) + " " + el.id+".offsetWidth = " +  el.offsetWidth+ " " + el.id + ".style.width = " + el.style.width+ " getElementStyle = " + getElementStyle(el.id, "width", "width"));}
	
		el = getEl( 'JBcontent',x);
		if(el){ alert("robs func = " + getWidth(el.id) + " " + el.id+".offsetWidth = " +  el.offsetWidth+ " " + el.id + ".style.width = " + el.style.width+ " getElementStyle = " + getElementStyle(el.id, "width", "width"));}
	
		return;
	}

	//try to get the width of an element in px
	function getWidth(id)
	{
		//alert("in getWidth = " + id)
		var width=0;
		var el = getEl(id);
		if(!el){return 0;}
		if(document.layers){
			width = el.document.width;
			//alert("got layers width = " + width)
		}else{
			width = el.style ? el.style.width : el.width;		
		}
		//alert("width = " + width)
		if(!width||parseInt(width)==0){
			width= getElementStyle(el.id, "width", "width")		
			//alert("from getElementStyle = " + width)
		}
		s=width.toString().toLowerCase().replace(/\d+/,"")
		if(s=="auto"||s=="%"||!width||parseInt(width==0)){
			width = el.offsetWidth;
			//alert("use offset = "+ width)
		}else if(s=="pt"){
			width = 1.3333*parseInt(width)
			//alert("is pt = " + s.toLowerCase() + " convert to px = " + width)
		}else if(s=="em"){
			width = ConvertEmToPX(parseInt(width))
			//alert("is em = " + s.toLowerCase() + " convert to px = " + width)
		}
		//alert("return " + width)
		return width;
	}

	//try to get the width of an element in px
	function getHeight(id)
	{
		//alert("in height = " + id)
		var height=0;
		var el = getEl(id);
		if(!el){return 0;}
		if(document.layers){
			height = el.document.height;
		}else{
			height = el.style ? el.style.height : el.height;		
		}
		if(!height||parseInt(height)==0){
			height= getElementStyle(el.id, "height", "height")		
			//alert("from getElementStyle = " + height)
		}
		s=height.toString().toLowerCase().replace(/\d+/,"")
		if(s=="auto"||s=="%"||!height||parseInt(height==0)){
			height = el.offsetHeight;
			//alert("use offset = "+ height)
		}else if(s=="pt"){
			height = 1.3333*parseInt(height)
			//alert("is pt = " + s.toLowerCase() + " convert to px = " + height)
		}else if(s=="em"){
			height = ConvertEmToPX(parseInt(height))
			//alert("is em = " + s.toLowerCase() + " convert to px = " + height)
		}
		//alert("return " + height)
		return height;
	}

	function getEl(id,doc)
	{
		if(!doc) { doc = document; }
		if( doc.layers ) {
			if( doc.layers[id] ) { 
				return doc.layers[id]; 
			}else {
				for( var x = 0, y; !y && x < doc.layers.length; x++ ) {
					y = getEl(id,doc.layers[x].document); 
				}
				return y; 						
			}
		}else if(document.getElementById){
			return doc.getElementById(id)       
		}else if(document.all){
		   return doc.all[id];
		} 
		return document[id];
	}

	function ResizeWin(winX)
	{		
		//alert("in ResizeWin")		
		if(!winX) return; 
		//will try and access a div container called featuredjob first if not then JBcontent and then content
		var el = getEl( 'featuredjob', winX.document ); 
		if(!el){ el = getEl( 'content', winX.document ) };
		if(!el){ el = getEl( 'JBcontent', winX.document ) };
		if(!el) { DoDefResize(winX); return;} //could not find any known div containers so set to default size

		
		var oW = el.clip ? el.clip.width : el.offsetWidth; 
		var oH = el.clip ? el.clip.height : el.offsetHeight; //if( !oH ) { retu19/02/2008rn false; }		
		var fW = oW + 200;
		var fH = oH + 200;
		//alert("do first resize = " + (fW) + ", " + (fH));
		winX.resizeTo(fW,fH);
		if( winX.focus ) { winX.focus(); }
		//alert("after first")			
		var myW = 0, myH = 0, d = winX.document.documentElement, b = winX.document.body;				
		//alert("get style width for " + el.id)
		myW = getElementStyle(el.id, "width", "width", winX);
		//alert(el.id + " width = " + myW)
		if(parseInt(myW)>0){					
			if(myW.replace(/\d+/,"")=="em"){			
				myW = ConvertEmToPX(parseInt(myW),winX)			
			}
			if( winX.innerHeight ) {  myH = winX.innerHeight; }
			else if( d && d.clientHeight ) { myH = d.clientHeight; }
			else if( b && b.clientHeight ) { myH = b.clientHeight; }
		}else{
			if( winX.innerWidth ) { myW = winX.innerWidth; myH = winX.innerHeight; }
			else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }
			else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }
			if( window.opera && !document.childNodes ) { myW += 16; }
		}
		oW = parseInt(oW);oH = parseInt(oH);myW = parseInt(myW);myH = parseInt(myH);
		var nW = oW + ( (oW + 200) - myW );
		var nH = oH + ( (oH + 200) - myH );
		//alert("2nd resize " + win.name + " to " + nW +" , " + nH)
		//win.focus();	
		//if(IsIE)nW+=500;
	
		nW = parseInt(nW)
		nH = parseInt(nH)
		
		winX.resizeTo(nW,nH);	
		
		//alert("after 2nd resize")
		if( winX.focus ) { winX.focus(); }
		var scW = screen.availWidth ? screen.availWidth : screen.width;
		var scH = screen.availHeight ? screen.availHeight : screen.height;							
		//move to middle of window
		//alert("move now")
		winX.moveTo(Math.round((scW-nW)/2),Math.round((scH-nH)/2));	
		return false
		
	}
	
	//func is used when we cannot access dimensions of container divs on the pop up page itself to create sizes
	//so instead we use the dimensions of the window that opened the popup
	function DoDefResize(winX)
	{			
		if(!winX) return;	
		var myWidth = 0, myHeight = 0;
		var myWidth = 0, myHeight = 0;			
		if( typeof( winX.innerWidth ) == 'number' ) { 
			// all except Explorer				
			myWidth = winX.innerWidth;
			myHeight = winX.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = winX.document.documentElement.clientWidth;
			myHeight = winX.document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = winX.document.body.clientWidth;
			myHeight = winX.document.body.clientHeight;
		}						
		//if big dimensions cut size down else if already a small window leave as be
		if(myWidth>=1000){myWidth=myWidth-300;}else if(myWidth>=800){myWidth=myWidth-200;}else if(myWidth>=500){myWidth=myWidth-100;}
		if(myHeight>=1000){myHeight=myHeight-300;}else if(myHeight>=800){myHeight=myHeight-200;}else if(myHeight>=500){myHeight=myHeight-100;}	
		winX.resizeTo((myWidth), (myHeight));			
		var scW = screen.availWidth ? screen.availWidth : screen.width;
		var scH = screen.availHeight ? screen.availHeight : screen.height;			
		winX.focus();		
		//move to middle of window
		winX.moveTo(Math.round((scW-myWidth)/2),Math.round((scH-myHeight)/2));			
	}

	function WinParam(p){if(p=="off" || p=="no" || p=="0" || p==0){return false;}else if(p=="on" || p=="yes" || p=="1" || p==1){return true;}else if(p){return true;}else{return false;}}


	//full comprehensive win opener
	function OpenNewWin(strName,Width,Height,TOP,LEFT,Resizable,Status,Scrollbars,Titlebar,ToolBar,MenuBar,URL,TYPE,dArg)
	{
		//alert("in OpenNewWin")
		//showModalDialog is the inverse of window.open, if you don't pass any params in for attributes
		//it will take it that you want them on not off! So best to always set paramater values.
		
		if(TOP==0 && LEFT==0){
			LEFT=(screen.width)?(screen.width-Width)/2:100;
			TOP=(screen.height)?(screen.height-Height)/2:100;
		}
			
		if (TYPE=="modal" && document.all)
		{
			var sF=""
			var _rv
			sF+='unadorned:'+(WinParam(Titlebar)?'1;':'0;');
			sF+='help:'+(WinParam(ToolBar)?'1;':'0;');
			sF+='status:'+ (WinParam(Status)?'1;':'0;');
			sF+='scroll:'+(WinParam(Scrollbars)?'1;':'0;');
			sF+='resizable:'+ (WinParam(Resizable)?'1;':'0;');
			sF+=Width?'dialogWidth:'+Width+'px;':'';
			sF+=Height?'dialogHeight:'+(parseInt(Height)+(WinParam(Status)?42:0))+'px;':'';
			sF+=TOP?'dialogTop:'+TOP+'px;':'';
			sF+=LEFT?'dialogLeft:'+LEFT+'px;':'';
			if (TYPE=="modal"){		
				//alert("modal = " + sF)
				_rv=window.showModalDialog(URL,dArg?dArg:"",sF);
				if ("undefined" != typeof(_rv) )
					return _rv;
			}
		}else{
			var sF=""
			sF+=Width?'width='+Width+',':'';
			sF+=Height?'height='+Height+',':'';
			sF+=TOP?'top='+TOP+',':'';
			sF+=LEFT?'left='+LEFT+',':'';
			sF+='resizable='+ (WinParam(Resizable)?'1,':'0,');
			sF+='status='+ (WinParam(Status)?'1,':'0,');
			sF+='scrollbars='+(WinParam(Scrollbars)?'1,':'0,');
			sF+='titlebar='+(WinParam(Titlebar)?'1,':'0,');
			sF+='toolbar='+(WinParam(ToolBar)?'1,':'0,');
			sF+='menubar='+(WinParam(MenuBar)?'1,':'0,');		
			URL = URL?URL:'about:blank';
			strName = strName?strName.replace(/ /gi,""):'win';	//remove any gaps in the name for the window			
			//alert("window.open('" + URL + "','" + strName + "','" + sF + "')");
			_rv = window.open(URL,strName,sF)
			//alert(_rv + " - " + typeof(_rv))
			return _rv;
		}
	}
