// JavaScript Document
function getElementPosition() {
		var offsetTrail = this;
		var offsetLeft = 0;
		var offsetTop = 0;
		while (offsetTrail) {
			offsetLeft += offsetTrail.offsetLeft;
			offsetTop += offsetTrail.offsetTop;
			offsetTrail = offsetTrail.offsetParent;
		}
		return {left:offsetLeft, top:offsetTop};
}

function getElementsByClassName(rel,scope){
    var col=[];
	var sc=scope || document;
    var tCol=sc.getElementsByTagName('*');
    for(var ii=0;ii<tCol.length;ii++)
        if(tCol[ii].className==rel)
            col.push(tCol[ii])
    return col;
}  
function getElementsByRelName(rel){
    var col=[];
    var tCol=document.getElementsByTagName('*');
    for(var ii=0;ii<tCol.length;ii++)
        if(tCol[ii].rel==rel || tCol[ii].getAttribute('rel')==rel)
            col.push(tCol[ii])
    return col;
}
function cancelEvent(e){
	if(e && e.preventDefault)
		e.preventDefault();
	else if(window.event)
		window.event.returnValue=false;
}
function stopEvent(e){
	if(e && e.stopPropagation)
		e.stopPropagation();
	else if(window.event)
		window.event.cancelBubble=true;
}
function compensar(delta){
		var mx=0;
		for(var i=1,l=arguments.length;i<l;i++){
			if($(arguments[i]).offsetHeight>mx)
				mx=$(arguments[i]).offsetHeight;
		}
		for(var ii=1,ll=arguments.length;ii<ll;ii++){
			if(arguments[ii]=='collection1')delta=-20;
			$(arguments[ii]).css('height',mx+delta+'px');
		}
}
function css(id,prop){ 
    if(window.getComputedStyle){ 
        return document.defaultView.getComputedStyle($(id),null).getPropertyValue(prop); 
    }else{ 
        var re = /(-([a-z]){1})/g; 
        if (prop == 'float') prop = 'styleFloat'; 
        if (re.test(prop)) { 
            prop = prop.replace(re, function () { 
                return arguments[2].toUpperCase(); 
            }); 
        } 
        return $(id).currentStyle[prop] ? $(id).currentStyle[prop] : null; 
    } 
}  
var ray={}
var cerremos=1;
addLoadEvent(
	function(){
		ray.med=getWindowData();
		if($('rayitas')){
				$('rayitas').height=ray.med[5]-85;
		}
		closemenu();
		$('mabout').addEvent('mouseover',function(e){
			cerremos=0;
			stopEvent(e);
			cancelEvent(e);
			closemenu('menuhome1');
			var pos=getElementPosition.call(this);
				$('menuhome1').style.top=pos.top+27+'px';
				$('menuhome1').style.left=pos.left+'px';
				fx($('menuhome1'),[
			{'inicio':0,'fin':180,'u':'px','propCSS':'width'},
			{'inicio':0,'fin':200,'u':'px','propCSS':'height'},
			{'inicio':0,'fin':.9999,'u':'','propCSS':'opacity'}
			],0,true,senoidal);
											  
		});
		
		$('mabout').addEvent('mouseout',function(e){
			cerremos=1;	});
		
		
		
		
		
		
		$('mclient').addEvent('mouseover',function(e){
			cerremos=0;
			stopEvent(e);
			cancelEvent(e);
			closemenu('menuhome2');
			var pos=getElementPosition.call(this);
				$('menuhome2').style.top=pos.top+27+'px';
				$('menuhome2').style.left=pos.left+'px';
				fx($('menuhome2'),[
			{'inicio':0,'fin':180,'u':'px','propCSS':'width'},
			{'inicio':0,'fin':200,'u':'px','propCSS':'height'},
			{'inicio':0,'fin':.9999,'u':'','propCSS':'opacity'}
			],0,true,senoidal);
											  
		});
		
		
		$('mclient').addEvent('mouseout',function(e){
			cerremos=1;	});
		
		
		
		$('mcase').addEvent('mouseover',function(e){
			cerremos=0;
			stopEvent(e);
			cancelEvent(e);
			closemenu('menuhome3');
			var pos=getElementPosition.call(this);
				$('menuhome3').style.top=pos.top+27+'px';
				$('menuhome3').style.left=pos.left+1+'px';
				fx($('menuhome3'),[
			{'inicio':0,'fin':180,'u':'px','propCSS':'width'},
			{'inicio':0,'fin':200,'u':'px','propCSS':'height'},
			{'inicio':0,'fin':.9999,'u':'','propCSS':'opacity'}
			],0,true,senoidal);
											  
		});
		
		$('mcase').addEvent('mouseout',function(e){
			cerremos=1;	});
		
		
		
		
		$('mcontact').addEvent('mouseover',function(e){
			cerremos=0;
			stopEvent(e);
			cancelEvent(e);
			closemenu('menuhome4');
			var pos=getElementPosition.call(this);
				$('menuhome4').style.top=pos.top+27+'px';
				$('menuhome4').style.left=pos.left+2+'px';
				fx($('menuhome4'),[
			{'inicio':0,'fin':180,'u':'px','propCSS':'width'},
			{'inicio':0,'fin':200,'u':'px','propCSS':'height'},
			{'inicio':0,'fin':.9999,'u':'','propCSS':'opacity'}
			],0,true,senoidal);
											  
		});
		
		$('mcontact').addEvent('mouseout',function(e){
			cerremos=1;	});
		
		
		var submenus= getElementsByClassName('submenu');
		for(var i=0,l=submenus.length;i<l;i++){
			panino.getO(submenus[i]).hover(function(){cerremos=0;},function(){cerremos=1;});//a	
			panino.getO(submenus[i].parentNode).hover(function(){cerremos=0;},function(){cerremos=1;});//td
			panino.getO(submenus[i].parentNode.parentNode).hover(function(){cerremos=0;},function(){cerremos=1;});//tr
			panino.getO(submenus[i].parentNode.parentNode.parentNode).hover(function(){cerremos=0;},function(){cerremos=1;});//table
			panino.getO(submenus[i].parentNode.parentNode.parentNode.parentNode).hover(function(){cerremos=0;},function(){cerremos=1;});//div
		}
			
	}			 
);

