/** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * 
 * 	Global App Functions
 * 
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
function GetPage(){
  return window.location.href;
}

function createCookie(c_name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else{
	  var expires = "";
	}
	if(document.location.href.substring(0,6).toLowerCase() == "https:"){
    document.cookie = c_name+"="+escape(value)+expires+"; path=/; secure;";
  }else{
    document.cookie = c_name+"="+escape(value)+expires+"; path=/;";
  }	
}

function readCookie(c_name) {
	var c_nameEQ = c_name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(c_nameEQ) == 0) return c.substring(c_nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(c_name) {
	createCookie(c_name,"",-1);
}

function validateNumericKeypress(evt)
{
  var charCode = (evt.which) ? evt.which : event.keyCode
  
  if (charCode > 31 && (charCode < 48 || charCode > 57)){
    return false;
  }

  return true;
}

function getTranslationSpanish(textStr){
  google.language.translate(textStr, 'es', 'en', function(result) {
    if (!result.error) {
      return result.translation;
    }else{
      return "";
    }
  });
}

//returns http://www.yorhealth.com/ or http://beta.www.yorhealth..com/ or http://localhost:9999/
function getDomainUrl(){
  var url = window.location.href;
  var splitArr = url.split("/");
  url = ""
  for (n = 0; n <= 2; n++) {
  	url += splitArr[n] + "/";
  }
  return url;
}








