function externalLinks() {
	if (!document.getElementsByTagName){
        return;
    }
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
            anchor.target = "_blank";
        }
	}
}
function navigate(theUrl){
    document.location.href = theUrl;
}

function setCookie(c_name,value,expiredays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+";expires="+exdate.toUTCString()+";path=/;domain=.scantraxx.com";
}

function addToField(field, code, sdefault)
{
	if($('#'+field).val() == sdefault){
		$('#'+field).val('');
	}
	$('#'+field).val($('#'+field).val()+code+ ' ');
}

function showImage(object, source){
	$('#'+object).attr("src", source);
}

function confirmDelete(){
	if(confirm('Are you sure that you want to delete this item?')){
		return true;
	}
	return false;
}

function onEnterSubmit(e, form){
    var keycode;
	if(e){
		e = e 
	} 
	else {
		e = window.event
	} 
	if(e.which){ 
		keycode = e.which
	} 
	else {
		keycode = e.keyCode 
	}
	if(keycode == 13) {
		form.submit();
	}
}

function refreshCaptcha() {
	$('#captcha').attr('src', 'captcha?sid='+ (898989218921 * Math.random()*Math.random()));
}

function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
    group.height(tallest);
}

$(window).load(function() {
	$('#slider').nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices:15,
        animSpeed:500,
        pauseTime:6000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:true, //Next & Prev
        directionNavHide:false, //Only show on hover
        controlNav:false, //1,2,3...
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.2, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){} //Triggers after all slides have been shown
	});

});

$(document).ready(function(){
	$("#pagenav a").textShadow();
    externalLinks();
});
