/***************************
 * SITE-SPECIFIC FUNCTIONS *
 ***************************/
 
 
/*********************
 * UTILITY FUNCTIONS *
 *********************/
 
function sendMail(user,domain,tld,subject,message) {
	if (!user) user = 'info';
	if (!domain) domain = 'clearpaymentsinc';
	if (!tld) tld = 'com';
	locationstring = 'mailto:' + user + '@' + domain + '.' + tld;
	if (subject) locationstring += '?subject=' + encodeURIComponent(subject);
	if (message) locationstring += '&body=' + encodeURIComponent(message);
	window.location = locationstring;
}

function sendExternalMail(subject,message,cc) {
	locationstring = 'mailto:';
	if (subject) locationstring += "?subject=" + encodeURIComponent(subject);
	if (message) locationstring += "&body=" + encodeURIComponent(message);
	if (cc) locationstring += "&cc=" + encodeURIComponent(cc);
	window.location = locationstring;
}

function openWindow(url,features) {
	var newWin = window.open(url,'popup',features);
	newWin.focus();
}

function closeWindow() {
	if (window.opener) {
		self.close();	
	}
}

function printPage() {
	if (window.print != null) {
		window.print();
	}
	else {
		alert("To print this page, please select Print from your browser's File menu.");
	}
}

function preload(o) {
	var j;
	o.path = (typeof(o.path) == 'undefined') ? '/images/' : o.path;
	for (var i=0; i<o.images.length; i++) {
		j = $('<img />').attr('src',o.path + o.images[i]);
	}
}

function externalLinks() {
	$('a[rel*=external], a[href^=http://]').attr('target','_blank');	
}

function filesToBlank() {
	$('a[href$=.pdf],a[href$=.PDF]').attr('target','_blank').after('&nbsp;<img src="/images/pdf.png" style="vertical-align:baseline" />');
	$('a[href$=.doc],a[href$=.DOC]').attr('target','_blank');//.append(' [DOC]');
	$('a[href$=.ppt],a[href$=.PPT]').attr('target','_blank');//.append(' [PPT]');
	$('a[href$=.pps],a[href$=.PPS]').attr('target','_blank');//.append(' [PPS]');
}

function makeRollovers(){
	$('a.rollover').each(function() {
		var img = new Image();
		var upimage = $(this).children().eq(0).attr('src');
		img.src = upimage.replace('_up','_ov');
	});
	$('a.rollover').hover(
		function(){
			var overimage = $(this).children().eq(0).attr('src').replace('_up','_ov');
			$(this).children().eq(0).attr('src',overimage);
		},
		function(){
			var upimage = $(this).children().eq(0).attr('src').replace('_ov','_up');
			$(this).children().eq(0).attr('src',upimage);
		}
	);
}

function actionLinks() {
	$('a.action').after(' &#187;');
}

function init() {
	$('.sf-menu').superfish();
	externalLinks();
	filesToBlank();
	makeRollovers();
	actionLinks();
	preload({
		path : '/flash/peachtree-header/images/',
		images : new Array('01.png','02.png','03.png')
	});
	preload({
		path : '/images/peachtree/',
		images : new Array('coins01.jpg','coins02.jpg','coins03.jpg','coins04.jpg','coins05.jpg')
	});
	$('.columnize tr td:last-child, .columnize tr th:last-child').css('padding-right','0');
	$('.callout p:last, .largenotice p:last').css('margin-bottom','0');
	$('.accordion h2').click(function() {
		if ($(this).next().is(':hidden')) {
			$('.accordion h2').not($(this)).next().slideUp('slow');
			$('.accordion h2').not($(this)).parent().removeClass('active-panel');
			$(this).next().slideDown('slow');
			$(this).parent().addClass('active-panel');
		} else {
			$(this).next().slideUp('slow');
			$(this).parent().removeClass('active-panel');
		}
		return false;
	}).next().hide();
	$('.accordion div[id]').addClass('panel');
	$('.accordion h2').hover(
		function(){
			$(this).css('cursor','pointer');
		},function(){
			$(this).css('cursor','default');
	});
}
