// clear login box
function loginbox() {
	if ($("input[name=username]").val()=='') {
		$("input[name=username]").css("background", "#fff url(/images/bg_user.gif) no-repeat 3px center");
	} else {
		$("input[name=username]").css("background", "#fff");
	}
	if ($("input[name=password]").val()=='') {
		$("input[name=password]").css("background", "#fff url(/images/bg_pass.gif) no-repeat 3px center");
	} else {
		$("input[name=password]").css("background", "#fff");
	}

}
function loginboxClear() {
	$("input[name=username]").css("background", "#fff");
	$("input[name=password]").css("background", "#fff");
}

//prep login box. run a few times to accommodate different browser behaviours
$(document).ready(function() {
	loginbox();
	$(window).load(function() {
		loginbox();
		setTimeout( 'loginbox()', 300 );
 	});
 });
 
// Load FAQ Page
function ajaxpage(url, containerid) {
	//$(containerid).css("visibility", "visible");
	//$('DIV_shadow').css("visibility", "visible");
	// prevent caching of ajax loaded content
	$.ajaxSetup ({ cache:false });
	//set up error msg
	var msg = "Sorry but there was an error: ";
	
	$('#'+containerid).load(url, function(response, status, xhr) {
		$('#'+containerid).show();
		$("#DIV_shadow").show();
		// if an error occurs
		if (status == "error") {
			$('#'+containerid).css("background", "#fff");
			$('#'+containerid).css("padding", "30px");
			$('#'+containerid).html(msg + xhr.status + " " + xhr.statusText);
		}
	});
}

function go_anchor(n){
document.getElementById("faq").scrollTop = document.getElementById(n).offsetTop;
}

function linkPrevImg(pi,l,id,w) {
	document.getElementById('DIV_lgimg').style.marginLeft='-' + w/2-27 + 'px';
	document.getElementById('prev_img').src='/images/affiliates/' + pi;
	document.getElementById('link').href='/linkthrough/?' + l + '&' + id;
	document.getElementById('DIV_shadow').style.visibility='visible';
	document.getElementById('DIV_lgimg').style.visibility='visible';
}

// Div And Shadow Layer Open/Close
function popup(shadow,page) {
	$('#'+page).toggle();
	$('#'+shadow).toggle();
}
