/*
  Google Map API Keys:

    agingpro.idacreative.com: ABQIAAAAvF__JDl-mlApuYax3nc69RSPu7PaRK3zRHDGFPscXYmIJh9ZDhQlcOWX-37Y_uRmJGNtN-YvpVsfzQ

    staging.agingpro.com: ABQIAAAAvF__JDl-mlApuYax3nc69RSsekFRL4CUnn98u8WjXbA7muaLRhStb4n1Fa6QaANeGYgJiJ5JDe8Vjg

    www.agingpro.com: ABQIAAAAvF__JDl-mlApuYax3nc69RQxtnSN9AkEqEvHymrE0G57iIs_dxSHB1oXwJezYwOevcwub40ajErLwg
*/

/* SOURCE FILE: AnchorPosition.js */
function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false, use_css=false, use_layers=false;if(document.getElementById){use_gebi=true;}else if(document.all){use_css=true;}else if(document.layers){use_layers=true;}if(use_gebi && document.all){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_gebi){var o=document.getElementById(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}else if(use_css){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent) != null){ol += el.offsetLeft;}return ol;}
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;}
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;}

function showBG(divID)
{
	document.getElementById(divID).style.backgroundPosition = '0 -58px';
}
function hideBG(divID) {
	document.getElementById(divID).style.backgroundPosition = '0 0';
}

function showDiv(divID,anchorID,offsetY,offsetX)
{
	if(offsetY == null) {offsetY = 44;}
	if(offsetX == null) {offsetX = 0;}
	var cords = getAnchorPosition(anchorID);
	var newTop = (Number(cords.y) + offsetY);
	var posTop = newTop+'px';
	var newLeft = (Number(cords.x) - offsetX);
	var posLeft = newLeft+'px';
	document.getElementById(divID).style.position = 'absolute';
	document.getElementById(divID).style.top = posTop;
	document.getElementById(divID).style.left = posLeft;
	document.getElementById(divID).style.display = 'block';
}

function hideDiv(day) {
	document.getElementById(day).style.display='none';
}

function showFeatured(id)
{
	if(id=='PMF')
	{
		document.getElementById('featured').innerHTML = '<div id="PMF"><img src="images/featured_planning.gif" border="0" usemap="#m_featured_planning" /><map name="m_featured_planning" id="m_featured_planning"><area shape="circle" coords="87,267, 55" href="pmf.php" alt="" /></map></div>';	
		document.getElementById('featuredNav').innerHTML = '<li id="careGivers"><a href="#" style="width:104px;background:url(\'./images/featured_nav.gif\') top left no-repeat;background-position:0px 0px;" onClick="showFeatured(\'FCG\'); return false;"></a></li><li id="carePros"><a href="#" style="width:135px;background:url(\'./images/featured_nav.gif\') top left no-repeat;background-position:-104px 0px;" onClick="showFeatured(\'CP\'); return false;"></a></li><li id="carePlanners"><a href="#" style="width:133px;background:url(\'./images/featured_nav.gif\') top left no-repeat;background-position:-239px 0px;" onClick="showFeatured(\'PMF\'); return false;"></a></li>';	
	}
	else if(id=='CP')
	{
		document.getElementById('featured').innerHTML = '<div id="CP"><img src="images/featured_carepros.gif" border="0" usemap="#m_featured_carepros" /><map name="m_featured_carepros" id="m_featured_carepros"><area shape="circle" coords="87,267, 55" href="cp.php" alt="" /></map></div>';	
		document.getElementById('featuredNav').innerHTML = '<li id="careGivers"><a href="#" style="width:104px;background:url(\'./images/featured_nav_2.gif\') top left no-repeat;background-position:0px 0px;" onClick="showFeatured(\'FCG\'); return false;"></a></li><li id="carePros"><a href="#" style="width:135px;background:url(\'./images/featured_nav_2.gif\') top left no-repeat;background-position:-104px 0px;" onClick="showFeatured(\'CP\'); return false;"></a></li><li id="carePlanners"><a href="#" style="width:133px;background:url(\'./images/featured_nav_2.gif\') top left no-repeat;background-position:-239px 0px;" onClick="showFeatured(\'PMF\'); return false;"></a></li>';	
	}
	else if(id=='FCG')
	{
		document.getElementById('featured').innerHTML = '<div id="fCG"><img src="images/featured_caregivers.gif" border="0" usemap="#m_featured_caregivers" /><map name="m_featured_caregivers" id="m_featured_caregivers"><area shape="circle" coords="87,267, 55" href="fcg.php" alt="" /></map></div>';	
		document.getElementById('featuredNav').innerHTML = '<li id="careGivers"><a href="#" style="width:104px;background:url(\'./images/featured_nav_1.gif\') top left no-repeat;background-position:0px 0px;" onClick="showFeatured(\'FCG\'); return false;"></a></li><li id="carePros"><a href="#" style="width:135px;background:url(\'./images/featured_nav_1.gif\') top left no-repeat;background-position:-104px 0px;" onClick="showFeatured(\'CP\'); return false;"></a></li><li id="carePlanners"><a href="#" style="width:133px;background:url(\'./images/featured_nav_1.gif\') top left no-repeat;background-position:-239px 0px;" onClick="showFeatured(\'PMF\'); return false;"></a></li>';	
	}
}

