function decision(url, delete_what){
	var message = "Are you sure that you want to delete " + delete_what + "?";
	if(confirm(message)) window.location.href = url;
}
function decisionSubmit(delete_what){
	var message = "Are you sure that you want to delete " + delete_what + "?";
	if(confirm(message)) document.deleteImage.submit();
}
// Submit Form
function submitenter(myform, e, f){
	var keycode;
	if(window.event) keycode = window.event.keyCode;
	else if(e) keycode = e.which;
	else return true;
	
	if(keycode == 13)  {
		if(f != '') eval(f); 
		else  $("#" + myform).submit();
		return false;
	} else {
		return true;
	}
}
// Handle Passphrases
function handlePassphrase(uri) {
	$.post("/js/scripts/handle-passphrase.php", { "uri" : uri, "passphrase" : $("#passphrase").val() },
	 function(data) {
		 $("#right-col").html(data);
	 });
}
// Handle Media
function getMedia(which, element_id, var1, var2, var3, var4, var5, var6, var7) {
	
	var url = "/js/scripts/get-media.php";		
	switch(which) {
		case "product-page":
		$.post(url, {"which" : element_id, "product_id" : var1, "product_name" : var2, "media_caption" : var3}, function(data) { $("#" + element_id).empty().html(data); });
		break;
		
		case "video-modal":
		$.post(url, {"which": which, "element_id" : element_id, "video_id" : var1, "video_name" : var2, "media_caption" : var3, "url" : var4, "preroll-image" : var5, "width" : var6, "height" : var7}, function(data) { $("#" + element_id).empty().html(data); });
		break;
	}
}
// Handle Email Addresses
function insertEmailAddress(contactName, emailUser, emailHost, subject, initialBodyText)  {
	if(emailHost == undefined || emailHost == "") emailHost = "devonway.com";
	if(contactName == "") contactName = emailUser + "@" + emailHost;
	if(subject == undefined) subject = "";
	if(initialBodyText == undefined) initialBodyText = "";
	
	// Generate the extra URL information for e-mail subject and body.
	extraURLData = "";
	
	if(subject != "" || initialBodyText != "" ) {
		extraURLData = "?";
		if(subject != "" ) extraURLData += "subject=" + subject + "&";
		if(initialBodyText != "" ) extraURLData += "body=" + initialBodyText;
	}
  document.write( '<a href="' + 'mailto:' + emailUser + '@' + emailHost + extraURLData + '">' + contactName + '</a>' );
}
// Handle Search
function handleSearch() {
	if(document.search_form.query.value != '' && document.search_form.query.value != 'Search this site')  document.search_form.submit();
}
// Mobile Check
function isiPhone(){
	var deviceAgent = navigator.userAgent.toLowerCase();
	var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
	if(agentID) return true
	else return false;
}
// Document Functions
$(document).ready(function(){
	//Remove outline from links
	$("a").focus(function(){ $(this).blur(); });

	// Remove Title
	$("a").removeAttr("title");

	// Navigation
	$("#nav ul li").each(function(index) { $(this).css({"width" : $(this).width()}); });
});

