/* Navigation Menu's
------------------------------------ */
<!--//--><![CDATA[//><!--

sfHover = function() {
	if ($('navigation')) {
		var sfEls = document.getElementById('navigation').getElementsByTagName('LI');
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=' sfhover';
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(' sfhover\\b'), '');
			}
		}
	}
}
if (window.attachEvent) {
	window.attachEvent('onload', sfHover);
}

//--><!]]>

/***********************************
 	Pages
***********************************/
function del_page(pageid) {
	var check = confirm('Are you sure you want to delete this Website Page?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=pages&page=delete&id=' + pageid;
	}
}
function del_content_block(id) {
	var check = confirm('Are you sure you want to delete this Content Block?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=pages&page=contentblocks&delete=' + id + '&msg=deleted';
	}
}
function del_navigation(id) {
	var check = confirm('Are you sure you want to delete this Navigation Section?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=pages&page=navigation&delete=' + id + '&msg=deleted_section';
	}
}
function del_navigation_link(id, navigation_id) {
	var check = confirm('Are you sure you want to delete this Navigation Link?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=pages&page=navigation&navigation_id=' + navigation_id + '&delete=' + id + '&msg=deleted';
	}
}
function changeNavigationType(value) {
	if (value == 'text') {
		Element.appear('text_link');
		Element.hide('image_link');
		Element.hide('text_heading');
	} else if (value == 'image') {
		Element.hide('text_link');
		Element.appear('image_link');
		Element.hide('text_heading');
	} else if (value == 'heading') {
		Element.hide('text_link');
		Element.hide('image_link');
		Element.appear('text_heading');
	}
}
function changeLinkType(value) {
	if (value == 'none') {
		Element.hide('link_page');
		Element.hide('link_website');
	} else if (value == 'page') {
		Element.appear('link_page');
		Element.hide('link_website');
	} else if (value == 'website') {
		Element.hide('link_page');
		Element.appear('link_website');
	}
}
function toggleExpand(id, action) {
	Effect.toggle('pages_' + id, 'blind');
	if ($('pages_' + id + '_img').name == 'expand') {
		$('pages_' + id + '_img').src='images/minimize.gif';
		$('pages_' + id + '_img').name='minimize';
	} else {
		$('pages_' + id + '_img').src='images/expand.gif';
		$('pages_' + id + '_img').name='expand';
	}
}
function DeleteFile(file, folder) {
	var check = confirm('Are you sure you want to delete this File?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=pages&page=upload&files&delete=' + file + '&folder=' + folder;
	}
}

/***********************************
 	Listings
***********************************/
function del_category(catid) {
	var check = confirm('Are you sure you want to delete this Category?\nAny Sub Categories & Listings under this category will be lost!\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=listings&listing=delete&catid=' + catid;
	}
}
function del_category_file(catid,fileid) {
	var check = confirm('Are you sure you want to delete this Category File?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=listings&listing=files&catid=' + catid + '&delete=' + fileid;
	}
}
function del_listing(catid,listingid) {
	var check = confirm('Are you sure you want to delete this Listing?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=listings&listing=deletelisting&catid=' + catid + '&listingid=' + listingid;
	}
}
function del_customfield(id) {
	var check = confirm('Are you sure you want to delete this Custom Field?\nAll listings that use this will lose custom field information.\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=listings&listing=custom&delete=' + id;
	}
}
function del_photo(listingid,id) {
	var check = confirm('Are you sure you want to delete this Photo?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=listings&listing=modify&listingid=' + listingid + '&view=photos&delete=' + id;
	}
}
function del_listing_file(listingid,fileid) {
	var check = confirm('Are you sure you want to delete this File?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=listings&listing=modify&listingid=' + listingid + '&view=files&delete=' + fileid;
	}
}
function del_option(id) {
	var check = confirm('Are you sure you want to delete this Purchase Option?\nThis will effect all listings that utilize this option.\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=listings&listing=options&delete=' + id;
	}
}
function del_product_option(listingid,id) {
	var check = confirm('Are you sure you want to delete this Purchase Option?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=listings&listing=modify&listingid=' + listingid + '&view=options&delete=' + id;
	}
}
function del_review(listingid,reviewid) {
	var check = confirm('Are you sure you want to delete this Review?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=listings&listing=modify&listingid=' + listingid + '&view=reviews&delete=' + reviewid;
	}
}
function del_review_pending(reviewid) {
	var check = confirm('Are you sure you want to delete this Review?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=listings&listing=reviews&delete=' + reviewid;
	}
}
function listings_options_toggle(field, id) {
	if (field.value != '') { 
		document.getElementById(id).style.display = ''; 
	} else { 
		document.getElementById(id).style.display = 'none'; 
	}
}
function listings_export() {
	var sections = $A(document.getElementsByClassName('columns'));
	var pars = '';
	sections.each(function(section) {
		var sectionID = section.id;
		pars += '&' + Sortable.serialize(sectionID);
	});
	window.location.href = 'index.php?module=listings&listing=export&export=true' + pars + '&hidetemplate=true';
}

