// Common Java Script functions



function hl(o){

	o.style.backgroundColor='#FFFF99';

	o.style.color='#333333';

}



function ll(o){

	o.style.backgroundColor='#FFFFCC';

	o.style.color='#666666';

}



function basketitems(action) {

	frm = document.entryform;

	frm.action.value = action;

	frm.submit();

}



function checknumeric(field,label,limit) {

	pattern = /^[0-9]*$/;

	if(pattern.test(field.value)==false)

	{

		alert(label + " must be a positive, numeric entry");

		field.value = 1;

	}

	else

	{

		if(field.value > limit)

		{

			alert("Value must be no greater than " + limit);

			field.value = limit;

		}

	}

}



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) { //v4.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);

  if(!x && document.getElementById) x=document.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 ViewPropertyImage(action, picid, picsrc, piclabel) {
	if (document.getElementById) {
		if ( document.images ) {
			if ( action == "prev" ) {
				imgNum--;
				if (imgNum < 0) {
					imgNum = imgLength - 1;
				}
			}
			else if ( action == "next" ) {
				imgNum++;
				if (imgNum >= imgLength) {
					imgNum = 0;
				}
			}
			else if ( action == "show" ) {
				imgNum = picid;
			}
			document.getElementById('main_image').src = picsrc;
			document.getElementById('main_image').alt = 'Picture ' + ( imgNum + 1 );
			document.getElementById('main_image_label').innerHTML = piclabel;
			document.getElementById('picCounter').innerHTML = '(' + ( imgNum + 1 ) + ' of ' + imgLength + ')';
			
			var superLink = "&nbsp;";
			if (supersizes != null) {
				var supersizeLink = supersizes[imgNum];
				if(supersizeLink != null && supersizeLink != "") {
				   document.getElementById('superimg').href = supersizeUri + '?uri=' + supersizeLink;
				   document.getElementById('superimg').title = 'enlarge image';
				   superLink = 'enlarge image';
				}
				else {
  			      document.getElementById('superimg').removeAttribute('href');
  			      document.getElementById('superimg').removeAttribute('title');
  			   }
			}
			document.getElementById('superSize').innerHTML = superLink;
		}
						
		if ( action == "show" ) {
			if ( document.getElementById ) {
				var imgElement = document.getElementById('imgTop');
				if ( imgElement && imgElement.scrollIntoView ){
					imgElement.scrollIntoView(1);
				}
			} 
			else {
				window.scrollTo(0,0);
			}
		}
		return false;
	}
	return true;
}

function show_floorplan(pFileName, pTitle, pCaption) {

// specify window parameters
  picWin = window.open("", "pic","width=500,height=700,status,scrollbars,resizable,screenX=20,screenY=40,left=20,top=40");

// wrote content to window
  picWin.document.write('<html><head><title>' + pTitle + '</title>');	
  picWin.document.write('<script language="JavaScript">');
  picWin.document.write('function rtclickcheck(keyp){ ');
  picWin.document.write('	if (navigator.appName == "Netscape" && keyp.which == 3){');
  picWin.document.write('	 	alert(message); ');
  picWin.document.write('		return false; ');
  picWin.document.write('	} ');
  picWin.document.write('	if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) {');
  picWin.document.write('	 	alert(message);'); 	
  picWin.document.write('		return false; ');
  picWin.document.write('	} ');
  picWin.document.write('} ');
  picWin.document.write('var message = "copyright ©2007 Whitestone";'); 
  picWin.document.write('document.onmousedown = rtclickcheck;');
  picWin.document.write('</script>');	
  picWin.document.write('</head>');	
  picWin.document.write('<BODY BGCOLOR=#FFFFFF TEXT=#333333 LINK=#333333 VLINK=#333333>');
  picWin.document.write('<center>');
  picWin.document.write('<font size=+3 face="Verdana, Arial, Helvetica, sans-serif"><b>' + pCaption + '</b></font><br>');
  picWin.document.write('<img src="' + pFileName + '">');
  picWin.document.write('<p><font face="Verdana, Arial, Helvetica, sans-serif">');
  picWin.document.write( '"' + pTitle + '" &copy;2007 Whitestone<br>');
  picWin.document.write('<p><font size=2><a href="javascript:window.print()">print floorplan</a></font></p>');
  picWin.document.write('<p><font size=2><a href="javascript:window.close()">close window</a></font></p>');
  picWin.document.write('</body></html>');
  picWin.document.close();	
	
// If we are on NetScape, we can bring the window to the front
	if (navigator.appName.substring(0,8) == "Netscape") picWin.focus();
}

function show_EPC(pFileName, pTitle, pCaption) {

// specify window parameters
  picWin = window.open("", "pic","width=700,height=500,status,scrollbars,resizable,screenX=20,screenY=40,left=20,top=40");

// wrote content to window
  picWin.document.write('<html><head><title>' + pTitle + '</title>');	
  picWin.document.write('<script language="JavaScript">');
  picWin.document.write('function rtclickcheck(keyp){ ');
  picWin.document.write('	if (navigator.appName == "Netscape" && keyp.which == 3){');
  picWin.document.write('	 	alert(message); ');
  picWin.document.write('		return false; ');
  picWin.document.write('	} ');
  picWin.document.write('	if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) {');
  picWin.document.write('	 	alert(message);'); 	
  picWin.document.write('		return false; ');
  picWin.document.write('	} ');
  picWin.document.write('} ');
  picWin.document.write('var message = "copyright ©2008 Whitestone Estate Agent";'); 
  picWin.document.write('document.onmousedown = rtclickcheck;');
  picWin.document.write('</script>');	
  picWin.document.write('</head>');	
  picWin.document.write('<BODY BGCOLOR=#FFFFFF TEXT=#333333 LINK=#333333 VLINK=#333333>');
  picWin.document.write('<center>');
  picWin.document.write('<font size=+3 face="Verdana, Arial, Helvetica, sans-serif"><b>' + pCaption + '</b></font><br>');
  picWin.document.write('<img src="' + pFileName + '">');
  picWin.document.write('<p><font face="Verdana, Arial, Helvetica, sans-serif">');
  picWin.document.write( '"' + pTitle + '" &copy; Whitestone Estate Agent<br>');
  picWin.document.write('<p><font size=2><a href="javascript:window.print()">print page</a></font></p>');
  picWin.document.write('<p><font size=2><a href="javascript:window.close()">close window</a></font></p>');
  picWin.document.write('</body></html>');
  picWin.document.close();	
	
// If we are on NetScape, we can bring the window to the front
	if (navigator.appName.substring(0,8) == "Netscape") picWin.focus();
}
