				var video = new Array();
				onImage = '';
				function changeGalleryImage (newImage) {
					if (onImage != newImage) {
					
						if (onImage) {
							document.getElementById('gi'+ onImage).style.display = 'none';
							onImage = '';
						}
						if (newImage) {
							document.getElementById('gi'+ newImage).style.display = 'block';
							onImage = newImage;
						}
					}
				}



	function checkState (elm) {
		if (elm.value == 'Search') {
			elm.value = '';
			elm.className = 'kwdFldOn'
		} else {
			if (elm.value == '') {
				elm.value = 'Search';
				elm.className = 'kwdFld'
			}
		}
	}

	function fixHomePage () {
		// search
		//
//		top.alert(fix);
//

		groups = new Array();
		groups[0] = 'quickSearch';
		groups[1] = 'centerBlock1';
		groups[2] = 'centerBlock2';
		groups[3] = 'search';
		groups[4] = 'featuredProperty';
		
		for (i =0 ; i < groups.length; i++) {
			group = groups[i];
			
			elm = document.getElementById(group);
			
			offset = getDivOffset(group);
			
			elm.style.height = offset[1] +'px';

			
			parentElm = elm.parentNode;
			
			nelm = document.createElement('div');
	//		nelm.setAttribute('id',group +'2');
	//		nelm.setAttribute('class','blank');
			nelm.className = group +'2';
			nelm.style.position = 'absolute';
			nelm.style.top = offset[3] +'px';
			nelm.style.left = offset[2] +'px';
			nelm.style.width = offset[0] +'px';
			nelm.style.height = offset[1] +'px';
			nelm.innerHTML = elm.innerHTML
			elm.innerHTML = '';

			parentElm.appendChild(nelm);

	//		docElm = document.getElementById(group +'2');
			
	//		docElm.style.width = offset[0] +'px';
	//		docElm.style.height = offset[1] +'px';
	//		nelm.setAttribute('style','position:absolute;top:'+ offset[3] +'px;left:'+ (offset[2] - 30) +'px;width:'+ offset[0] +'px;height:'+ offset[1] +'px;');
	//		nelm.setAttribute('style','position:absolute;top:0px;left:-30px;width:'+ offset[0] +'px;height:'+ offset[1] +'px;');
			
	//		docElm.style.left = '-30px';
	//		docElm.style.visibility = 'visible';
			
	
		//	parentElm.appendChild(nelm);
					
		}

	
	}



	function addOnLoadEvent(func) {

	  var oldonload = window.onload;

	  if (typeof window.onload != 'function') {

		window.onload = func;

	  } else {

	//	top.alert(oldonload)
	//	top.alert(func)

		window.onload = function() {

		  if (oldonload) {
			oldonload();
		  }
		  eval (func +'()');

		}

	  }

	}

	function addOnUnloadEvent(func) {

	  var oldonunload = window.onunload;

	  if (typeof window.onunload != 'function') {

		window.onunload = func;

	  } else {

	//	top.alert(oldonload)
	//	top.alert(func)

		window.onunload = function() {

		  if (oldonunload) {
			oldonunload();
		  }
		  eval (func +'()');

		}

	  }

	}

	function loadModalView () {
	
		document.getElementById('workspace').innerHTML = "<center><table cellspacing=0 cellpadding=0 border=0 width=700 id='modalFrame'><tr><td align=center><div class='modalPadding'><div id='modalContent'><table cellspacing=0 cellpadding=0 border=0 width=670 height=200><tr><td align=center><div id='modalInnerContent'></div></td></tr></table></div><div id='modalOptions'><a href='javascript:hideModal()' id='closeModalButtom'></a><div id='customModalOptions'></div></div></td></tr></table></center>";
	
	
	}
	
	function showLoading () {
	
		document.getElementById('modalInnerContent').innerHTML = '<table cellspacing=0 cellpadding=0  border=0 width="670" height="200"><tr><td align=center><b>Submiting Request</b></tr></td></table>';
	
	}
	
	function submitRequest(form,frm) {
	
		httpCon.complete = displayPage;
		httpCon.url = 'Request_Quote.php';
		httpCon.input = parseForm(frm);


		showModal();

		showLoading();

		httpCon.get();
		
	
	}
	
	function submitEmailFriend(query) {
	
		httpCon.complete = displayPage;
		httpCon.url = 'email_friend.php';
		httpCon.input = query;


		showModal();

		showLoading();

		httpCon.get();
		
	
	}


	function quoteRequest(form,collection) {
	
		showModal();
		
		httpCon.complete = displayPage;
		httpCon.url = 'Request_Quote.php';
		httpCon.input = 'Collection='+ collection +'&sendthrough='+ form;
		httpCon.get();
	
	}
	
	function emailFriend(page) {
	
		showModal();
		
		httpCon.complete = displayPage;
		httpCon.url = 'email_friend.php';
		httpCon.input = 'page='+ page;
		httpCon.get();
	
	}
	
	function showFinishes () {
	
		showPage('ModelFinishes.htm');
	
	}
	
	function showDistressings () {
	
		showPage('ModelDistressings.htm');
	
	}

	function showPage (page) {
		
		showModal();
		
		httpCon.complete = displayPage;
		httpCon.url = page;
		httpCon.get();
	
	}

	function displayPage (responseObj) {

		var html = responseObj.lastResponse

		document.getElementById('modalInnerContent').innerHTML = html

		repositionDiv('workspace',100);

		document.getElementById('workspace').style.display = 'block';

/*
		currentOverall = document.getElementById('modalFrame').offsetWidth;
		currentContent = document.getElementById('modalContent').offsetWidth;
		
		currentDiff = (currentOverall - currentContent);
		
		contentHeight = document.getElementById('modalInnerContent').offsetHeight;
		contentWidth  = document.getElementById('modalInnerContent').offsetWidth;
		
//		document.getElementById('modalContent').style.height = ((contentHeight > 200) ? contentHeight : 200) +'px';
		
		document.getElementById('modalContent').style.width = (contentWidth > 670 ? contentWidth : 670) +'px';

		document.getElementById('modalFrame').style.width = ((contentWidth > 670 ? contentWidth : 670) + currentDiff) +'px';

		top.alert(contentWidth +':'+ currentDiff +':'+ ((contentWidth > 670 ? contentWidth : 670) + currentDiff))
*/
		resizeCover('modalCover');

	}







