function bos_share_facebook(url, title) {
	window.open('http://www.facebook.com/sharer.php?u='+url+'&t='+title,'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function bos_share_myspace(T, C, U, L)
{
	var targetUrl = 'http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + encodeURIComponent(T)
	+ '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
	window.open(targetUrl);
}


function stopError() {
  return true;
}

window.onerror=function()
{
	return true;
}

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];}
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("bos_cal_category.")==-1 || obj.bos_cal_category)) eval("obj."+theProp+"='"+theValue+"'");
}

function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' must contain a number.\\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\\n'; }
  } if (errors) alert('The following error(s) occurred:\\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/*//---------------------------------------------*/
/*// Name: ping_page()							 */
/*// Desc: Send Get Variables to page 			 */
/*//---------------------------------------------*/
function ping_page(pageLocation)
{
	var xmlHttp;

	try
	{
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not have the correct requirements to run this software, please contact support immediately");
				return false;
			}
		}
	}

	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{
			return true;
		}
	}

	xmlHttp.open("GET", pageLocation ,true);
	xmlHttp.send(null);
}

/*//---------------------------------------------*/
/*// Name: post_form_popBox()					 */
/*// Desc: POST form & load content				 */
/*//---------------------------------------------*/
function post_form_popBox (pageLocation, elementId, formId, width, height)
{
	var xmlHttp;
	var currentForm = document.getElementById(formId);
	var elementId2 = document.getElementById(elementId);


	if	(
			width != null &&
			width != undefined
		)
	{
		document.getElementById(elementId).style.width = width + "px";
		document.getElementById(elementId).style.marginLeft = "-" + width / 2 + "px";
	}

	if	(
			height != null &&
			height != undefined
		)
	{
		document.getElementById(elementId).style.height = height + "px";
		document.getElementById(elementId).style.marginTop = "-" + height / 2 + "px";
	}

	try
	{
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not have the correct requirements to run this software, please contact support immediately");
				return false;
			}
		}
	}

	xmlHttp.onreadystatechange = function()
	{
		if (xmlHttp.readyState < 4)
		{
			document.getElementById(elementId).innerHTML = '<div id="load"></div>';
		}
		else if(xmlHttp.readyState == 4)
		{
			document.getElementById(elementId).innerHTML = '<div id="close" onclick="popBoxClose();"></div>' + xmlHttp.responseText;

			realWidth = 400;
			realHeight = 400;

			if(document.getElementById('popBox').childNodes[1].tagName == 'FORM')
			{
				var parent = document.getElementById('popBox').childNodes[1];
				if(parent.childNodes[0].tagName == 'TABLE')
				{
					realWidth = parent.childNodes[0].offsetWidth;
					realHeight = parent.childNodes[0].offsetHeight;
				}
				else if(parent.childNodes[1].tagName == 'TABLE')
				{
					realWidth = parent.childNodes[1].offsetWidth;
					realHeight = parent.childNodes[1].offsetHeight;
				}
				else
				{
					realWidth = parent.childNodes[2].offsetWidth;
					realHeight = parent.childNodes[2].offsetHeight;
				}
			}
			else
			{
				realWidth = document.getElementById('popBox').childNodes[1].offsetWidth;
				realHeight = document.getElementById('popBox').childNodes[1].offsetHeight;
			}

			elementId2.style.width = realWidth + 'px';
			elementId2.style.height = realHeight + 'px';
			elementId2.style.marginLeft = '-' + Math.round((realWidth / 2)) + 'px';
			elementId2.style.marginTop = '-' + Math.round((realHeight / 2)) + 'px';

			if(document.forms.popBoxForm)
			{
				document.forms.popBoxForm[0].focus();
			}
		}
	}

	var postData = '';

	for (var i = 0; i < currentForm.elements.length; i++)
	{
		var thisElement = currentForm.elements[i];
		var elementType = thisElement.type;
		var elementName = thisElement.name;
		var elementValue = thisElement.value;

		if (elementType == 'text' || elementType == 'hidden' || elementType == 'textarea' || elementType == 'password')
		{
			postData = postData + '&' + elementName + '=' + elementValue;
		}
		else if (
					elementType == 'checkbox' &&
					thisElement.checked == true
				)
		{
			postData = postData + '&' + elementName + '=' + elementValue;
		}
		else if (
					elementType == 'radio' &&
					thisElement.checked == true
				)
		{
			postData = postData + '&' + elementName + '=' + elementValue;
		}
		else if (
					elementType == 'select-one'
				)
		{
			postData = postData + '&' + elementName + '=' + elementValue;
		}
	}

	xmlHttp.open("POST", pageLocation, true);
	xmlHttp.setRequestHeader(
			'Content-Type',
			'application/x-www-form-urlencoded; charset=UTF-8'
		);
	xmlHttp.send(postData);

	return false;
}