function closemenu(ignorar){
	if(ignorar!='menuhome1'){
	fx($('menuhome1'),[
			{'inicio':parseInt(css('menuhome1','width')),'fin':0,'u':'px','propCSS':'width'},
			{'inicio':parseInt(css('menuhome1','height')),'fin':0,'u':'px','propCSS':'height'},
			{'inicio':.9999,'fin':0,'u':'','propCSS':'opacity'}
			],0,true,senoidal);
	}
	if(ignorar!='menuhome2'){
	fx($('menuhome2'),[
			{'inicio':parseInt(css('menuhome2','width')),'fin':0,'u':'px','propCSS':'width'},
			{'inicio':parseInt(css('menuhome2','height')),'fin':0,'u':'px','propCSS':'height'},
			{'inicio':.9999,'fin':0,'u':'','propCSS':'opacity'}
			],0,true,senoidal);
	}
	if(ignorar!='menuhome3'){
	fx($('menuhome3'),[
			{'inicio':parseInt(css('menuhome3','width')),'fin':0,'u':'px','propCSS':'width'},
			{'inicio':parseInt(css('menuhome3','height')),'fin':0,'u':'px','propCSS':'height'},
			{'inicio':.9999,'fin':0,'u':'','propCSS':'opacity'}
			],0,true,senoidal);
	}
	if(ignorar!='menuhome4'){
	fx($('menuhome4'),[
			{'inicio':parseInt(css('menuhome4','width')),'fin':0,'u':'px','propCSS':'width'},
			{'inicio':parseInt(css('menuhome4','height')),'fin':0,'u':'px','propCSS':'height'},
			{'inicio':.9999,'fin':0,'u':'','propCSS':'opacity'}
			],0,true,senoidal);
	}
}
setInterval(function(){if(!cerremos)return;closemenu(null);},1500);
function mod(){
	if($('nombre').value.length<2){
		alert('Please, fill in First Name field');
		return;
	}
	if($('apellido').value.length<2){
		alert('Please, fill in Last Name field');
		return;
	}
	if($('direccion').value.length<2){
		alert('Please, fill in Address field');
		return;
	}
	if($('city').value.length<2){
		alert('Please, fill in City field');
		return;
	}
	if($('codpos').value.length<2){
		alert('Please, fill in ZIP CODE field');
		return;
	}	
	if($('tel').value.length<2){
		alert('Please, fill in Phone Number field');
		return;
	}
	if($('mail').value.length<2){
		alert('Please, fill in E-mail field');
		return;
	}
	if($('mail').value.indexOf('@')==-1){
		alert('Please, re-enter Your Email again');
		return;
	}
	if($('mail').value.indexOf('.')==-1){
		alert('Please, re-enter Your Email again');
		return;
	}
	if($('username').value.length<1){
		alert('Please, fill in Username field');
		return;
	}
	if($('password').value.length<1){
		alert('Please, fill in Password field');
		return;
	}
	requestCallbackParam('cms/proceso.php',
						 function(r){location.reload();},{'id':$('id').value,'nombre':$('nombre').value,'apellido':$('apellido').value,
						'direccion':$('direccion').value,'city':$('city').value,'codpos':$('codpos').value,'tel':$('tel').value,
						'mail':$('mail').value,'user':$('username').value,'pass':$('password').value,'proceso':'MODPERF'
						
																													  });
}
