// JavaScript Document
function f(id){
	return document.getElementById(id);
}
function AJOYAGUA(url){
    oldsc=document.getElementById("old_sc");
       if(oldsc)
            document.getElementsByTagName('body')[0].removeChild(oldsc);
    sc=document.createElement('script');
    sc.id="old_sc";
    sc.src=url+'&'+Math.random();
    document.getElementsByTagName('body')[0].appendChild(sc);
}
function rpc(url){
	oldsc=document.getElementById("old_sc");
       if(oldsc)
            document.getElementsByTagName('body')[0].removeChild(oldsc);
    sc=document.createElement('script');
    sc.id="old_sc";
    sc.src=url+'&'+Math.random();
    document.getElementsByTagName('body')[0].appendChild(sc);
}
function ventanagal(url,ancho,alto){
	coordx=screen.width?(screen.width-ancho)/2:0;
	coordy=screen.height?(screen.height-alto)/2:0;
	window.open(url,"","width="+ancho+",height="+alto+",menubar=no,resizable=yes,scrollbars=yes,left="+coordx+",top="+coordy);
}
function validateECards(){
/*
fecard
senderName
senderEmail
destinationName
destinationEmail
subject
text
img
*/	if(f('senderName').value.length<2){
		alert('Please, fill in the Your Name field');
		f('senderName').focus();
		return false;
	}
	if(f('senderEmail').value.length<2){
		alert('Please, fill in the Your Email field');
		f('senderEmail').focus();
		return false;
	}
	var filter=/^[A-Za-z]+\.*\-*\_*[A-Za-z0-9_\-]*@[A-Za-z0-9_\-]+\.[A-Za-z0-9_.]+[A-za-z]*$/;
	if(filter.test(f('senderEmail').value)==0){
		alert('Please, re-enter Your Email again');
		f('senderEmail').focus();
		return false;
	}
	if(f('destinationName').value.length<2){
		alert('Please, fill in the Recipient\'s Name field');
		f('destinationName').focus();
		return false;
	}
	if(f('destinationEmail').value.length<2){
		alert('Please, fill in the Recipient\'s Email field');
		f('destinationEmail').focus();
		return false;
	}
	var filter=/^[A-Za-z]+\.*\-*\_*[A-Za-z0-9_\-]*@[A-Za-z0-9_\-]+\.[A-Za-z0-9_.]+[A-za-z]*$/;
	if(filter.test(f('destinationEmail').value)==0){
		alert('Please, re-enter Recipient\'s Email again');
		f('destinationEmail').focus();
		return false;
	}
	
	if(f('subject').value.length<2){
		alert('Please, fill in the Subject field');
		f('subject').focus();
		return false;
	}
	if(f('text').value.length<2){
		alert('Please, fill in the Text field');
		f('text').focus();
		return false;
	}
	for(i=0;obj=document.fecard.elements[i];i++){
		ok=false;
		if(obj.type=='radio')
			if(obj.checked==true){
				ok=true;
				break;
			}
	}
	if(!ok){
		alert('Please choose an E-Card');
		return false;
	}
	return true;
}
window.onload=function(){rpc('rpc_calendario_2.php?c');}