//Dreamweaver Behaviors

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.01
  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 && d.getElementById) x=d.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];}
}

//Preload main menu buttons
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

	MM_preloadImages('/resources/.template/images/nav-lodging-over.gif');
	MM_preloadImages('/resources/.template/images/nav-shopping-over.gif');
	MM_preloadImages('/resources/.template/images/nav-restaurants-over.gif');
	MM_preloadImages('/resources/.template/images/nav-outdoor-over.gif');
	MM_preloadImages('/resources/.template/images/nav-groups-over.gif');
	MM_preloadImages('/resources/.template/images/nav-press-over.gif');
	MM_preloadImages('/resources/.template/images/nav-contact-over.gif');



//newsletter sign-up (prepopulate form and validation)


function getPassedInfo(){
var queryString = window.top.location.search.substring(1);
var thankyou =getParameter(queryString,'thankyou');
if (thankyou !=null) {
var spanTag = document.getElementById('emailAddress');
spanTag.appendChild(document.createTextNode(thankyou));
return;
}
var value = getParameter(queryString, 'value');
if (value != null)
document.Signup.email.value = value;
var email = getParameter(queryString, 'email');
if (email != null)
document.Signup.email.value = email;
var firstName = getParameter(queryString, 'firstName');
if (firstName != null)
document.Signup.firstName.value = firstName;
var lastName = getParameter(queryString, 'lastName');
if (lastName != null)
document.Signup.lastName.value = lastName;
var title = getParameter(queryString, 'title');
if (title != null)
document.Signup.title.value = title;
var error = getParameter(queryString, 'error');
if (error != null)
setErrorMsg(error);
}
function setErrorMsg(error) {
	var pTag= document.getElementById('errorMessage');
	pTag.appendChild(document.createTextNode(error));

}

function getParameter ( queryString, parameterName ) {
   // Add "=" to the parameter name (i.e. parameterName=value)
   var parameterName = parameterName + "=";
   if ( queryString.length > 0 ) {
      // Find the beginning of the string
      begin = queryString.indexOf ( parameterName );
      // If the parameter name is not found, skip it, otherwise return the value
      if ( begin != -1 ) {
         // Add the length (integer) to the beginning
         begin += parameterName.length;
         // Multiple parameters are separated by the "&" sign
         end = queryString.indexOf ( "&" , begin );
      if ( end == -1 ) {
         end = queryString.length
      }
      // Return the string
      return unescape ( queryString.substring ( begin, end ) );
   }
   // Return "null" if no parameter has been found
   return null;
   }
}


function sendToNewPage() {
var text = document.getElementById('email').value;
var url = 'http://www.carolinabeachgetaway.com/secondary/enewsletter.php';
window.location = url + '?value='+text;
}

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
/* Modified to support Opera */
function bookmarksite(title,url){
	// Begin CrossComm modifications
	if(!title) {
		title = document.title;
	}
	if(!url) {
		url = document.URL;
	}
	// End CrossComm modifications
	if (window.sidebar) {// firefox
		window.sidebar.addPanel(title, url, "");
	} else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} else if(document.all) {// ie
		window.external.AddFavorite(url, title);
	} 
	// Begin CrossComm modifications
	else {// safari
		alert('To bookmark, press Cmd-D (Mac) or Ctrl-D (PC).');
	}
	// End CrossComm modifications
}
