/* v 20050112 */
/* v webcindario */



var eList = new Array ("smile","happy","grin","laugh","biglaugh",
                       "roll","wink","tongue","makingfun",
                       "eek","rolleyes","embarassed","cheerful",
                       "blush","frowneyes", "frown","tear","crying","weeping",
                       "bigcry","sleeping","anger","scold","boxing","eating1",
                       "suspicious","doubtful",
                       "clown","confused","yes","no","deny",
                       "clapping","whistling",
                       "noidea","cheekkiss","lips",
                       "hug1l","hug2r","goodbye","ttu","ttd",
                       "chained","phone","coffe");



function drawEmoticons (list) {
  for (var i=0; i<list.length; i++) {
    document.write ("<input type=image src=emoticons/" +
                    list[i] + ".gif"+
                    " onclick=\"insertEmoticon(frmPost.what," + i + ");return false;\"> &nbsp; ");
  }
}


function insertEmoticon (el, num) {
  var text;
  
  text = "<img src=emoticons/" + eList[num] + ".gif>";		
  
  el.focus ();
  if (el.createTextRange &&
	  el.selected  && 
	  el.selected.text.length == 0)	{
   	var selected = el.selected;
	selected.text = text;
  } else if ((text != null) && (text != ""))
	       el.value += text;
}




function shake (duration,strength) {
  for (t=0; t<duration; t++) {
    top.moveBy(0,strength);
    top.moveBy(0,-strength);
    top.moveBy(strength,0);
    top.moveBy(-strength,0);
  }
}



function gag (str) {
  len=Math.round(str.length/15);
  answer="&nbsp;";
 
  sad = Math.round(Math.random()*3);
  center = Math.round(Math.random());
  if (center==0) answer = "<center>";
  for (i = 0; i <= len; i++) {
    bold = Math.round(Math.random());
    claim = Math.round(Math.random());
    query = Math.round(Math.random());
    grunt = Math.round(Math.random()*2);
    
    if (grunt==0) answer = answer + " ...mmmmphfh";
    if (grunt==1) answer = answer + " ...gmmuhf";
    if (grunt==2) answer = answer + " ...grimhft";
       
    if (claim==0) answer = answer + "!";
    if (query==0) answer = answer + "?";
    answer = answer + "..."
    if (bold==0) answer = "<b>"+answer+"</b>";
  }
  if (sad==0) answer = answer + " &nbsp; <img src=emoticons/almostcry.gif>";
  
  return answer;
}


function trim(inputStr){
  while(inputStr.charAt(0)==" ") {
    inputStr=inputStr.substring(1,inputStr.length);
  }
  
  while(inputStr.charAt(inputStr.length-1)==" ") {
    inputStr=inputStr.substring(0,inputStr.length-1);
  }
  
  return inputStr;
}




function isEmpty(inputStr) {
  if ((inputStr==null) || (trim(inputStr)=="")) {
    return true;
  } 
  
  return false;
}


function validateDate(strDate) {
  var numbers='1234567890';
  var month=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
  var fecha=trim(strDate);
  
  var num=fecha.split('-');
  if(num.length!=3){
  	return false;
  }
  
  for(i=0;i<num.length;i++){
  	num[i]=trim(num[i]);
  	if(num[i].length>(i==2?4:2)||num[i]<1){
  		return false;
  	}
  	while(num[i].charAt(0)=='0'){
  		num[i]=num[i].substring(1,num[i].length);
  	}
  	for(j=0;j<num[i].length;j++){
  		if(numbers.indexOf(num[i].charAt(j))==-1){
  			return false;
  		}
  	}
  }
  var dia=parseInt(num[0]);
  var mes=parseInt(num[1]);
  var ano=parseInt(num[2]);
  if(mes>12||mes<1){
  	return false;
  }
  if(ano%4==0&&(ano%100!=0||ano%400==0)){
  	month[1]+=1;
  }
  if(dia>month[mes-1]||dia<1){
  	return false;
  }
  return true;
}



function openSubscriber()
{
  imageTmp = new Image;
  imageTmp.src = "images/noemission.gif";
  
  saw = window.screen.availWidth; // ancho de pantalla disponible
  sah = window.screen.availHeight; // alto de pantalla disponible
  
  if (saw>800) {
    woff=0
    w=800;
  } else {
    woff=15
    w=saw-woff;
  }
    
  if (sah>600) {
    hoff=0;
    h=600;
  } else {
    hoff=35;
    h=sah-hoff;
  }
    
  l = (saw-w-woff)/2;  // centrada	 
  t = (sah-h-hoff)/2;  // centrada	 
  
  html = '<html><head>';
  html += '<meta http-equiv="Expires" content="0">';
  html += '<meta http-equiv="Pragma" content="no-cache">';
  html += '<meta http-equiv="Cache-Control" content="no-cache">';
  html += '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">';
  html += '<frames><noframes></frames></noframes>';
  html += '<title>Muppet place. De, por y para muppets. Area para abonados.</title>';
  html += '<script type="text/javascript" language="JavaScript1.2" src="pages/js/js.js"></script>';
  html += '</head>';
  html += '<body background="images/noemission.gif" onClick="redirect();" onLoad="setTimeout(\'redirect();\',2000)">';
  html += '</body></html>';
  
  popupWindow = window.open('_blank','nagora','left='+l+',top='+t+',width='+w+',height='+h+',scrollbars=no,status=no,resizable=yes,directories=no,location=no,toolbar=no');
  popupWindow.document.open();
  popupWindow.document.write(html);
  popupWindow.document.close();
  return false;
} //Fin openSubscriber



function closeWin() { 
  var thisWin=window.self; 
  alert("cerrar ventana");
  thisWin.opener=window.self; 
  thisWin.close(); 
} 

function redirect() {
  if (event!=null) {
    esx = event.clientX; esy = event.clientY;
  } else {
    esx = 0; esy = 0;
  }
  //alert(esx+"\n"+esy);
  saw = window.screen.availWidth; sah = window.screen.availHeight; 
  
  if (saw>800) {
    woff=0
    w=800;
  } else {
    woff=15
    w=saw-woff;
  }
    
  if (sah>600) {
    hoff=0;
    h=600;
  } else {
    hoff=35;
    h=sah-hoff;
  }
  if ((esx>=75) && (esx<=200))
    if ((esy>=((h-100-hoff)/2)) && (esy<=((h+100-hoff)/2))) {
      location="http://muppet-place.webcindario.com/agora_nav/agora.php";
      return;
    }
  location="http://www.plus.es/codigo/default.asp";
}
  