function generateIFrame() {
	// my modal iframe
	targetID	=	"mySearch";
	if(elm = document.getElementById(targetID)){
		if(newIFrame = document.createElement("IFRAME")){
			newIFrame.id = "myModalSearchFrame";
			newIFrame.frameborder = "0px";
			newIFrame.scrolling = "no";
			newIFrame.style.width = "300px";
			newIFrame.style.height = "440px";
			newIFrame.style.padding = "2px";
			newIFrame.style.background = "#FFFFFF";
			newIFrame.style.border = "1px solid #CDCDCD";
			newIFrame.style.zIndex = 100000;
			elm.appendChild(newIFrame);
		}
	}else{
	}
	externalLinks();
}

function externalLinks() {
	if (!document.getElementsByTagName){
		 return;
	}
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank";
		}
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "myModal"){
			/*
				"+anchor.getAttribute("href")+"
			*/
			anchor.setAttribute("href", "javascript:void(0);");
		}
	}
}


function fadeAlpha(objname,alphastart,alphaend,timesteps,steps,mode){


  		if (document.getElementById(objname)) {


			if(mode == "+"){
				// Show layer
				document.getElementById(objname).style.visibility = "visible";
			

				// Alpha = 0;
				document.getElementById(objname).style.filter = "Alpha(opacity=0, finishopacity=0, style=1)";
			}

			setAlpha(objname,alphastart,alphaend,timesteps,steps,mode);


			//mode = document.getElementById(divname).style.visibility;
  		}
}
function setAlpha (objname,alphastart,alphaend,timesteps,steps,mode){
  	if (document.getElementById) {
		document.getElementById(objname).style.filter = "Alpha(opacity=" + alphastart + ", finishopacity=" + alphastart + ", style=1)";
	}


	if(mode == "+"){
		alphastart = alphastart + steps;

		if(alphastart <= alphaend){
			string = 'window.setTimeout("setAlpha(\''+objname+'\','+alphastart+','+alphaend+','+timesteps+','+steps+',\''+mode+'\')",'+timesteps+')';
			eval(string);
		}
	}

	if(mode == "-"){
		alphastart = alphastart - steps;

		if(alphastart >= alphaend){
			string = 'window.setTimeout("setAlpha(\''+objname+'\','+alphastart+','+alphaend+','+timesteps+','+steps+',\''+mode+'\')",'+timesteps+')';
			eval(string);
		}else{
			
			document.getElementById(objname).style.visibility = "hidden";
		}
	}

}
function handleevent_mySearch(url){
	document.getElementById('myModalSearchFrame').src= url;
	positionSearch('mySearch');
	fadeAlpha("mySearch",0,100,30,5,"+");
}
function close_mySearch(){
	fadeAlpha("mySearch",100,10,30,5,"-");
}
function positionCenter(objectRef)
{

	if (document.getElementById) {
		var elem = document.getElementById(objectRef);
	}
	else if (document.layers && document.layers[objectRef]) {
		var elem = document.layers[objectRef];
	}
	else if (document.all) {
		var elem = document.all[objectRef];
	}
	
	if(elem.style.width){
		objectWidth = elem.style.width;
		objectWidth.replace(/\w/g,"");
		objectWidth = parseInt(objectWidth);
	}else{
		objectWidth = 0;
	}
	
	if(elem.style.height){
		objectHeight = elem.style.height;
		objectHeight.replace(/\w/g,"");
		objectHeight = parseInt(objectHeight);
	}else{
		objectHeight = 0;
	}


	if(window.event){

		if(document.documentElement.clientHeight){
			topposition  = Math.round(document.documentElement.scrollTop + (document.documentElement.clientHeight /2)) -Math.round((objectHeight / 2));
			leftposition = Math.round(document.documentElement.scrollLeft + (document.documentElement.clientWidth /2)) -Math.round((objectWidth / 2));

		}else{
			topposition  = Math.round(document.body.scrollTop + (document.body.clientHeight /2)) -Math.round((objectHeight / 2));
			leftposition = Math.round(document.body.scrollLeft + (document.body.clientWidth /2)) -Math.round((objectWidth / 2));
		}
		
	}else{
		//only executed by NC,Mozilla, this var is now the value of the top left corner even the user has scrolled down
		topposition  = Math.round(window.innerHeight + window.pageYOffset - (window.innerHeight / 2)) - Math.round((objectHeight / 2));
		leftposition = Math.round(window.innerWidth + window.pageXOffset - (window.innerWidth / 2)) - Math.round((objectWidth / 2));
	}

		var browser=navigator.appName
		if (browser=="Microsoft Internet Explorer"){
			topposition  = Math.round(document.documentElement.scrollTop + (document.documentElement.clientHeight /2)) -Math.round((objectHeight / 2));
			leftposition = Math.round(document.documentElement.scrollLeft + (document.documentElement.clientWidth /2)) -Math.round((objectWidth / 2));
		}
	
	elem.style.top = topposition+"px";
	elem.style.left = (leftposition - 180)+"px";
}
 function getEnter() {
	handleevent_mySearch('search_frame.aspx?q=' + encodeURI(document.getElementById('mapsearch').land2.value));
	return false;
}

var imgPos = 0
function slideit(){
	//window.status = document.getElementById('pic').style.backgroundimage//slideimages[imgPos]
	document.getElementById('pic').style.background='url('+slideimages[imgPos]+')'
	//window.status = document.getElementById('pic').style.background
	if (imgPos<slideimages.length-1)
		imgPos++
	else
		imgPos=0
		setTimeout("slideit()",5000)
}

function positionSearch(objectRef)
{

	if (document.getElementById) {
		var elem = document.getElementById(objectRef);
	}
	else if (document.layers && document.layers[objectRef]) {
		var elem = document.layers[objectRef];
	}
	else if (document.all) {
		var elem = document.all[objectRef];
	}
	
	elem.style.top = "100px";
	elem.style.left = "-1px";
}

