
	function exec_refresh(waitMsg, sendLocation)
	{
		//alert(waitMsg+' - '+sendLocation);
		window.status = waitMsg;
		window.location = sendLocation;
			
	}

	
	function NewWindow(mypage,myname,w,h,pos,infocus){
	  var win=null;
	  if(pos=="random"){
		  
		myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	  
	  }
	  if(pos=="center"){
		  
	    myleft=(screen.width)?(screen.width-w)/2:100;
		mytop=(screen.height)?(screen.height-h)/2:100;
	  
	  }else if((pos!='center' && pos!="random") || pos==null){
		myleft=0;
		mytop=20;
	  }
	  
	  settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	  win=window.open(mypage,myname,settings);
	  win.focus();
	}

	
	function launchLive() {
	  //props=window.open('http://www.localgoat.com/live', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=1, width=800, height=600');
	  NewWindow('http://www.localgoat.com/live','liveWindow','892','612','center','front');
}

	function changeDefaultImage(oldDiv, newDiv){
				//ajax_loadContent('Loading...','imgDiv_'+oldDiv,'../get/basic.php?what=changeDefaultImage&id=1234&new='+oldDiv+'&old='+newDiv);return false;
	document.getElementById('image_'+oldDiv).className = 'viewImages';
	document.getElementById('image_'+newDiv).className = 'viewImagesDefault';
    }


  function validateUnameURLSubmit(){ 
  //alert('Error: '+document.getElementById('eml').value);
	  if(document.getElementById('uname_url').value.length >= 6){
	  if(document.getElementById('uname_url').value.match(/\b[A-Z0-9_-]+\b/gi)){
		if(document.getElementById('uname_check').value != 'pass'){
		  return true;
		}else{
		  return false;
		}
	  }else{
	    return false;
	  }
	}else{
	  return false;
	}
  }
  
  function validateUnameURLInput(elmId){ 
    if(document.getElementById(elmId).value.length >= 6){
	  if(document.getElementById(elmId).value.match(/\b[A-Z0-9_-]+\b/gi)){
		if(document.getElementById('uname_check').value != 'pass'){
		  ajax_loadContent("Checking Username...", "unameURLMsg","includes/check/uname_url.php?uname="+document.getElementById(elmId).value);
		  document.getElementById(elmId).className = 'text_field';
		}else{
		  document.getElementById(elmId).className = 'required_text_field';
		}
	  }else{
	    document.getElementById(elmId).className = 'required_text_field';
	  }
	}else{
	  document.getElementById(elmId).className = 'required_text_field';
	}
  }
  
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 changeIngredStatus(elementId, elementClass){
	
	if(elementClass = 'mybar_ingredStatus_empty'){
		document.getElementById(elementId).className = 'mybar_ingredStatus_full';
	}else{
		document.getElementById(elementId).className = 'mybar_ingredStatus_empty';
	}
	alert(elementId+' and '+elementClass);
}

function toggleDivByName(elementName){
  

}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function CreateDIV(n) {
  var str = '';
  for (i=0; i<n; i++) {
//    str += '<DIV id="DB'+i+'" style="display:none; border: 1px solid blue">';
    str += '<DIV id="DB'+i+'" class="db">';
    str += 'FAQ question #'+(i+1)+'</DIV>';
  }
  document.write(str);
}  
function toggleIngreds(have,dont) {
	var hide, show, showDiv;
  if(!get_cookie("showIngreds") || get_cookie("showIngreds") == 'have'){
	set_cookie("showIngreds", "dont");
	hide = have; 
	show = dont;
	showDiv = 'dont';
  }else{
	set_cookie("showIngreds", "have");
	hide = dont; 
	show = have;
	showDiv = 'have'; 
  }
  
  for (s=0; s<show; s++) { 
    if(showDiv == 'dont'){
  		document.getElementById('ingred_dont_have'+s).style.display='block'; 
	}
	if(showDiv == 'have'){
		document.getElementById('ingred_have'+s).style.display='block';
	}
  }
  for (h=0; h<hide; h++) { 
    if(showDiv == 'dont'){
  		document.getElementById('ingred_dont_have'+h).style.display='none'; 
	}
	if(showDiv == 'have'){
		document.getElementById('ingred_have'+h).style.display='none';
	}
  }

} 

function getElementsByClass(node,searchClass,tag,showDiv,hideDiv) {
var classElements = new Array();
var els = node.getElementsByTagName(tag); // use "*" for all elements
var elsLen = els.length;
var pattern = new RegExp("\\b"+searchClass+"\\b");

  
for (i = 0, j = 0; i < elsLen; i++) {
 if ( pattern.test(els[i].className) ) {
 classElements[j] = els[i];
 	classElements[j].style.display = (classElements[j].style.display==''||classElements[j].style.display=='block')?'none':'block';
 j++;
 }
}
return classElements;
}

function toggleIngred(userId) {
	
	if(!get_cookie("showIngreds") || get_cookie("showIngreds") == 'have'){
			
		
		if(document.getElementById('removedIngredient').value == 'yes'){
			
			loadContentAndTrigger('Compiling list of Ingredients...','IngredientListDiv','/bar/get/ingreds/'+userId,'titleToNote.setup', false, false, false);
			ajax_loadContent('Updating your Drinks...<BR>this can take drunken hour (approx. a couple of moments)','myDrinksDiv','/bar/get/mybardata/'+userId+'/compile');
		
		}else{
			
			var el = getElementsByClass(document,'have','*');
			var elx = getElementsByClass(document,'dont','*');
			
		}
		set_cookie("showIngreds", "dont");
	}else{
		
		set_cookie("showIngreds", "have");
		
		if(document.getElementById('removedIngredient').value == 'yes'){
		
			loadContentAndTrigger('Compiling list of Ingredients...','IngredientListDiv','/bar/get/ingreds/'+userId+'/false','titleToNote.setup', false, false, false);
	
		}else{	
		
			var el = getElementsByClass(document,'have','*');
			var elx = getElementsByClass(document,'dont','*');
			
		}
		
	}
	
//alert(elx.length);
}
function toggleAlcohol(userId) {
	
	if(!get_cookie("showAlcohols") || get_cookie("showAlcohols") == 'have'){
			
		
		if(document.getElementById('removedAlcohol').value == 'yes'){
			
			loadContentAndTrigger('Compiling list of Alcohols...','AlcoholListDiv','/bar/get/alcohol/'+userId,'titleToNote.setup', false, false, false);
			ajax_loadContent('Updating your Drinks...<BR>this can take drunken hour (approx. a couple of moments)','myDrinksDiv','../bar/get/mybardata/'+userId+'/compile');
		
		}else{
			
			var el = getElementsByClass(document,'have','*');
			var elx = getElementsByClass(document,'dont','*');
			
		}
		set_cookie("showAlcohols", "dont");
	}else{
		
		set_cookie("showAlcohols", "have");
		
		if(document.getElementById('removedAlcohol').value == 'yes'){
		
			loadContentAndTrigger('Compiling list of Alcohols...','AlcoholListDiv','/bar/get/alcohol/'+userId+'/false','titleToNote.setup', false, false, false);
	
		}else{	
		
			var el = getElementsByClass(document,'have','*');
			var elx = getElementsByClass(document,'dont','*');
			
		}
		
	}
	
//alert(elx.length);
}


function changeClass(elementID, classpassed){
	document.getElementById(elementID).className=classpassed;
}

function setInputValue(elementID, Value){
	document.getElementById(elementID).value=Value;
	//alert(document.getElementById(elementID).value);
}

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