/***********************************
 	eCommerce
***********************************/
function del_order(id) {
	var check = confirm('Are you sure you want to delete this Order?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=ecommerce&ecommerce=vieworder&orderid=' + id + '&delete=true';
	}
}
function del_order_item(orderid, id) {
	var check = confirm('Are you sure you want to delete this Order Item?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=ecommerce&ecommerce=vieworder&orderid=' + orderid + '&delete_item=' + id;
	}
}
function resend_order(orderid) {
	var check = confirm('Are you sure you want to Resend Order Information to Purchaser?\n"OK" to resend, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=ecommerce&ecommerce=vieworder&orderid=' + orderid + '&resend_order=true';
	}
}
function resend_certificates(orderid) {
	var check = confirm('Are you sure you want to resend the Gift Certificate emails?\n"OK" to resend, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=ecommerce&ecommerce=vieworder&orderid=' + orderid + '&resend_certificates=true';
	}
}
function del_shipping_zone(id) {
	var check = confirm('Are you sure you want to delete this Shipping Zone?\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=ecommerce&ecommerce=shipping&view=zones&delete=' + id;
	}
}
function del_shipping_method(zone_id, id) {
	var check = confirm('Are you sure you want to delete this Shipping Method?\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=ecommerce&ecommerce=shipping&view=zones-methods&zone_id=' + zone_id + '&delete=' + id;
	}
}
function del_taxrate(id) {
	var check = confirm('Are you sure you want to delete this Tax Rate?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=ecommerce&ecommerce=taxrates&delete=' + id;
	}
}
function del_coupon(id) {
	var check = confirm('Are you sure you want to delete this Coupon Code?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=ecommerce&ecommerce=couponcodes&delete=' + id;
	}
}

/***********************************
 	Members
***********************************/
function del_member(id) {
	var check = confirm('Are you sure you want to delete this Member?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=members&members=delete&id=' + id;
	}
}
function del_member_inactive(id) {
	var check = confirm('Are you sure you want to delete this Inactive Member?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=members&members=delete&id=' + id + '&inactive=true';
	}
}
function del_member_customfield(id) {
	var check = confirm('Are you sure you want to delete this Custom Field?\nAll members that use this will lose custom field information.\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=members&members=custom&delete=' + id;
	}
}

/***********************************
 	Blog
***********************************/
function del_blog_post(id) {
	var check = confirm('Are you sure you want to delete this Blog Post?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=blog&blog=delete&bid=' + id;
	}
}
function del_blog_category(id) {
	var check = confirm('Are you sure you want to delete this Blog Category?\nWarning: This cannot be undone!\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=blog&blog=categories&categories=delete&cid=' + id;
	}
}

/***********************************
 	Events
***********************************/
function del_event(eventid) {
	var check = confirm('Are you sure you want to delete this Event?\n"OK" to delete, "Cancel" to stop.');
	if (check == true) {
		window.location.href = 'index.php?module=events&event=delete&id=' + eventid;
	}
}

/***********************************
 	Get States
***********************************/
function getStates(country, state_select, state_text) {
	var country = country.options[country.selectedIndex].value;
	var pars = 'country=' + country + '&select=' + state_select + '&text=' + state_text;	
	var myAjax = new Ajax.Request(
		'../includes/countries-list.php', 
		{
			method: 'post',
			parameters: pars,
			onComplete: ajaxResponse
		});
}
function getStatesTax(country, state_id, state_select) {
	var country = country.options[country.selectedIndex].value;
	var pars = 'country=' + country + '&state_el=' + state_id + '&select=' + state_select;	
	var myAjax = new Ajax.Request(
		'../includes/countries-list.php', 
		{
			method: 'post',
			parameters: pars,
			onComplete: ajaxResponse
		});
}

/*************************
 	Toggle Upload Form
*************************/
function toggleUpload() {
	document.getElementById('uploadform').style.display = "none";
	document.getElementById('uploadmsg').style.display = "";
}

/***********************************
 	Toggle Checkboxes
***********************************/
function toggleAllCheckboxes(check) {
	formObj = check.form;
	for (var i=0;i < formObj.length; i++) {
		fldObj = formObj.elements[i];
		if (fldObj.type == 'checkbox') {
			fldObj.checked = check.checked;
		}
	}
}

/*************************
 	Validate Number
*************************/
function validate(field) {
	var valid = "0123456789"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") {
			ok = "no";
		}
	}
	if (ok == "no") {
		alert("Invalid entry! Only numbers are accepted as the quantity");
		field.focus();
		field.select();
	 }
}

/*************************
 	Open Window
*************************/
function newwindow(url,width,height) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=' + width + ',height=' + height + ',left = 390,top = 112');");
}

/*************************
 	Confirmation Message
*************************/
function ConfirmCancel(msg) {
	var resp	
	resp = window.confirm(msg);
	return resp;
}

/*************************
	AJAX Response (eval)
*************************/
ajaxResponse = function(request) {
	eval(request.responseText);
}