// Process FORM DATA
function parseForm (frm) {

	var string = '';

	for (i = 0; i < frm.elements.length; i++) {
		elm = frm.elements[i]
		if (elm.disabled) {
			// don't use, disabled element
		} else {
			if (elm.type == 'checkbox') {
				if (elm.checked) {
					string += '&'+ frm.elements[i].name +'='+ encodeURIComponent(frm.elements[i].value);
				}
			} else if (elm.type == 'radio') {
				if (elm.checked) {
					string += '&'+ frm.elements[i].name +'='+ encodeURIComponent(frm.elements[i].value);
				}
			} else if (elm.type == 'select') {
				if (elm.selectedindex >= 0) {
					string += '&'+ frm.elements[i].name +'='+ encodeURIComponent(frm.elements[i].options[elm.selectedIndex].value);
				}
			} else {
				string += '&'+ frm.elements[i].name +'='+ encodeURIComponent(frm.elements[i].value);
			}
		}
	}

	return string

}



/****

FORM FUNCTIONS

**/



/* VIEW LARGER */

	function newImage(arg) {
		if (document.images) {
			rslt = new Image();
			rslt.src = arg;
			return rslt;
		}
	
		//img_on	= newImage("/pics/index_nav/index_con.gif");
		//img_off	= newImage("/pics/index_nav/index_con.gif");
	}

	
function emailFriendSubmit()
{
	var string = 'You must enter ';
	var alert_message = '';
	frm = document.frm_email_friend;
	var sender_name = frm.sname.value;
	var sender_email = frm.semail.value;
	var friend_name = frm.fname.value;
	var friend_email = frm.femail.value;
	var message = frm.message.value;
	var url = frm.url.value;
	
	if (trimAll(sender_name) == "") 
	{	
		alert_message += string + " your name.\n";
	}
	if (trimAll(sender_email) == "") 
	{	
		alert_message += string + " your email.\n";
	}
	if (trimAll(friend_name) == "") 
	{	
		alert_message += string + " your friend's name.\n";
	}
	if (trimAll(friend_email) == "") 
	{	
		alert_message += string + " your friend's email.\n";
	}
	
	if(alert_message != '')
	{
		alert(alert_message);
		//return false;
	} else {
		submitEmailFriend('sname=' + encodeURIComponent(sender_name) + '&semail=' + encodeURIComponent(sender_email) +
						  '&fname=' + encodeURIComponent(friend_name) + '&femail=' + encodeURIComponent(friend_email) +
						  '&message=' + encodeURIComponent(message) + '&url=' + encodeURIComponent(url) + '&sendemail=1');
	}
}





/*  modal elements */

/* loads the custom modal view, must have modalContent where modal info is loaded */

	function loadModalView () {
	
		document.getElementById('workspace').innerHTML = "<a href='javascript:hideModal()' id='closeModal'>CLOSE X</a><div class=modalPadding><div id='modalContent'></div></div>";		
	
	}

