
function isMail(txt){ 
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	return filter.test(txt);
}

function isURL(txt){ 
	var filter  = /^http|https/;
	
	return filter.test(txt);
}

function right(str, n){
	/***
	IN: str - the string we are RIGHTing
			n - the number of characters we want to return
	
	RETVAL: n characters from the right side of the string
	***/
	
	if(n<=0) return ""; // Invalid bound, return blank string
	else if(n>String(str).length) return str; // Invalid bound, return entire string
	else { // Valid bound, return appropriate substring
		 var iLen=String(str).length;
		 return String(str).substring(iLen, iLen-n);
	}
}

function mid(str, start, len){
	/***
	IN: str - the string we are LEFTing
			start - our string's starting position (0 based!!)
			len - how many characters from start we want to get
	
	RETVAL: The substring from start to start+len
	***/
	// Make sure start and len are within proper bounds
	if(start<0 || len<0) return "";

	var iEnd, iLen=String(str).length;
	
	if(start+len>iLen) iEnd=iLen;
	else iEnd=start+len;

	return String(str).substring(start,iEnd);
}

var win = null;

function popup(url, nom, w, h, wscroll){
	pleft=(screen.width) ? (screen.width-w)/2 : 0;
	ptop=(screen.height) ? (screen.height-h)/2 : 0;
	//left=100;
	//top=100;
	settings='height='+h+',width='+w+',top='+ptop+',left='+pleft+',scrollbars='+wscroll+',resizable';
	win=window.open(url, nom, settings);
}
function homepage()
	{
	if (navigator.appVersion.indexOf("MSIE 5") > -1 || navigator.appVersion.indexOf("MSIE 6") > -1) {
		this.style.behavior='url(#default#homepage)';
		this.setHomePage('http://www.cocinaymuchomas.com/');
	} else {
		alert("Su navegador no permite la configuración automática de la página principal. Deberá hacerlo manualmente.");
	}
}


function random_imglink(){
  var myimages=new Array()
  myimages[1]="admin/uploads/publicitat/54/es/concurs.gif"
  myimages[2]="admin/uploads/publicitat/54/es/banner_periquete.gif"

  var imagelinks=new Array()
  imagelinks[1]="http://www.cocinaymuchomas.com/counter/click.php?id=95"
  imagelinks[2]="http://www.cocinaymuchomas.com/counter/click.php?id=105"

  var ry=Math.floor(Math.random()*myimages.length)

  if (ry==0)
     ry=1
     document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" width=\"196\" height=\"222\" alt=\"\" class=\"banner\"></a>')

}