/* ************************************************************************************************************************** */
/* ************************************************************************************************************************** */
/* JAVASCRIPT - js/common.js   */
/* ************************************************************************************************************************** */
/* ************************************************************************************************************************** */


/* The functions "meOnload()" and "meOnUnload()" exist here so we can have a call for onload and onunload in the template body tags. 
This version is only executed if the current page doesn't have a function of the same name */
function meOnload() {};
function meOnUnload() {};


/**/
// ROLLOVER FUNCTIONS *******************************************************************************************************
/**/
/**/
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) { //v3.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); 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];}
};
/**/
/**/
/**/
// STRING AND NUMBER FUNCTIONS **********************************************************************************************
/**/
/**/
// VALIDATE IS NUMBER *********************************************************************
function isNumber( aNum, delimit )   { 
	var isNum = true;
	if( !aNum  ||  aNum == "" )   return false;
	// Convert to a string for parsing purposes 
	aNum += "";
	// Allow for there to be a negative sign as the first character 
	if( aNum.substring( 0, 1) == "-" )   aNum = aNum.substring( 1, aNum.length); // Remove the first character
	// Allow for there to be a dollar sign as the first character 
	if( aNum.substring( 0, 1) == "$" )   aNum = aNum.substring( 1, aNum.length); // Remove the first character
	// Return false for any strings that don't pass the "isNaN" check:
	if( isNaN( parseInt( aNum) ) )   return false;
	// Return false for any strings that contain letters within them:
	if (delimit)	  {  // Allow for comma and decimal delimeters
		for( var i = 0; i < aNum.length; i++ ) {
			if( (aNum.charAt(i) < "0" || aNum.charAt(i) > "9") & (aNum.charAt(i) != "," ) & (aNum.charAt(i) != ".") ) {
				isNum = false;
				break;
			}
		}
	} else  {  // Purely numeric
		for( var i = 0; i < aNum.length; i++ ) {
			if( (aNum.charAt(i) < "0"  ||  aNum.charAt(i) > "9") ) {
				isNum = false;
				break;
			}
		}
	}
	return( isNum);
};
// TEST FUNCTION FOR RETURNED STRING VALUES STRING
function dspStringTest( str ) {
	var arr = new Array(16);  
	arr[0] = str + " \n";
	arr[1] = "Left - : " + left( str, "-");
	arr[2] = "Left ) : " + left( str, ")");
	arr[3] = "Left . : " + left( str, ".");
	arr[4] = "Left 4 : " + left( str, 4);
	arr[5] = "LeftBack - : " + leftBack( str, "-");
	arr[6] = "LeftBack ) : " + leftBack( str, ")");
	arr[7] = "LeftBack . : " + leftBack( str, ".");
	arr[8] = "LeftBack 4: " + leftBack( str, 4);
	arr[9] = "Right - : " + right( str, "-");
	arr[10] = "Right ) : " + right( str, ")");
	arr[11] = "Right . : " + right( str, ".");
	arr[12] = "Right 4: " + right( str, 4);
	arr[13] = "RightBack - : " + rightBack( str, "-");
	arr[14] = "RightBack ) : " + rightBack( str, ")");
	arr[15] = "RightBack . : " + rightBack( str, ".");
	arr[16] = "RightBack 4: " + rightBack( str, 4);
	alert ( implode( arr, " \n" ) );
};
// Left
// Searches str from left to right. The number of characters returned is determined by either a number or substring. (Updated 2-18-08 to accomodate "numberOfChars" as a parameter option.)
// Returns  A)  All characters to the left of the first occurrence of the specified substring...  OR ..  B) The leftmost specified number of characters
// Returns "" if parseAt is not found, or entire string (str) if the number is negative. ( Same logic as @Left )
// Examples:   left( "Mississippi", "s" ) = "Mi";  left( "Mississippi", 4 ) = "Miss"
function left( str, parseAt ) { 
	// Validate input parameters:
	if ( !str  ||  str == ""  ||   !parseAt )   return "";  // finish - verify that using !parseAt works properly for 0 passed as a number
	if ( isNumber( parseAt ) )   {
		n = parseAt;
		if ( n <= 0 )   return str;  // parseAt is negative, return entire string
	}
	else   {
		n = str.indexOf(parseAt);  // Find the first occurrence of the substring
		if ( n <= 0 )   return "";  // parseAt not found, return ""
	}
	if ( n <= 0 )   return "";
	else if ( n > String(str).length )   return str;
	else   	return String(str).substring( 0, n );		
};
// Left Back
// Searches str from right to left. The number of characters returned is determined by either a number or substring. (Updated 2-18-08 to accomodate "numberOfChars" as a parameter option.)
// Returns  A)  All characters to the left of the last occurrence of the specified substring...  OR ..  B) The leftmost characters up to the last specified number of chars to skip
// Returns "" if parseAt is not found or if the number is negative. ( Same logic as @LeftBack )
// Examples:   leftBack( "Mississippi", "s" ) = "Missis";  leftBack( "Mississippi", 4 ) = "Mississ"
function leftBack( str, parseAt ) {
	// Validate input parameters:
	if ( !str  ||  str == ""  ||   !parseAt )   return str;  // finish - verify that using !parseAt works properly for 0 passed as a number
	if ( isNumber( parseAt ) )   {
		n = parseAt;
		if ( n <= 0 )   return "";  // parseAt is negative, return ""
		else if ( n > String(str).length )   return str;
		else   return String(str).substring( 0, String(str).length - n );
	}
	else   {
		n = str.lastIndexOf(parseAt);  // Find the last occurrence of the substring
		if ( n <= 0 )   return "";  // parseAt not found, return ""
		else if ( n > String(str).length )   return str;
		else   return String(str).substring( 0, n );
	}
};
// Right
// Returns all characters to the right of the first occurrence of the specified substring.
// The number of characters returned is determined by either a number or substring. (Updated 2-18-08 to accomodate "numberOfChars" as a parameter option.)
// Returns  A)  All characters to the right of the first occurrence of the specified substring...  OR ..  B) The rightmost specified number of characters
// Returns "" if parseAt is not found, or entire string (str) if the number is negative. ( Same logic as @Right )
// Examples:   right( "Mississippi", "s" ) = "sissippi";  right( "Mississippi", 4 ) = "ippi"
function right( str, parseAt ) {
	// Validate input parameters:
	if ( !str  ||  str == ""  ||   !parseAt )   return "";  // finish - verify that using !parseAt works properly for 0 passed as a number
	if ( isNumber( parseAt ) )  {
		n = parseAt;
		if ( n <= 0 )   return str;  // parseAt is negative, return entire string
		else if ( n > String(str).length )   return str;
		else   	return String(str).substring( String(str).length - n, String(str).length );  // Keep the last n chars
	}
	else  {
		n = str.indexOf(parseAt);  // Find the first occurrence of the substring
		if ( n <= 0 )   return "";  // parseAt not found, return ""
		n = n + 1;  // Add 1 to exclude that char
		if ( n > String(str).length )   return str;
		else   	return String(str).substring( n, String(str).length );  // Start from the first occurence and go to the end
	}
};
// Right Back
// Searches str from right to left. The number of characters returned is determined by either a number or substring. (Updated 2-18-08 to accomodate "numberOfChars" as a parameter option.)
// Returns  A)  All characters to the right of the last occurrence of the specified substring...  OR ..  B) All remaining chars after skipping the first specified number of chars
// Returns "" if parseAt is not found or if the number is negative. ( Same logic as @RightBack )
// Examples:   rightBack( "Mississippi", "s" ) = "ippi";   rightBack( "Mississippi", 4 ) = "issippi"
function rightBack( str, parseAt ) {
	// Validate input parameters:
	if ( !str  ||  str == ""  ||   !parseAt )   return str;  // finish - verify that using !parseAt works properly for 0 passed as a number
	if ( isNumber( parseAt ) )   {
		n = parseAt;
		if ( n <= 0 )   return "";  // parseAt is negative, return ""
	}
	else   	{
		n = str.lastIndexOf(parseAt);  // Find the last occurrence of the substring
		if ( n <= 0 )   return "";  // parseAt not found, return ""
		n = n + 1;  // Add 1 to exclude that char
	}
	if ( n > String(str).length )   return str;
	else   return String(str).substring( n, String(str).length );  // Skip specified # chars (or start from the last occurrence) and go to the end		
};
/**/
/**/
/**/
// VISIBILITY and DISPLAY FUNCTIONS  *****************************************************************************************
/**/
/**/
function getDOM( objectID, withStyle ) {
	
	var isID = 0;
	var isAll = 0;
	var isLayers = 0;
	
	if (document.getElementById)
		isID = 1;
	else if (document.all)
		isAll = 1; 
	else {
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) 
			isLayers = 1; 
	}
	
	if ( withStyle == 1 ) {
		if (isID) {
			if(document.getElementById(objectID)) return (document.getElementById(objectID).style); 
			else return;
		}
		else if (isAll) { return (document.all[objectID].style); }
		else if (isLayers) { return (document.layers[objectID]); }
		else return;
	}  // with style 
	else {
		if (isID) {
			if(document.getElementById(objectID)) return (document.getElementById(objectID)); 
			else return;
		}
		else if (isAll) { return (document.all[objectID]); }
		else if (isLayers) { return (document.layers[objectID]); }
		else return;
	}  // without style 
};
/**/
/*  ********************  DISPLAY  ********************  */
/**/
function getDisplay( objectID ) {
	if ( !objectID ) return;
	var obj = getDOM(objectID,1); // 1 = with style (i.e. document.object.style )
	if ( !obj ) return;
	return obj.display;
};
function setDisplay( objectID, state ) {
	if ( !objectID ) return;
	var obj = getDOM(objectID,1); // 1 = with style (i.e. document.object.style )
	if ( !obj ) return;
	obj.display = state;
};
function toggleDisplay( objectID )   {
	if ( !objectID ) return;
	var obj = getDOM(objectID,1); // 1 = with style (i.e. document.object.style )
	var state = obj.display;
	if ( state != 'none' )
		obj.display = 'none';
	else
		obj.display = "";
};
/**/
/*  ********************  VISIBILITY  ********************  */
/**/
function getVisibility( objectID ) {
	if ( !objectID ) return;
	var obj = getDOM(objectID,1); // 1 = with style (i.e. document.object.style )
	if ( !obj ) return;
	return obj.visibility;
};
function setVisibility( objectID, state ) {
	if ( !objectID ) return;
	var obj = getDOM(objectID,1); // 1 = with style (i.e. document.object.style )
	if ( !obj ) return;
	obj.visibility = state;
};
function toggleVisibility( objectID ) {
	if ( !objectID ) return;
	var obj = getDOM(objectID,1); // 1 = with style (i.e. document.object.style )
	if ( !obj ) return;
	var state = obj.visibility;
	if ( state != 'hidden' )
		obj.visibility = 'hidden';
	else
		obj.visibility = "";
};
/**/
/**/
/**/
// JQUERY EFFECTS ************************************************************************************************************
/**/
/**/
/**/
function framedPhoto_loadEffect() {	
// JQUERY FUNCTION (Requires include of jquery-latest.pack.js and jqi-drop-scroll.js)
	/*
	if($.browser.msie) {
		//setVisibility( "framedPhoto", "visible" );
		$('#framedPhoto').css('visibility', 'visible');
	} else {
		$('#framedPhoto').DropInUp(1000).css('visibility', 'visible');	
	}
	*/
	$('#framedPhoto').DropInUp(2000);	
};
/**/
function showRandomFramedPhoto() {
	var oframedPhotoPhoto = getDOM( "framedPhotoPhoto", 0 );  // 0 = not with style (i.e. document.object )	
	if ( !oframedPhotoPhoto ) return;
	
	var rnd_no = Math.round( Math.random()*5 + 1 ); /* Whole #s between 1 and 6 inclusive */
	/* Image suffixes _1 to _6 */
	
	$('#framedPhotoPhoto').attr("src", pathPrefix + "img/Portfolio_Concept_Exterior_22CCW_" + rnd_no + ".gif" );
	
	//oframedPhotoPhoto.src = pathPrefix + "img/Portfolio_Concept_Exterior_22CCW_" + rnd_no + ".gif"; 
	//setVisibility( "framedPhotoPhoto", "visible" );
};
/**/
/**/
/**/
// NS RESIZE FIX *************************************************************************************************************
/**/
/**/
if (document.layers) {
	origWidth = innerWidth;
	origHeight = innerHeight;
};
function reloadPage() {
	if (innerWidth != origWidth  ||  innerHeight != origHeight)   location.reload();
};
if (document.layers) onresize = reloadPage;
/**/
/**/
/**/
// FORMS and FIELDS *************************************************************************************************************
/**/
/**/
// REPLACE SUBSTRING *********************************************************************
function replaceSubstring (inputString, badString, goodString, caseSensitive) {
	newStr= "";
	UI = inputString;
	UB = badString;
 	if(( caseSensitive != 1) && (caseSensitive != true)) {
		UI = inputString.toUpperCase();
		UB = badString.toUpperCase();
	}
   	badEnd = -1;
   	badLoc = UI.indexOf(UB);
  	 if( badLoc != -1) {
      		for (x=1; (badLoc != -1); x++) {
         			newStr = newStr + inputString.substring((badEnd + 1), badLoc) + goodString;
         			badEnd = badLoc + UB.length - 1;
         			badLoc = UI.indexOf(UB, (badLoc + 1)); 
		}
      		newStr = newStr + inputString.substring((badEnd + 1), inputString.length); 
	} else
		newStr = inputString;  
	return( newStr);
};
/**/
/**/
// LIST FIELD  - Get the values of the selected indexes  ******************************************************************
function getSelectedValues( objSelect, skipOne ) {
	// Always check that an object is initialized before using its methods or properties:
	if( !objSelect )   return( null );
	if( !objSelect.options )  {
		if( objSelect.value != "" )  return objSelect.value;
	}
	if( !skipOne  ||  skipOne+"" == "undefined"  ||  skipOne+""== "" )   skipOne = false;
	
	// Set up variables:
	var selectVals = new Array();  // stores return values
	var index =  0; // the options index to start with
	
	// Loop through all the options in the select object, and store the selected ones in the array:
	start = 0;
	if( skipOne == true )   start = 1;		
	
	var x = 0;
	for( var i = start ; i <  objSelect.length ; i++) { 
		curOption = objSelect.options[i];
		if( curOption.selected ) {
			selectVals[x] = curOption.value;
			x++;
		}
	}
	return( selectVals );
};
/**/









<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->


function preventRightClick(e) {
	var msg = "Sorry, you don't have permission to right-click.";	
	
	if (navigator.appName == 'Netscape' && e.which == 3) {
		alert(msg);
		return false;
	}
	if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
		alert(msg);
		return false;
	}
	else return true;
};

function loadPreventRightClick() {
	if(document.images) {
		for(i=0;i<document.images.length;i++)  {
			document.images[i].onmousedown = preventRightClick;
			document.images[i].onmouseup = preventRightClick;
    	}
	}
};


