// Capucines Boulevard

// rollover 
function CI(ImageID, ImageSource)
	{	ImageID.src = ImageSource; }
	
// pop-up
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// pop-up ALT
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=570,left = 300,top = 250');");
}

// Clear Text Boxes
function CTB(Texbox, TextStr)
{	if(Texbox.value==TextStr)
		Texbox.value = '';	
}

function radioSelect()
{
		document.forma.Artist[1].checked = "checked"; 
}

function SelectBank(ID)
{
		document.forma.PaymentPreferenceID[ID].checked = "checked"; 
}

function doDelete(URL)
{	if (confirm("Do you want to delete this data?"))
		document.location.href = URL;	
}


// calculate strings
function StringLength(DestinationID, SourceID)
{	document.getElementById(DestinationID).value = document.getElementById(SourceID).value.length
}

function maxReached()
{	if (document.getElementById('Answer').value.length >= 8000)
		return false;
	else
		return true;
}

// Netscape resize
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


// Persistent layer
window.onerror = null;
	var topMargin = 0;
	var slideTime = 1200;
	var ns6 = (!document.all && document.getElementById);
	var ie4 = (document.all);
	var ns4 = (document.layers);

function layerObject(id,left)
{	if (ns6) {
		this.obj = document.getElementById(id).style;
		this.obj.left = left;
		return this.obj;
		}
	else if(ie4) {
		this.obj = document.all[id].style;
		this.obj.left = left;
		return this.obj;
		}
	else if(ns4) {
	this.obj = document.layers[id];
	this.obj.left = left;
	return this.obj;
	   }
}

function layerSetup() 
{
	floatLyr = new layerObject('floatLayer', pageWidth * 1);
	window.setInterval("main()", 1);
}

function floatObject()
{	if (ns4 || ns6) 
	{	findHt = window.innerHeight;
		} else if(ie4) 
	{	findHt = document.body.clientHeight;
   }
} 
function main()
{	if (ns4) 
	{	this.currentY = document.layers["floatLayer"].top;
		this.scrollTop = window.pageYOffset;
		mainTrigger();
	}
	else if(ns6)
		{	this.currentY = parseInt(document.getElementById('floatLayer').style.top);
			this.scrollTop = scrollY;
			mainTrigger();
}
	else if(ie4) 
		{	this.currentY = floatLayer.style.pixelTop;
			this.scrollTop = document.body.scrollTop;
			mainTrigger();
	   }
}

function mainTrigger()
{	var newTargetY = this.scrollTop + this.topMargin;
	if ( this.currentY != newTargetY ) {
	if ( newTargetY != this.targetY ) {
	this.targetY = newTargetY;
	floatStart();
	}
	animator();
   }
}

function floatStart()
{	var now = new Date();
	this.A = this.targetY - this.currentY;
	this.B = Math.PI / ( 2 * this.slideTime );
	this.C = now.getTime();
	if (Math.abs(this.A) > this.findHt) {
	this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
	this.A = this.A > 0 ? this.findHt : -this.findHt;
	}
	else {
	this.D = this.currentY;
	   }
}

function animator()
{	var now = new Date();
	var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D;
	newY = Math.round(newY);
	if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) {
	if ( ie4 )document.all.floatLayer.style.pixelTop = newY;
	if ( ns4 )document.layers["floatLayer"].top = newY;
	if ( ns6 )document.getElementById('floatLayer').style.top = newY + "px";
	   }
}

function start()
{
//	if(ns6||ns4) {
//	pageWidth = innerWidth;
//	pageHeight = innerHeight;
//	layerSetup();
//	floatObject();
//	}
//	else if(ie4) 
//	{	pageWidth = document.body.clientWidth;
//		pageHeight = document.body.clientHeight;
//		layerSetup();
//		floatObject();
//  }
}

theObjects = document.getElementsByTagName("object");
for (var i = 0; i < theObjects.length; i++) {
theObjects[i].outerHTML = theObjects[i].outerHTML;
}

// Send To A Friend Functionality
var request;
var forwardlink = 1;

function toggle(div,evt) {
	var emaildiv = document.getElementById(div);
	var parent = emaildiv.parentNode;
	var posx = 0;
	var posy = 0;
	
	if (emaildiv) {
		if (emaildiv.className == "on") {
			emaildiv.className = "off";
		} else {
			emaildiv.className = "on";
			if (evt) {
				if (evt.pageX) {
					posx = evt.pageX;
				} else if (evt.clientX) {
					posx = evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft);
				} else {
					posx = "10";
				}
				emaildiv.style.left = (posx - 20) + "px";
				if (evt.pageY) {
					posy = evt.pageY;
				} else if (evt.clientY) {
					posy = evt.clientY + (document.documentElement.scrollTop ?  document.documentElement.scrollTop : document.body.scrollTop);
				} else {
					posy = "10";
				}
				emaildiv.style.top = (posy - 10) + "px";
			}
		}
	}
}

function forwardlinkset(url) {
	forwardlink = escape(url);
}

function sendtoafriend() {
	var toname = document.getElementById("friendfield").value;
	var toemail = document.getElementById("friendemailfield").value;
	var fromname = document.getElementById("userfield").value;
	var fromemail = document.getElementById("useremailfield").value;
	var frommessage = document.getElementById("usermessage").value;
	var fromurl;
	if (forwardlink != 1) {
		fromurl = forwardlink;
	} else {
		fromurl = escape(location.href);
	}
	var fullurl = "http://www.capucinesboulevard.com/sendmail.aspx?FromName=" + fromname + "&FromEmail=" + fromemail + "&FromURL=" + fromurl + "&ToName=" + toname + "&ToEmail=" + toemail + "&FromMessage=" + frommessage;
	
	if (window.XMLHttpRequest && !(window.ActiveXObject)) {
		request = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if (request) {
		request.onreadystatechange = sendemail;
		request.open("POST", fullurl, true);
		request.send("");
	}
}

function sendemail() {
	if (request.readyState == 4) {
		if (request.status == 200) {
			var div = document.getElementById('emailpop');
			var status = div.lastChild;
			if (document.getElementById('sendstatus')) {
				div.removeChild(status);
			}
			var result = request.responseText;
			var resulttext = document.createTextNode(result);
			var resultspan = document.createElement('div');
			resultspan.setAttribute('id','sendstatus');
			resultspan.appendChild(resulttext);
			div.appendChild(resultspan);
		} else {
			alert("Your email could not be sent.");
        }
    }
}