/* Declare a namespace for the site */
var Site = window.Site || {};

/* Create a closure to maintain scope of the '$'
   and remain compatible with other frameworks.  */
(function($) {

	//same as $(document).ready();
	$(function() {



	});


	$(window).bind("load", function() {



	});

})(jQuery);


function changeit(theid,theimg) {
	//alert(theid+'\n'+theimg);
	document.getElementById(theid).src=theimg;
}

function confirmLink(theLink, theMsg, id) {
    // Confirmation is not required in the configuration file
    if (confirmMsg == '') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg + theMsg + id + "?");
    if (is_confirmed) {
        theLink.href;
        alert(id + " Deleted!");
    } else {
    	alert(theMsg + " " + id + " Aborted!");
    }

    return is_confirmed;
} // end of the 'confirmLink()' function
var confirmMsg  = 'Do you really want to ';

// Function for car submittal denials
function denySubmittal(first, last, year, model, carID, userID, referer) {
	var reason = prompt("Denying "+first+" "+last+"\'s "+year+" "+model+" from inclusion within the registry will remove it from the publicly viewable registry, and send it back to the user for them to make necessary changes. Once they make the changes, it will put the "+year+" "+model+" back into a 'pending approval' state.\n\nThe reason supplied below will be sent to "+first+" "+last+" via email.\n\nReason for denying "+first+" "+last+"\'s "+year+" "+model+":","");
	if (reason != null && reason != '') {
		reason = escape(reason);
		location.href = '/admin/setstatus.php?D=1&i='+carID+'&uid='+userID+'&reason='+reason+'&referer='+referer;
	}
}

// Function for deleting cars from the Registry
function deleteCar(first, last, year, model, carID, userID, referer) {
	var reason = prompt("Deleting "+first+" "+last+"\'s "+year+" "+model+" will delete the car from the registry, along with all associated images. This cannot be undone.\n\nThe reason supplied below will be sent to "+first+" "+last+" via email.\n\nReason for deleting "+first+" "+last+"\'s "+year+" "+model+":","");
	if (reason != null && reason != '') {
		reason = escape(reason);
		location.href = '/admin/setstatus.php?K=1&i='+carID+'&uid='+userID+'&reason='+reason+'&referer='+referer;
	}
}

// Function for user denials
function denyUser(first, last, userID, referer) {
	var reason = prompt("Disabling "+first+" "+last+"'s account will result in them not being able to login to the registry. Their cars will still remain publicly viewable within the registry. This can be changed at any time.\n\nThe reason supplied below will be sent to "+first+" "+last+" via email.\n\nReason for disabling "+first+" "+last+"'s account:","");
	if (reason != null && reason != '') {
		reason = escape(reason);
		location.href = '/admin/usersetstatus.php?D=1&i='+userID+'&reason='+reason+'&referer='+referer;
	}
}

// Function for deleting users from the registry
function deleteUser(first, last, userID, referer) {
	var reason = prompt("Deleting "+first+" "+last+" will remove their account, their cars, and all associated images from the registry. This cannot be undone.\n\nThe reason supplied below will be sent to the user via email.\n\nReason for deleting "+first+" "+last+"'s account:","");
	if (reason != null && reason != '') {
		reason = escape(reason);
		location.href = '/admin/usersetstatus.php?K=1&i='+userID+'&reason='+reason+'&referer='+referer;
	}
}

function NewWindow(mypage,myname,w,h,directories,location,menubar,resizable,scroll,status,toolbar) {
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'width='+w+',height='+h+',directories='+directories+',location='+location+',menubar='+menubar+',resizable='+resizable+',scrollbars='+scroll+',status='+status+',toolbars='+toolbar+',top='+TopPosition+',left='+LeftPosition
	win = window.open(mypage,myname,settings)
}

function SetCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue)+";path=/;expires="+expire.toGMTString();
}