/* clear out modal, change what needs to be changed for hiding */

	function hideModal () {
	
		document.getElementById('modalCover').className = 'coverOff';
		document.getElementById('modalContent').innerHTML = '';
		document.getElementById('workspace').style.visibility = 'hidden';
		document.getElementById('workspace').style.display = 'none';
	
	}


	function checkHeight () {
		top.alert(document.getElementById('innerFrame').innerHeight)
	}
	
	function getDivOffset (divId) {

		h = document.getElementById(divId).offsetHeight;
		w = document.getElementById(divId).offsetWidth;
		t = document.getElementById(divId).offsetTop;
		l = document.getElementById(divId).offsetLeft;

		return [w,h,l,t];
	}
	
	function modalVideo (videoId) {
		
		showModal();

		document.getElementById('modalContent').innerHTML = video[videoId];
				
		adjustModalContent();
		
	}
	
	function adjustModalContent () {
	
			sizes = getDivOffset('modalContent');
	
			fullSize = sizes[0] + 20;
	
			repositionDiv('workspace',120,20);
			centerDiv('workspace', (sizes[0] + 60) );
			document.getElementById('workspace').style.height = (sizes[1]+60) +'px';
	
			document.getElementById('workspace').style.visibility = 'visible';

	}
	
	function lossenModalContent () {
		document.getElementById('modalContent').style.height = 'auto';
		document.getElementById('modalContent').style.width = 'auto';
	}

	function resizeWorkspace () {
		
		w = imgElm.width;
		h = imgElm.height;

		centerDiv('workspace',(w+20));
		document.getElementById('workspace').style.height = (h+20) +'px';
		
	//	lossenModalContent();
		
		cover = document.getElementById('modalCover');
		contentElm = document.getElementById('modalContent');
		spinnerElm = document.getElementById('modalSpinner');
		spinnerElm.src = imgElm.src;
		spinnerElm.width = w;
		spinnerElm.height = h;
		
	//	adjustModalContent();

	}

	var imgElm = null;
	
	spinnerImg = new Image()
	spinnerImg.src = '/images/spinner_large.gif'

	function modalImage (imageUrl) {
	
		showModal();
		
		showSpinner();

//		document.getElementById('modalContent').innerHTML = "<center><img src=''></center>";
		
		imgElm = new Image()
		imgElm.onload = function () {
			resizeWorkspace();
		}
		imgElm.src = imageUrl;
	
	
	}

	function showSpinner () {

		centerDiv('workspace',100);
		repositionDiv('workspace',120,20);

		document.getElementById('workspace').style.height = 100 +'px';
		document.getElementById('workspace').style.visibility = 'visible';
		
		contentElm = document.getElementById('modalContent');

		spinElement = document.createElement('img');
		spinElement.setAttribute('id','modalSpinner');
		spinElement.setAttribute('src',spinnerImg.src);
		contentElm.appendChild(spinElement);
	
	}


	function innerPage (pageUrl,w,h) {
		
		showModal();
		
		centerDiv('workspace',w);
		repositionDiv('workspace',120,20);
		document.getElementById('workspace').style.height = h +'px';
		document.getElementById('workspace').style.visibility = 'visible';
		document.getElementById('modalContent').innerHTML = "<iframe src='"+ pageUrl +"' id='innerFrame' width='100%' height='"+ (h - 30) +"' frameborder=0 ></iframe>";
	
	}
	


/* no customize below */


/* create/show modal */

	function showModal () {
		
		if (!document.getElementById('modalCover')) {
			body  = document.getElementsByTagName('body');
			cover = document.createElement('div');
			cover.setAttribute('id','modalCover');
			cover.setAttribute('class','coverOn');
			cover.setAttribute('onClick','hideModal()');
			body[0].appendChild(cover);
		}

		document.getElementById('modalCover').className = 'coverOn';
		resizeCover('modalCover');

		
		if (!document.getElementById('workspace')) {
			body  = document.getElementsByTagName('body');
			workspace = document.createElement('div');
			workspace.setAttribute('id','workspace');
			workspace.setAttribute('align','center');
			body[0].appendChild(workspace);
		}

		document.getElementById('workspace').style.display = 'block'
	
		if (!document.getElementById('modalContent')) {
			loadModalView();
		}
		
	}

/* center the modal div (left/right), divId, finalWidth of your div, use left right with reposition below */

function centerDiv(objId,width)
{
	// get your main object
	obj = document.getElementById(objId);
	// get page position
	page_pos = getPagePosition();
	// get page size
	page_size = getPageSizeWithScroll();
	// determine the left position
	leftPos = ((page_size[0] - width)/2);
	if (leftPos < 0) leftPos = 0; 

	obj.style.width = width +'px';
	obj.style.left  = leftPos +'px';
	
//	top.alert(leftPos +':'+ width +':'+ page_size[0]);
}

/* reposition your modal div (up and down) , divId, minimum top offset, additional offset from current position */

function repositionDiv(objId,minDistance,plusDistance)
{

	obj = document.getElementById(objId);
	page_pos = getPagePosition();
	document.getElementById(objId).style.top = (page_pos[1] < minDistance ? minDistance : page_pos[1] + plusDistance) +'px';
	
}

/* resizing the cover object (send in id of the cover) */

function resizeCover (objId) {

	page_dims = getPageSizeWithScroll();
	document.getElementById(objId).style.height = page_dims[1]+'px';

}

/* getting the page size */

function getPageSizeWithScroll()
{
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	return arrayPageSizeWithScroll;
}


/* getting the position of the page */

function getPagePosition ()
{
  var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [ scrOfX, scrOfY ];
}
	