function showHideLayer(sLayer,sStyle) 
{
	var sCommand, objLayer;
	
	if (navigator.appName == 'Netscape' && document.layers != null) { //NS
		objLayer = eval('document.layers[\'' + sLayer + '\']') ;
	
		if (objLayer) {
			objLayer.visibility = sStyle ;
		}
	} 
	else if (document.all != null) {    //IE

		objLayer = eval('document.all[\'' + sLayer + '\']') ;
		if (sStyle == 'show') {
			sCommand = 'visible' ;
		} else if (sStyle == 'hide') {
			sCommand = 'hidden' ;
		}
		if (objLayer) {
			objLayer.style.visibility = sCommand ;
		}            
	}
}
function jsTrim(sText) { 
    //Remove leading spaces
  
    while (sText.substring(0,1) == ' ') 
        sText = sText.substring(1, sText.length);

    //Remove trailing spaces 
    while (sText.substring(sText.length-1,sText.length) == ' ')
        sText = sText.substring(0, sText.length-1);
		
   return sText;
}
function submitGenericForm()
{
	document.frmGeneric.submit();
}
function replaceIt(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replaceIt(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
function jsDecimals(number, decimals) { 

	var iPos;
	var sfind;
	var sNumber;
	
	sNumber=jsTrim(number);
	
	iPos=sNumber.search('\\.') ;
	iLength=sNumber.length;
	
	if 	(decimals==0 && iPos >-1 )
	{
		return false;
	}
	else if ((iLength-iPos) > decimals+1 && iPos >-1)
	{
		return false;
	}
		
	return true;	
}
function checkInteger(txtAmount)
{
	if ((isNaN(txtAmount) == true) || (jsDecimals(txtAmount, 0) == false))
	{
		return false;
	}
	else
	{
		return true;
	}
}
function gotoPageNumberFromThumb()
{
	var pageNo='';
	if (jsTrim(document.frmGeneric.txtPageTo[0].value) != '')
	{
		if (checkInteger(document.frmGeneric.txtPageTo[0].value))
		{
			pageNo = document.frmGeneric.txtPageTo[0].value;
		}
	}
	else if (jsTrim(document.frmGeneric.txtPageTo[1].value) != '')
	{
		if (checkInteger(document.frmGeneric.txtPageTo[1].value))
		{

			pageNo = document.frmGeneric.txtPageTo[1].value;
		}	
	}
	if (pageNo != '')
	{
		sendPageNo(pageNo);
	}
}
function photoOpen(URL,Width,Height) {

	var theWindow = window.open(URL,'EPhotoSitePhotoWindow','menubar=yes,width=' + Width + ',height=' + Height + ',top='+screen.availTop+',left='+screen.availLeft+',resizable,scrollbars=yes');
	theWindow.focus();

}
function mapOpen(URL) {

	var theWindow = window.open("http://www.photopoints.com/main/gmap.aspx?ID=" + URL,'GoogleMap','menubar=no,width=750px,height=550px,top='+screen.availTop+',left='+screen.availLeft+',resizable,scrollbars=yes');
	theWindow.focus();

}
function sendAllSitePMessage(ID)
{		
	var sURLQuery = '?QS=' + ID;
		
	windowName = window.open('/main/myaccount/sendimmessage.aspx' + sURLQuery,'ReplyWindow','width=655,height=520,top='+screen.availTop+',left='+screen.availLeft+',resizable,scrollbars=1');
	windowName.focus();
	
}
function RADOnClientMouseOverHandler()
{
	RADchangeVis(true);		
}
function RADOnClientMouseOutHandler()
{
	RADchangeVis(false);
}
function RADchangeVis(hideIt)
{

	embeds = document.getElementsByTagName('embed');

	for (var i = 0; i < embeds.length; i++)
	{
		if (hideIt)
		{
			embeds[i].style.visibility = 'hidden';
		}
		else
		{
			embeds[i].style.visibility = 'visible';
		}
	}	
	embeds = document.getElementsByTagName('object');

	for (var i = 0; i < embeds.length; i++)
	{
		if (hideIt)
		{
			embeds[i].style.visibility = 'hidden';
		}
		else
		{
			embeds[i].style.visibility = 'visible';
		}
	}
}
