// JavaScript Document

var panelCt=0;

jQuery(document).ready(function() {
	if( iDevice()!=true ) { jQuery("#home").homeValign(); }
	mlinks();
});

function homeAnimate() {
var panels=new Array('.panelA','.panelB','.panelC','.panelD','.home_text');

	if(panelCt==0) {
	jQuery(".panelA").hide(); 
	jQuery(".panelB").hide(); 
	jQuery(".panelC").hide(); 
	jQuery(".panelD").hide(); 
	//jQuery(".home_text").hide(); 
	}	
	
	if(panelCt<=8) {
	jQuery(panels[panelCt]).fadeIn(700,function () {
        panelCt++;
		homeAnimate();
      });
	}
}


function mlinks() {
var chars='st2-n7vwk_5x16uyqz9m:0b3hja4opr.igcdel8@f'; var m='42495560245143';	
	
jQuery('.mlink').each(function(index) {
var op=''; var mx=new Array(); 
    var idm=jQuery(this).attr("id");
	idm=idm.substring(5,idm.lastIndexOf('.'));
	var inp=m+idm;for(var i=0; i<inp.length; i+=2) {id=parseInt(inp.substr(i,2));op+=chars.charAt(id-23);}	
	var mstr=(jQuery(this).parent().attr("id")=="contact")? 'click here to email' : op.substr(7);
	jQuery(this).html('<a href='+op+'>'+mstr+'</a>');
  });
	// restore form based 
	jQuery('input').each(function(index) {
			if( jQuery(this).val().substr(0,15)=="<span id='mlink") { var fop='';
				var str=jQuery(this).val().substr(15);
				var fm=str.substr(0,str.indexOf('class')-2);
				for(var i=0; i<fm.length; i+=2) {id=parseInt(fm.substr(i,2));fop+=chars.charAt(id-23);}	
				jQuery(this).val(fop.substr(0,fop.length-3));
			}	
  	});
}


(function (jQuery) {
jQuery.fn.homeValign = function() {
	return this.each(function(i){
	var h = jQuery(this).height();
	var oh = jQuery(this).outerHeight();
	var mt = ( (h + (oh - h)) / 2 ) + 28;	
	jQuery(this).css("margin-top", "-" + mt + "px");	
	jQuery(this).css("top", "50%");
	});	
};
})(jQuery);

$(window).resize(function() {
 jQuery("#home").homeValign();
});


function iDevice() {
if( (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) ) { 	return true;} 
return false;
}


