// JavaScript Document

//' Pops up a new window at the upper left of screen
function PopIt(page, widthVal, heightVal, leftPos, topPos){ 
	
    var newWnd = window.open( page, 'popupWindow', 'status,resizable,scrollbars,width=' + widthVal + ',height=' + heightVal + ',left=' + (leftPos) + ',top=' + (topPos) + '', true ); 
    newWnd.focus(); 
}

//Validate positive quote length.
function ValidateTitleLength(quote)
{
	var divError=document.getElementById("divError");
	var divCharCount=document.getElementById("divCharCount");
	
	divCharCount.innerText="Character Typed :" + quote.length  ;
	if (quote.length>150)
	{		
		divError.innerText="Memorial title length can not be longer than 150 characters.";	
		divCharCount.style.color="#FF0000";
	}
	else
	{	divCharCount.style.color="#000000";
		divError.innerText="";
	}
	
}

//Validate the memorial tribute length.
function ValidateTributeLength(tribute)
{
	var divMessage=document.getElementById("divMessage");
	divMessage.style.color="#000000";
	divMessage.innerText="Characters typed :" + tribute.length;
	
	if (tribute.length>500)
	{	
		divMessage.innerText="Memorial tribute can not be longer than 500 characters.";
		divMessage.style.color="#FF0000";
	}
	

}

//function OpenMemorialDonationWindow(url,memorialId,kinteraImageUrl,windowTitle)
function OpenMemorialDonationWindow(url)
{
	window.open ( url ,'',"menubar=1,toolbar=0,location=1,resizable=1,status=1,scrollbars=1,width=700,height=700"); 
}



//Trap the enter key press to submit the search queary in the findmemorial page.
function fnTrapKeyDown(btn, event)
	{
	
		if (document.all)
		{
			if  (event.keyCode == 13)
			{
				event.returnValue=false;
				event.cancel = true;
				btn.click();
			}
		}
		else if (document.getElementById)
		{
			if (event.which == 13)
			{	
				event.returnValue=false;
				event.cancel = true;
				btn.click();
			}
		}
		else if(document.layers)
		{
			if(event.which == 13)
			{	
				event.returnValue=false;
				event.cancel = true;
				btn.click();
			}
		}
	}
	

	
//swap the images 
//Usage: It is used to swap the images of the memorial creation nevigation buttons upon MouseOver and MouseOut;  
function swapImages(buttonId,imageSrc)
{
	var imgButton=document.getElementById(buttonId);
	imgButton.src=imageSrc;
}

	