/*//---------------------------------------------*/
/*// Name: post_form()							 */
/*// Desc: POST form & load content				 */
/*//---------------------------------------------*/
function post_form (pageLocation, elementId, formId, noCloseButton)
{
	var xmlHttp;
	var currentForm = document.getElementById(formId);

	try
	{
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not have the correct requirements to run this software, please contact support immediately");
				return false;
			}
		}
	}

	xmlHttp.onreadystatechange = function()
	{
		if (xmlHttp.readyState < 4)
		{
			document.getElementById(elementId).innerHTML = '<div id="loadGrey"></div>';
		}
		else if(xmlHttp.readyState == 4)
		{
			if (noCloseButton > 0)
			{
				document.getElementById(elementId).innerHTML = xmlHttp.responseText;
			}
			else
			{
				document.getElementById(elementId).innerHTML = '<div id="close" onclick="popBoxClose();"></div>' + xmlHttp.responseText;
			}
			document.forms.popBoxForm[0].focus();
		}
	}

	var postData = '';

	for (var i = 0; i < currentForm.elements.length; i++)
	{
		var thisElement = currentForm.elements[i];
		var elementType = thisElement.type;
		var elementName = thisElement.name;
		var elementValue = thisElement.value;

		if (elementType == 'text' || elementType == 'hidden' || elementType == 'textarea')
		{
			postData = postData + '&' + elementName + '=' + elementValue;
		}
		else if (
					elementType == 'checkbox' &&
					thisElement.checked == true
				)
		{
			postData = postData + '&' + elementName + '=' + elementValue;
		}
		else if (
					elementType == 'radio' &&
					thisElement.checked == true
				)
		{
			postData = postData + '&' + elementName + '=' + elementValue;
		}
		else if (
					elementType == 'select-one'
				)
		{
			postData = postData + '&' + elementName + '=' + elementValue;
		}
	}

	xmlHttp.open("POST", pageLocation, true);
	xmlHttp.setRequestHeader(
			'Content-Type',
			'application/x-www-form-urlencoded; charset=UTF-8'
		);
	xmlHttp.send(postData);

	return false;
}

function getInternetExplorerVersion()
{
	var rv = -1; // Return value assumes failure.
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
			rv = parseFloat( RegExp.$1 );
	}
	return rv;
}

function getElemntSize(elementid)
{
	var myWidth = 0;
	var myHeight = 0;
	var elem = document.getElementById(elementid);

	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	return { width : myWidth, height : myHeight};
}

function getSize()
{
	var myWidth = 0;
	myHeight = 0;

	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	return { width : myWidth, height : myHeight};
}

function returnObjById( id )
{
	if (document.getElementById)
		var returnVar = document.getElementById(id);
	else if (document.all)
		var returnVar = document.all[id];
	else if (document.layers)
		var returnVar = document.layers[id];
	return returnVar;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function bosOpenPopupWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function toggleDisplayStatus(n)
{
	if (document.getElementById(n))
	{
		if (document.getElementById(n).style.display == 'none')
		{
			document.getElementById(n).style.display = 'block';
		}
		else
		{
			document.getElementById(n).style.display = 'none';
		}
	}
}
