
var type = "IE";	//Variable used to hold the browser name

BrowserSniffer();

//detects the capabilities of the browser
function BrowserSniffer() 
{
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById)
	{
		 type="OP";		//Opera
	}
	else if (document.all) 
	{
		 type="IE";		//Internet Explorer e.g. IE4 upwards
	}
	else if (document.layers)
	{
		 type="NN";		//Netscape Communicator 4
	}
	else if (!document.all && document.getElementById) 
	{
		 type="MO";		//Mozila e.g. Netscape 6 upwards
	}
	else
	{ 
		 type = "IE";	//I assume it will not get here
	}
}


//Change the color of the layer background
//id is the name of the layer
//color is the required color
//Works with all browsers except NN4
function ChangeBgColor(id, color, cur )
{
	if (type=="IE") 
	{
		document.all[id].style.backgroundColor=color;
		document.all[id].style.cursor = cur;
	}
	if (type=="NN") 
	{
		document.layer['id'].bgColor=color;
		document.layer['id'].cursor = cur;
	}
	if (type=="MO" || type=="OP") 
	{
		document.getElementById(id).style.backgroundColor=color;
		document.getElementById(id).style.cursor = cur;
	}
}

function CopyValue( from, to )
{
    if (document.getElementById)
    {
        // this is the way the standards work
        document.getElementById(to).value = document.getElementById(from).value;
        //style2.display = style2.display? "":"block";
    }
    else if (document.all)
    {
        // this is the way old msie versions work
        var style2 = document.all[whichLayer].style;
    }
    else if (document.layers)
    {
        // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
    }
    else
    {
		return;
    }
    
}

function openPhotoAlbum() 
{

	ChildForm = window.open('photostream.aspx','ChildForm','status=no,toolbar=no, menubar=no,titlebar=no,location=no,resizable=yes,scrollbars=yes,true');
								
	if (navigator.appName=='Microsoft Internet Explorer') 
	{
		ChildForm.location.reload();
	} 
}

var ChildForm = null;

function openPhoto( url, width, height ) 
{
	//if ( typeof(ChildForm)!='undefined')
	//{
	//	ChildForm.close();
	//}
	
	//if ( ChildForm && ChildForm.open && !ChildForm.closed)	
	//{
	//	ChildForm.document.SinglePhoto.InnerHtml= "<img src='" + "readPhoto.aspx?id=" + photoID + "' />";
	//}
	//else
	{
		ChildForm = window.open( url ,'ChildForm','status=no,toolbar=no, menubar=no,titlebar=no,location=no,resizable=yes,scrollbars=yes,true,width=' + width +',height=' + height);
								
		if (navigator.appName=='Microsoft Internet Explorer') 
		{
			//ChildForm.location.reload();
		} 
	}
}

function openChildWindow( url ) 
{
	var ChildForm = window.open( url ,'ChildForm','status=no,toolbar=no, menubar=no,titlebar=no,location=no,resizable=yes,scrollbars=yes,true');
								
	if (navigator.appName=='Microsoft Internet Explorer') 
	{
		ChildForm.location.reload();
	} 
}

function validateInteger( what, errorMsg )
{
	
	// XXX - debug
    if (!document.getElementById)
    {
		alert( "document.getElementById NOT supported" );		
		return;
	}
	var num = document.getElementById(what).value;
	
	if ( num.toString() == "" )
	{
		return true;
	}
	
	if ( parseInt(num).toString() == num )
	{	
		return true;
	}
	if ( errorMsg != "" )
	{
		alert( errorMsg );
		document.getElementById(what).value = "";
	}	
	event.cancelBubble = true; 
	
	return false;
}

function validateString( ctrl, maxLength, errorMessage )
{
	
	var ctrlString = document.getElementById(ctrl).value;

	if ( ctrlString.toString().length > maxLength )
	{	
		if ( errorMessage != "" )
		{
			alert( errorMessage );
		}
		event.cancelBubble = true; 
		return false;
	}
	
	return true;
}

function disableButton( message )
{
	if ( message != "" )
	{
		alert( message );
	}
	return false;
}

function ConfirmCheckbox( chkbox, message )
{
	if ( document.getElementById(chkbox).checked != false )
	{
		return confirm( message );
	}
}

function popupTerms( url ) 
{
	var windowprops = "width=600,height=650,top=100,left=200,scrollbars=yes";
	var myWin = window.open( url, "mynewwin", windowprops );
}