function setFontSize()
{
	var div = document.getElementsByTagName('div');
	for(i=0;i<div.length;i++) 
	{
		if(div[i].id == 'txt1') { div[i].style.fontSize = '12px'; }
		if(div[i].id == 'txt2') { div[i].style.fontSize = '14px'; }
		if(div[i].id == 'txt3') { div[i].style.fontSize = '16px'; }
		if(div[i].id == 'txt4') { div[i].style.fontSize = '18px'; }
	}
}
function decFontSize()
{
	// txt1
	var div = document.getElementsByTagName('div');
	for(i=0;i<div.length;i++) 
	{
		if(!div[i].style.fontSize) 
		{
			div[i].style.fontSize = '12px';
		} 
		if(div[i].id == 'txt1') // 12px
		{
			var txtSize = div[i].style.fontSize;
			if(txtSize == '14px') { div[i].style.fontSize = '12px'; }
			if(txtSize == '16px') { div[i].style.fontSize = '14px'; }
			if(txtSize == '18px') { div[i].style.fontSize = '16px'; }
		}
		else if(div[i].id == 'txt2') // 14px
		{
			var txtSize = div[i].style.fontSize;
			if(txtSize == '16px') { div[i].style.fontSize = '14px'; }
			if(txtSize == '18px') { div[i].style.fontSize = '16px'; }
			if(txtSize == '20px') { div[i].style.fontSize = '18px'; }
		}
		else if(div[i].id == 'txt3')// 16px
		{
			var txtSize = div[i].style.fontSize;
			if(txtSize == '18px') { div[i].style.fontSize = '16px'; }
			if(txtSize == '20px') { div[i].style.fontSize = '18px'; }
			if(txtSize == '22px') { div[i].style.fontSize = '20px'; }
		}
		else if(div[i].id == 'txt4')// 18px
		{
			var txtSize = div[i].style.fontSize;
			if(txtSize == '20px') { div[i].style.fontSize = '18px'; }
			if(txtSize == '22px') { div[i].style.fontSize = '20px'; }
			if(txtSize == '24px') { div[i].style.fontSize = '22px'; }
		}
   }
}
function incFontSize()
{
	// txt1
	var div = document.getElementsByTagName('div');
	for(i=0;i<div.length;i++) 
	{
		if(!div[i].style.fontSize) 
		{
			div[i].style.fontSize = '12px';
		} 
		if(div[i].id == 'txt1') // 12px
		{
			var txtSize = div[i].style.fontSize;
			if(txtSize == '12px') { div[i].style.fontSize = '14px'; }
			if(txtSize == '14px') { div[i].style.fontSize = '16px'; }
			if(txtSize == '16px') { div[i].style.fontSize = '18px'; }
		}
		else if(div[i].id == 'txt2') // 14px
		{
			var txtSize = div[i].style.fontSize;
			if(txtSize == '14px') { div[i].style.fontSize = '16px'; }
			if(txtSize == '16px') { div[i].style.fontSize = '18px'; }
			if(txtSize == '18px') { div[i].style.fontSize = '20px'; }
		}
		else if(div[i].id == 'txt3') // 16px
		{
			var txtSize = div[i].style.fontSize;
			if(txtSize == '16px') { div[i].style.fontSize = '18px'; }
			if(txtSize == '18px') { div[i].style.fontSize = '20px'; }
			if(txtSize == '20px') { div[i].style.fontSize = '22px'; }
		}
		else if(div[i].id == 'txt4') // 18px
		{
			var txtSize = div[i].style.fontSize;
			if(txtSize == '18px') { div[i].style.fontSize = '20px'; }
			if(txtSize == '20px') { div[i].style.fontSize = '22px'; }
			if(txtSize == '22px') { div[i].style.fontSize = '24px'; }
		}
   }
}

