/* ************ GLOBAL JAVASCRIPT FUNCTIONS ******************* */
// Add a class target_blank links.
$(document).ready(function(){  
    $("a[href*='http://']:not([href*='"+location.hostname+"'])")
    .attr("target","_self")
    .addClass("external");  
}); 

$(document).ready(function() {
$(".intro_graphic dl, .intro_graphic_page dl, #developers dl.last_block").click(function () {
var url = $(this).find("a").attr('href');
window.location = url;
	});
});
	
 
//rollover intro graphics  
$(document).ready(function(){
	 $("dl.merchant").mouseover(function(){
      $(this).addClass("merchant_over");    
    }).mouseout(function(){
      $(this).removeClass("merchant_over");
    });
	});

$(document).ready(function(){
	 $("dl.developers").mouseover(function(){
      $(this).addClass("developers_over");    
    }).mouseout(function(){
      $(this).removeClass("developers_over");
    });
	});

$(document).ready(function(){
	 $("dl.resellers").mouseover(function(){
      $(this).addClass("resellers_over");    
    }).mouseout(function(){
      $(this).removeClass("resellers_over");
    });
	});
//end rollovers
// subcontent labels
$(document).ready(function(){
		$("label.hover+input")
			.wrap("<div class='hover-wrap'></div>")
			.focus(function(){
        $(this).prev().hide();
    })
    .blur(function(){
        if ( !this.value ) $(this).prev().show()
    })

    .each(function(){
        $(this).before( $(this).parent().prev() );

        if ( this.value ) $(this).prev().hide();
    });
});
/* BUTTON ROLLOVER *************** */
	$(document).ready(function() {
		$('.rollover').hover(
			function(){ // Change the input image's source "roll on"
			t = $(this);
			t.attr('src',t.attr('src').replace(/([^.]*)\.(.*)/, "$1_over.$2"));
			},
		function(){ 
			t= $(this);
			t.attr('src',t.attr('src').replace('_over',''));
					}
				);
			});


$(function(){
	 $('.intro_graphic_page dl').mouseover(function(){
      $(this).addClass('target');    
    }).mouseout(function(){
      $(this).removeClass('target');
    });		
});

	
// Q AND A FAQ PAGES
$(document).ready(function() {
	$('dl.qa dd').hide();
	$('dl.qa dt').click(function() {
          $(this).next().slideToggle(500);
		  return false;
        });
      }); 
// FORM VALIDATION
$(document).ready(function() {
  	  $('#phone').mask('(999) 999-9999');
	  $('#contact_form, #application_form').validate();
		
 });
$(document).ready(function() { 
				
var options = { 
	target:    '#alert'
	}; 
	$('#inquire').ajaxForm(options); 
	}); 
										
	$.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
			return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
		});
	}; 

	//CYCLE LOGOS
$(document).ready(function() {
	$('.logo_group').cycle()
	});
