// JavaScript Document
function alertDelete(url) {
	
	if (window.confirm('Are you sure you want to Delete this item?')) {
		location = url;
	}
}

function gId (element) {
	var e = document.getElementById(element);
	if (e) {
		return document.getElementById(element);
	} else {
		return false;	
	}
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
var cv = escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
cv = cv+';path=/';
document.cookie=c_name+ "=" +cv;
}


function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function reOrderMenu(id, url) {
	
	m = document.getElementById(id);
	list = '';
	// check li id names
	for (var i in m.childNodes) {
		s = m.childNodes[i];
		if (s.id)
			list += s.id + '-';
	}
	
	// got order page
	location = (url + '&order=order_menu&reorderlist=' + list);
}

function reOrderImages(id, url) {
	
	var m = document.getElementById(id);
	list = '';
	// check li id names
	
	for (var i in m.childNodes) {
		s = m.childNodes[i];
		if (s.id)
			list += s.id + '-';
	}
	
	// got order page
	
	location = (url + '&order=order_images&reorderlist=' + list);
	
}

function reOrderVideo(id, url) {
	
	m = document.getElementById(id);
	list = '';
	// check li id names
	for (var i=0;i < m.length;i++) {
		list += m[i].getAttribute('id') + '-';
	}
	// got order page
	
	location = (url + '&order=order_video&reorderlist=' + list);
	
}

function reOrderQuotes(id, url) {
	
	m = document.getElementById(id);
	list = '';
	// check li id names
	for (var i=0;i < m.length;i++) {
		list += m[i].getAttribute('id') + '-';
	}
	
	// got order page
	
	location = (url + '&order=order_quotes&reorderlist=' + list);
	
}

// form input prefill clear on focus, and reset on blur (if empty)

function prefillClear(field, dValue) {

if (field.value==dValue) {field.value = '';}

else if (field.value == '') {field.value = dValue;}



}