// AJAX FOR RATING SYSTEM - IN SPANISH FOR ALL YOUR BILINGUAL FOLKS
function datosServidor() {
};
datosServidor.prototype.iniciar = function() {
	try {
		// Mozilla / Safari
		this._xh = new XMLHttpRequest();
	} catch (e) {
		// Explorer
		var _ieModelos = new Array(
		'MSXML2.XMLHTTP.5.0',
		'MSXML2.XMLHTTP.4.0',
		'MSXML2.XMLHTTP.3.0',
		'MSXML2.XMLHTTP',
		'Microsoft.XMLHTTP'
		);
		var success = false;
		for (var i=0;i < _ieModelos.length && !success; i++) {
			try {
				this._xh = new ActiveXObject(_ieModelos[i]);
				success = true;
			} catch (e) {
				// Implementar manejo de excepciones
			}
		}
		if ( !success ) {
			// Implementar manejo de excepciones, mientras alerta.
			return false;
		}
		return true;
	}
}

datosServidor.prototype.ocupado = function() {
	estadoActual = this._xh.readyState;
	return (estadoActual && (estadoActual < 4));
}

datosServidor.prototype.procesa = function() {
	if (this._xh.readyState == 4 && this._xh.status == 200) {
		this.procesado = true;
	}
}

datosServidor.prototype.enviar = function(urlget,datos) {
	if (!this._xh) {
		this.iniciar();
	}
	if (!this.ocupado()) {
		this._xh.open("GET",urlget,false);
		this._xh.send(datos);
		if (this._xh.readyState == 4 && this._xh.status == 200) {
			return this._xh.responseText;
		}
		
	}
	return false;
}
// Este es un acceso rapido, le paso la url y el div a cambiar
function _gr(reqseccion,divcont) {
	remotos = new datosServidor;
	nt = remotos.enviar(reqseccion,"");
	document.getElementById(divcont).innerHTML = nt;
}
//Estas dos son para guardar
var urlBase = "updateRating.php?";
function rateProduct(rating,category,itemID,userID,redirectID,sitepath)  {
		remotos = new datosServidor;
		nt = remotos.enviar(sitepath+'ajax/updateRating.php?rating='+rating+'&itemID='+itemID+'&userID='+userID+'&category='+category);
		rating = (rating * 25) - 8;
		document.getElementById(redirectID).style.width = rating+'px';
		// document.getElementById('ratelinks').style.display = 'none';
		//document.getElementById('ratingtext').innerHTML = 'Thank you for your vote!';
}

function countWords(w,x,limit)
{
	var y=w.value;
	var r = 0;
	a=y.replace(/\s/g,' ');
	a=a.split(' ');
	for (z=0; z<a.length; z++) {if (a[z].length > 0) r++;}
	if(r>limit){x.style.color='#ff0000';} else {x.style.color='#009900';}
	x.value=r;
}

function checkWords(words,limit) {
  if (words.value > limit) {
    alert('Your description cannot be longer than '+limit+' words.\nPlease edit your description.');
    return false;
  }
  return true;
}

function showDirectoryDiv(elementid) {
  if (document.getElementById(elementid).style.display == "none") {
    document.getElementById(elementid).style.display = "block";
  }
  else {
    document.getElementById(elementid).style.display = "none";
  }
}
