<br />
<b>Warning</b>:  Unknown: open_basedir restriction in effect. File(/home/dohy/www/access-logs/dohy.net_error_log) is not within the allowed path(s): (/home/dohy:/usr/lib/php:/usr/local/lib/php:/tmp) in <b>Unknown</b> on line <b>0</b><br />
/*==================================================
  Cookie functions
  ==================================================*/
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

/* inner functions*/

function toggle(obj) {
	var el = $(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '' );
}

function hidden_obj(obj) {
	//alert(obj);
	var el = $(obj);
	el.style.display = 'none';			
}

function show_obj(obj) {
	var el = $(obj);
	el.style.display = '';	
	//alert(obj);	
}

function toggle_attrib(obj, id) {
	if(obj.innerHTML=='+')	{
		obj.innerHTML = '-';
	} else {
		obj.innerHTML = '+';	
	}
	
	toggle('im_'+id+'_value_panel');		
}

function delete_attrib(id) {	
	var answer = confirm("Delete this attribute?")
	if (answer){		
	}
	else{
		return;
	}
		
	var pars = 'todo=delete_attribute&attrib_id='+id; /* just for example */
  //var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_attrib_update.php', {method:'get',parameters:pars});	
	myactions = new Array();	
  var myAjax = new Ajax.Request('ajax/prd_attrib_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_attrib("+id+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_attrib_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_attrib(id);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});		  			
}

function hide_attrib(id) {
	hidden_obj('im_'+id);	
	el = $('master['+id+']');	
	el.checked = false;	
}

function delete_attrib_value(id, value_id) {	
	var answer = confirm("Delete this value?")
	if (answer){		
	}
	else{
		return;
	}
	
	hide_attrib_value(id, value_id);
  var pars = 'todo=delete_object&obj_id='+value_id; /* just for example */
  //var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_attrib_update.php', {method:'get',parameters:pars});	
  myactions = new Array();	
  var myAjax = new Ajax.Request('ajax/prd_attrib_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_attrib("+id+", "+value_id+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_attrib_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_attrib_value(id, value_id);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}

function hide_attrib_value(id, value_id) {	
	hidden_obj('im_'+id+'_value_'+value_id);	
	el = $('master_value['+id+']['+value_id+']');	
	el.checked = false;	
}

function add_new_attrib() {
	div = $('im');
	tpl = blank_item.replace(/###/gi, base_id);
	base_id--;
	//div.innerHTML += tpl;
	var new_item = document.createElement("div");
	new_item.innerHTML = tpl;
	div.appendChild(new_item);
	
}

function add_new_attrib_value(id) {
	div = $('im_'+id+'_values');
	tpl = blank_value.replace(/###/gi, id);
	tpl = tpl.replace(/@@@/gi, value_base_id);
	value_base_id--;	
	//div.innerHTML += tpl;
	
	var new_item = document.createElement("div");
	new_item.innerHTML = tpl;
	div.appendChild(new_item);	
	toggle_order(id);
}

function delete_loc(id, k) {	
	var answer = confirm("Delete this location?")
	if (answer){		
	}
	else{
		return;
	}
		
	var pars = 'todo=delete_location&loc_id='+id; /* just for example */
  //var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/acc_loc_update.php', {method:'get',parameters:pars});	
	myactions = new Array();	
  var myAjax = new Ajax.Request('ajax/acc_loc_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_loc("+k+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/acc_loc_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_loc(k);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});		  			
}

function hide_loc(id) {
	hidden_obj('im_'+id);	
	hidden_obj('loc_'+id);	
	el = $('master['+id+']');	
	el.checked = false;	
}

function delete_loc2(id, k) {	
	var answer = confirm("Delete this location?")
	if (answer){		
	}
	else{
		return;
	}
	var pars = 'todo=delete_location&loc_id='+id; /* just for example */
  //var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/acc_loc_update.php', {method:'get',parameters:pars});	
	myactions = new Array();	
  var myAjax = new Ajax.Request('ajax/acc_loc_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {  																		
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_loc2("+k+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/acc_loc_update.php', {method:'get',parameters:"+pars+"})";
																    } else {				
																    										    	
																    	hide_loc2(k);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});		  			
}

function hide_loc2(id) {	
	hidden_obj('in_'+id);		
	el = $('master['+id+']');	
	el.checked = false;	
}

function delete_loc_value(id, value_id) {	
	var answer = confirm("Delete this value?")
	if (answer){		
	}
	else{
		return;
	}
	
	hide_loc_value(id, value_id);
  var pars = 'todo=delete_object&obj_id='+value_id; /* just for example */
  //var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/acc_loc_update.php', {method:'get',parameters:pars});	
  myactions = new Array();	
  var myAjax = new Ajax.Request('ajax/acc_loc_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_loc("+id+", "+value_id+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/acc_loc_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_loc_value(id, value_id);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}

function hide_loc_value(id, value_id) {	
	hidden_obj('im_'+id+'_value_'+value_id);	
	el = $('master_value['+id+']['+value_id+']');	
	el.checked = false;	
}

function add_new_loc() {
/*	div = $('im');
	tpl = blank_item.replace(/###/gi, -1);
	tpl = tpl.replace(/@@@/gi, base_id);
	base_id--;
	//div.innerHTML += tpl;
	var new_item = document.createElement("div");
	new_item.innerHTML = tpl;
	div.appendChild(new_item);
*/
	edit_location(-1, -1);	
}

function add_new_loc2() {
	div = $('in');
	tpl = blank_item.replace(/###/gi, -1);
	tpl = tpl.replace(/@@@/gi, base_id);
	id = base_id;
	base_id--;
	//div.innerHTML += tpl;
	var new_item = document.createElement("div");
	new_item.innerHTML = tpl;
	div.appendChild(new_item);
	
	populateCountry('', id);
	populateState('', '', id);	
}

function add_new_loc_value(k) {
	 var tbody = document.getElementById("tb_"+k).getElementsByTagName("tbody")[0];
	 var row = document.createElement("TR");
	 row.id = 'comm_'+comm_base_id;
	 tpl = empty_line.replace(/###/gi, -1);
	 tpl = tpl.replace(/@@@/gi, comm_base_id);
	 
	 comm_base_id--;
	 
	 a = tpl.split('<!--col-->');	 
	 for(i=0; i<a.length; i++) {
	 	var cell = document.createElement("TD");	
	 	cell.innerHTML = a[i];	
	 	if(i==0) {
	 		cell.className = 'key';
	 	}
	 	row.appendChild(cell);
	 }
	 tbody.appendChild(row);
}

function add_new_user_value(k) {
	 var tbody = document.getElementById("tb_"+k).getElementsByTagName("tbody")[0];
	 var row = document.createElement("TR");
	 row.id = 'comm_'+comm_base_id;
	 tpl = empty_line.replace(/###/gi, -1);
	 tpl = tpl.replace(/@@@/gi, comm_base_id);
	 
	 comm_base_id--;
	 
	 a = tpl.split('<!--col-->');	 
	 for(i=0; i<a.length; i++) {
	 	var cell = document.createElement("TD");	
	 	cell.innerHTML = a[i];	
	 	if(i==0) {
	 		cell.className = 'key';
	 	}
	 	row.appendChild(cell);
	 }
	 tbody.appendChild(row);
}

function edit_location(id, k) {
		var div = $('loc_editor');
		var url = 'ajax/acc_loc.info.php';
		$('SYSTEM_BAR').innerHTML = "<p>Loading...<\/p>"; 
		var pars = 'loc_id='+id+'&key='+k; /* just for example */
    myactions = new Array();
    var myAjax = new Ajax.Request(url, 
    															{method:'get',
    															parameters:pars,
    															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "var myAjax = new Ajax.Updater('"+div.id+"', '"+url+"', {method:'get',parameters:'"+pars+"'});";
																    } else {
																      div.innerHTML = transport.responseText;
																      load_js();
																    }
																    $('SYSTEM_BAR').innerHTML = ""; 
																	  }																	  
    															});    		
}

function getElementsByStyleClass (className) {
  var all = document.all ? document.all :
    document.getElementsByTagName('*');
  var elements = new Array();
  for (var e = 0; e < all.length; e++)
    if (all[e].className == className)
      elements[elements.length] = all[e];
  return elements;
}

function toggle_order(id) {
	obj = $(id+'_order_option');
	
	els = getElementsByStyleClass('order');
	for (var e = 0; e < els.length; e++) {
		el = els[e];	
		cur_id = el.id;
		a = cur_id.split("::");
		if(id==a[0]) {			
			if(obj.value==0) {
				show_obj(el.id);
			} else {
				hidden_obj(el.id);						
			}
		}
	}	
}

function delete_sugg_prod(id, key) {	
	var answer = confirm("Delete this product?")
	if (answer){		
	}
	else{
		return;
	}
	
	myactions = new Array();	
	var pars = 'todo=delete_item&id='+id; /* just for example */
  var myAjax = new Ajax.Request('ajax/prd_sugg_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_sugg_prod("+key+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/sale_items_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_sugg_prod(key);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}


function hide_sugg_prod(key) {
	hidden_obj('item_'+key);	
	el = $('removed_'+key);	
	el.value = 1;		
}

function delete_build_item(id, key) {	
	var answer = confirm("Delete this item?")
	if (answer){		
	}
	else{
		return;
	}
	
	myactions = new Array();	
	var pars = 'todo=delete_item&id='+id; /* just for example */
  var myAjax = new Ajax.Request('ajax/build_info_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_build_item("+key+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/build_info_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_build_item(key);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}


function hide_build_item(key) {
	hidden_obj('item_'+key);	
	el = $('removed_'+key);	
	el.value = 1;		
}

function refresh_trans_item(id, key) {
	el = $('refreshed_'+key);	
	el.value = 1;	
	ajax_submit('items_form', 'tab_items', 'ajax/sale_items_update.php');		
}

function delete_trans_item(id, key) {	
	var answer = confirm("Delete this item?")
	if (answer){		
	}
	else{
		return;
	}
	
	myactions = new Array();	
	var pars = 'todo=delete_item&id='+id; /* just for example */
  var myAjax = new Ajax.Request('ajax/sale_items_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_trans_item("+key+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/sale_items_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_trans_item(key);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}


function hide_trans_item(key) {
	hidden_obj('item_'+key);	
	el = $('removed_'+key);	
	el.value = 1;		
}

function delete_item(id) {	
	var answer = confirm("Delete this item?")
	if (answer){		
	}
	else{
		return;
	}
	
	myactions = new Array();	
	var pars = 'todo=delete_item&item_id='+id; /* just for example */
  var myAjax = new Ajax.Request('ajax/prd_item_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_item("+id+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_item_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_item(id);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}


function delete_product_list(id, k) {	
	var answer = confirm("Delete this product?")
	if (answer){		
	}
	else{
		return;
	}
	
	myactions = new Array();	
	var pars = 'todo=delete_product&prd_id='+id; /* just for example */
  var myAjax = new Ajax.Request('ajax/prd_product_list_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_product_list("+k+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_product_list_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_product_list(k);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}

function hide_product_list(id) {
	hidden_obj('product_list_'+id);	
	el = $('product_list_id['+id+']');	
	el.checked = false;	
}


function delete_account_list(id, k) {	
	var answer = confirm("Delete this account?")
	if (answer){		
	}
	else{
		return;
	}
	
	myactions = new Array();	
	var pars = 'todo=delete_account&acc_id='+id; /* just for example */
  var myAjax = new Ajax.Request('ajax/acc_list_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_account_list("+k+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_account_list_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_account_list(k);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}

function hide_account_list(id) {
	hidden_obj('account_list_'+id);	
	el = $('account_list_id['+id+']');	
	el.checked = false;	
}

function delete_warehouse_list(id, k) {	
	var answer = confirm("Delete this warehouse?")
	if (answer){		
	}
	else{
		return;
	}
	
	myactions = new Array();	
	var pars = 'todo=delete_warehouse&wh_id='+id; /* just for example */
  var myAjax = new Ajax.Request('ajax/wh_list_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_warehouse_list("+k+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_warehouse_list_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_warehouse_list(k);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}

function hide_warehouse_list(id) {
	hidden_obj('warehouse_list_'+id);	
	el = $('warehouse_list_id['+id+']');	
	el.checked = false;	
}

function delete_user(id, k) {	
	var answer = confirm("Delete this user?")
	if (answer){		
	}
	else{
		return;
	}
	
	myactions = new Array();	
	var pars = 'todo=delete_user&user_id='+id; /* just for example */
  var myAjax = new Ajax.Request('ajax/user_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_user("+k+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_user_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_user(k);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}

function hide_user(id) {
	hidden_obj('user_'+id);	
}

function delete_price_list(id, k, opt) {	
	if(opt!='') {
		var answer = confirm("Do you check no account has this price list?")
		if (answer){		
		}
		else{
			return;
		}
	}
	
	myactions = new Array();	
	var pars = 'todo=delete_price_list&price_list_id='+id+'&opt='+opt; /* just for example */
  var myAjax = new Ajax.Request('ajax/prd_price_list_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_price_list("+k+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_price_list_update.php', {method:'get',parameters:"+pars+"})";
																    } else if (transport.responseText.match(/DOUBLE CHECK/ig)){
																      	var answer = confirm("At least ONE account has this price list selected, those accounts will have NO price list attached if you continue. Proceed?")
																				if (answer){	
																					delete_price_list(id, k, '');	
																				} else {
																																										
																				}
																    }else {
																    	hide_price_list(k);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}

function hide_price_list(id) {
	hidden_obj('price_list_'+id);	
	el = $('price_list_id['+id+']');	
	el.checked = false;	
}

function delete_shipping_price_list(id, k) {	
	myactions = new Array();	
	var pars = 'todo=delete_price_list&price_list_id='+id; /* just for example */
  var myAjax = new Ajax.Request('ajax/shp_price_list_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_shipping_price_list("+k+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_shipping_price_list_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_shipping_price_list(k);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}

function hide_shipping_price_list(id) {
	hidden_obj('shipping_price_'+id);	
	el = $('price_list_id['+id+']');	
	el.checked = false;	
}

function delete_tax_list(id, k) {	
	var answer = confirm("Do you check no account has this tax?")
	if (answer){		
	}
	else{
		return;
	}
	
	myactions = new Array();	
	var pars = 'todo=delete_tax_list&tax_list_id='+id; /* just for example */
  var myAjax = new Ajax.Request('ajax/prd_tax_list_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_tax_list("+k+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_tax_list_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_tax_list(k);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}

function hide_tax_list(id) {
	hidden_obj('tax_list_'+id);	
	el = $('tax_list_id['+id+']');	
	el.checked = false;	
}

function hide_item(id) {
	hidden_obj('item_'+id);	
	el = $('id['+id+']');	
	el.checked = false;	
}

function hide_item_price(id) {	
	hidden_obj('price_'+id);	
	el = $('price_id['+id+']');	
	el.checked = false;	
	el.value = '';
	
}

function appendRow()
{
	 var tbody = document.getElementById("items").getElementsByTagName("tbody")[0];
	 var row = document.createElement("TR");
	 row.id = 'item_'+item_base_id;
	 tpl = blank_row.replace(/###/gi, item_base_id);
	 
	 item_base_id--;
	 
	 a = tpl.split('<!--col-->');
	 for(i=0; i<a.length; i++) {
	 	var cell = document.createElement("TD");	
	 	b = a[i].split('<!--data-->');
	 	cell.className = b[0];
	 	cell.innerHTML = b[1];	
	 	row.appendChild(cell);
	 }
	 tbody.appendChild(row);
}

function browse_item(id, key) {
	showModalDialog('item_pickup', 500, 200);
	tab_updated('item');
	cur_sku_id = 'no_'+key;
}

function add_item_sale() {
	//alert(cur_sku_id);
	//document.items_form.new_item_sku.value = 'haha'
	$(cur_sku_id).value = document.items_form.new_item_sku.value;
	toggle('blanket');
	toggle('item_pickup');	
	//alert(document.items_form.new_item_sku.value);
}

function appendItemRow()
{
	 var tbody = document.getElementById("items").getElementsByTagName("tbody")[0];
	 var row = document.createElement("TR");
	 row.id = 'item_'+item_base_id;
	 tpl = blank_row.replace(/###/gi, item_base_id);
	 tpl = tpl.replace(/@@@/gi, item_base_id);
	 
	 item_base_id--;
	 
	 a = tpl.split('<!--col-->');
	 for(i=0; i<a.length; i++) {
	 	var cell = document.createElement("TD");	
	 	b = a[i].split('<!--data-->');
	 	cell.className = b[0];
	 	cell.innerHTML = b[1];	
	 	row.appendChild(cell);
	 }
	 insertBefore(row, $('sub-total'));
}

function appendPriceListRow()
{
	 var tbody = document.getElementById("price_list").getElementsByTagName("tbody")[0];
	 var row = document.createElement("TR");
	 row.id = 'price_list_'+price_list_base_id;
	 tpl = empty_line.replace(/###/gi, price_list_base_id);
	 
	 price_list_base_id--;
	 
	 a = tpl.split('<!--col-->');
	 for(i=0; i<a.length; i++) {
	 	var cell = document.createElement("TD");	
	 	cell.innerHTML = a[i];	
	 	row.appendChild(cell);
	 }
	 tbody.appendChild(row);
}

function appendTaxListRow()
{
	 var tbody = document.getElementById("tax_list").getElementsByTagName("tbody")[0];
	 var row = document.createElement("TR");
	 row.id = 'tax_list_'+tax_list_base_id;
	 tpl = empty_line.replace(/###/gi, tax_list_base_id);
	 id = tax_list_base_id;
	 tax_list_base_id--;
	 
	 a = tpl.split('<!--col-->');
	 for(i=0; i<a.length; i++) {
	 	var cell = document.createElement("TD");	
	 	b = a[i].split('<!--data-->');
	 	cell.className = b[0];
	 	cell.innerHTML = b[1];	
	 	row.appendChild(cell);
	 }
	 tbody.appendChild(row);
	 
	 populateCountry('', id); populateState('' , '', id); 
}

function appendShippingPriceRow()
{
	 var tbody = document.getElementById("shipping_price").getElementsByTagName("tbody")[0];
	 var row = document.createElement("TR");
	 row.id = 'shipping_price_'+shipping_price_base_id;
	 tpl = empty_line.replace(/###/gi, shipping_price_base_id);
	 id = shipping_price_base_id;
	 shipping_price_base_id--;
	 
	 a = tpl.split('<!--col-->');
	 for(i=0; i<a.length; i++) {
	 	var cell = document.createElement("TD");	
	 	b = a[i].split('<!--data-->');
	 	cell.className = b[0];
	 	cell.innerHTML = b[1];	
	 	row.appendChild(cell);
	 }
	 tbody.appendChild(row);	 	 
}

function appendProductListRow()
{
	 var tbody = document.getElementById("product_list").getElementsByTagName("tbody")[0];
	 var row = document.createElement("TR");
	 row.id = 'product_list_'+product_list_base_id;
	 tpl = empty_line.replace(/###/gi, product_list_base_id);
	 
	 product_list_base_id--;
	 
	 a = tpl.split('<!--col-->');
	 for(i=0; i<a.length; i++) {
	 	var cell = document.createElement("TD");	
	 	cell.innerHTML = a[i];	
	 	row.appendChild(cell);
	 }
	 tbody.appendChild(row);
}	

function appendGroupListRow()
{
	 var tbody = document.getElementById("group_list").getElementsByTagName("tbody")[0];
	 var row = document.createElement("TR");
	 row.id = 'group_list_'+group_list_base_id;
	 tpl = empty_line.replace(/###/gi, group_list_base_id);
	 
	 group_list_base_id--;
	 
	 a = tpl.split('<!--col-->');
	 for(i=0; i<a.length; i++) {
	 	var cell = document.createElement("TD");	
	 	cell.innerHTML = a[i];	
	 	row.appendChild(cell);
	 }
	 tbody.appendChild(row);
}	
function insertAfter(new_node, existing_node) {
// if the existing node has a following sibling, insert the current
// node before it. otherwise appending it to the parent node
// will correctly place it just after the existing node.

if (existing_node.nextSibling) {
// there is a next sibling. insert before it using the mutual
// parent's insertBefore() method.
existing_node.parentNode.insertBefore(new_node, existing_node.nextSibling);
} else {
// there is no next sibling. append to the end of the parent's
// node list.
existing_node.parentNode.appendChild(new_node);
}

} // insertAfter()

function insertBefore(new_node, existing_node) {
existing_node.parentNode.insertBefore(new_node, existing_node);
} // insertBefore()

function appendPriceRow(obj_id, item_id, sku, desc, k)
{	
	 var tbody = document.getElementById("item_prices").getElementsByTagName("tbody")[0];
	 var row = document.createElement("TR");
	 row.id = 'price_'+item_price_base_id;
	 tpl = blank_line.replace(/@@@/gi, item_price_base_id);
	 //tpl = tpl.replace(/#@@/gi, obj_id); //useless
	 tpl = tpl.replace(/##@/gi, item_id);
	 tpl = tpl.replace(/@##/gi, desc);
	 tpl = tpl.replace(/###/gi, sku);

	 item_price_base_id--;
	 
	 a = tpl.split('<!--col-->');
	 for(i=0; i<a.length; i++) {
	 	if(i==1) { // for description
	 		c = desc.split('<!--desc-->');
	 		for(j=0; j<c.length; j++) {
			 	var cell = document.createElement("TD");				 	
			 	cell.className = 'center';
			 	cell.innerHTML = c[j];	
			 	row.appendChild(cell);	 
			}		
	 	} else {
		 	var cell = document.createElement("TD");	
		 	b = a[i].split('<!--data-->');
		 	cell.className = b[0];
		 	cell.innerHTML = b[1];	
		 	row.appendChild(cell);
		 }
	 }
	 insertAfter(row, $('price_'+k));
	 
	//toggle by current value	
	var testId = new RegExp("^pdpl\\[(.*)\\]$");
	var elements =document.getElementsByTagName("input");
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testId.test(current.id)){					
			toggle_status(testId.exec(current.id)[1], (current.value=='A'));
		}
	}
	
}

function delete_item_price(id, k) {	
	var answer = confirm("Delete this row?")
	if (answer){		
	}
	else{
		return;
	}
	
	myactions = new Array();	
	var pars = 'todo=delete_item_price&obj_id='+id; /* just for example */
  var myAjax = new Ajax.Request('ajax/prd_price_update.php', 
  															{method:'get',
  															parameters:pars,
  															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "hide_item_price("+k+")";
																      myactions[1] = "var myAjax = new Ajax.Updater($('SYSTEM_MESSAGE'), 'ajax/prd_price_update.php', {method:'get',parameters:"+pars+"})";
																    } else {
																    	hide_item_price(k);
																      $('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																    }
																	  }
  															});				
}

function remove_activity() {
	return;
	document.log_activity.todo.value = 'delete';
	ajax_alert('log_activity', 'system-message', 'ajax/log_activity.php', 0);
}

function register_activity() {
	return;
	document.log_activity.todo.value = 'save';
	ajax_alert('log_activity', 'system-message', 'ajax/log_activity.php', 0);
}

function ajax_alert(formname, divname, ajax_url, interval) {
	var pars = 'entrance=ajax';
	//alert('var f = document.'+formname+';');
	eval('var f = document.'+formname+';');
	var elem = f.elements;
	var flength = elem.length; 	
	for (i=0; i < flength; i++) {
		if ((elem[i].type!='checkbox') || ((elem[i].type='checkbox')&&(elem[i].checked))) {
			pars += '&'+ elem[i].name + '=' + escape(elem[i].value);
		}
		
		if(elem[i].id) {
			if($(elem[i].id).className='wrong_price') {
				$(elem[i].id).className='';
			}		
		}
		
	}		
		
	//$('SYSTEM_MESSAGE').innerHTML = pars;
	div = $(divname);
	//div.innerHTML = "<p>Loading...<\/p>"; 
	var return_message = '';
	if(pars.match(/todo=save/ig)) {
		//$('SYSTEM_BAR').innerHTML = "<p>Saving...<\/p>";
		return_message = 'Successfully Saved!';
	} else {	
		//$('SYSTEM_BAR').innerHTML = "<p>Loading...<\/p>"; 
	}
 
  var myAjax = new Ajax.Request(ajax_url, {method:'post',
  														parameters:pars,
  														  onSuccess: function(transport) {																   
																    if (transport.responseText.match(/ACCESS DENIED/ig)) {
																      revealModal('modalPage');
																    }  else {
																    	div.innerHTML = transport.responseText;	
																    	//alert("ajax_alert('log_activity', 'system_message', 'log_activity.php', "+interval+")");																      
																    	//setTimeout ( "ajax_alert('log_activity', 'system_message', 'log_activity.php', "+interval+")", interval );
																    }																			    											    																    
																  }  																  														
  														});		
}

function ajax_submit(formname, divname, ajax_url, message_bar) {
	var message_bar = message_bar || 'SYSTEM_BAR';
	var pars = 'entrance=ajax';
	//alert('var f = document.'+formname+';');
	eval('var f = document.'+formname+';');
	var elem = f.elements;
	var flength = elem.length; 	
	for (i=0; i < flength; i++) {
		if ((elem[i].type!='checkbox') || ((elem[i].type='checkbox')&&(elem[i].checked))) {
			pars += '&'+ elem[i].name + '=' + escape(elem[i].value);
		}
		
		if(elem[i].id) {
			if($(elem[i].id).className='wrong_price') {
				$(elem[i].id).className='';
			}		
		}
		
	}		
	//$('SYSTEM_MESSAGE').innerHTML = pars;
	div = $(divname);
	//div.innerHTML = "Loading..."; 
	var return_message = '';
	if(pars.match(/todo=save/ig)) {
		$(message_bar).innerHTML = "Saving...";
		return_message = 'Successfully Saved!';
	} else {	
		$(message_bar).innerHTML = "Loading..."; 
	}
  //var myAjax = new Ajax.Updater(div, ajax_url, {method:'post',parameters:pars});	
  var myAjax = new Ajax.Request(ajax_url, {method:'post',
  														parameters:pars,
  														  onSuccess: function(transport) {																   
																    if (transport.responseText.match(/ACCESS DENIED/ig)) {
																      revealModal('modalPage');
																    } else if (transport.responseText.match(/VALIDATION FAILED/ig)) {
																      //alert('Please check it up!');
																      //$('SYSTEM_MESSAGE').innerHTML = transport.responseText;
																      cleanup();
																      $(message_bar).innerHTML = '';
																      warning_els = transport.responseText.split("::");
																      for(var i=1; i < warning_els.length; i++) {
																      	$( warning_els[i]).className="wrong_price";																	      	
																      }																      
																    } else {
																    	cleanup();
																    	$(message_bar).innerHTML = return_message;
																    	setTimeout(" $('" + message_bar + "').innerHTML = '' ", 5000);
																      div.innerHTML = transport.responseText;	
																      load_js();													      
																      run_strict_actions(Array('0', '1'));																      																      
																    }																    																    
																  }  														
  														});		
}

function load_js()
{
	/*if($('jsbuffer')) {
		eval($('jsbuffer').innerHTML);	
	}*/
	
	var divs = document.getElementsByTagName("div");
	for(var i=0; i<divs.length; i++) {
		if(divs[i].className=='jscache') {
			//alert(divs[i].innerHTML);
			js = divs[i].innerHTML;
			js = js.replace(/&amp;/ig, "&");
			js = js.replace(/&lt;/ig, "<");
			eval(js);
			divs[i].innerHTML='';
		}
	}	
}

function cleanup() {
	//alert('haha');
	if(typeof( tabber_conf ) != "undefined") {
		for(var i=0; i<tabber_conf.length; i++) {
			tabber_conf[i]['updated'] = 0;			
		}	
	}
	
	myactions = new Array();
}

function ajax_login(formname, divname, ajax_url) {
	var pars = 'entrance=ajax';
	//alert('var f = document.'+formname+';');
	eval('var f = document.'+formname+';');
	var elem = f.elements;
	var flength = elem.length; 	
	for (i=0; i < flength; i++) {
		if ((elem[i].type!='checkbox') || ((elem[i].type='checkbox')&&(elem[i].checked))) {
			pars += '&'+ elem[i].name + '=' + elem[i].value;
		}
	}		
	//$('SYSTEM_MESSAGE').innerHTML = pars;
	div = $(divname);
	div.innerHTML = "<p>Loading...<\/p>";
  //var myAjax = new Ajax.Updater(div, ajax_url, {method:'post',parameters:pars});	
  var myAjax = new Ajax.Request(ajax_url, {method:'post',
  														parameters:pars,
  														  onSuccess: function(transport) {
  														  		//alert(transport.responseText);	  														  															   
																    if (transport.responseText.match(/INVALID LOGIN/ig)) {
																      div.innerHTML = transport.responseText;
																      revealModal('modalPage');
																    } else if(transport.responseText.match(/WELCOME USER/ig)) {																     
																      div.innerHTML = transport.responseText;
																      hideModal('modalPage');																      
																      run_actions(myactions);
																      myactions = new Array();
																    } else {
																      div.innerHTML = transport.responseText;
																      revealModal('modalPage');																    	
																    }
																  }  														
  														});		
}

function change_description(obj, prd_id) {
	if(0 && savings[1]==1) {				
		if(act_setup=='ask_for_action') {	
			revealModal('modalConfirm');	
			myactions = new Array();	
			myactions[0] = "retrieve_description('"+obj.value+"', "+prd_id+");";			
			myactions[1] = 'savings[1]=0';		
			myactions[2] = "ajax_submit('desc_form', 'tab_desc', 'ajax/prd_desc_update.php')";			
			return;
		} else if(act_setup=='auto_save') {
			ajax_submit('desc_form', 'tab_desc', 'ajax/prd_desc_update.php');
			retrieve_description(obj.value);
			savings[1]=0;
			return;
		} else if(act_setup=='auto_ignore') {
			//nothing	
		}
	}
	
	$('old_website').value = obj.value;
	retrieve_description(obj.value, prd_id);								
}

function change_prd_tab(obj, prd_id) {
	if(0 && savings[1]==1) {				
		if(act_setup=='ask_for_action') {	
			revealModal('modalConfirm');	
			myactions = new Array();	
			myactions[0] = "retrieve_prd_tab('"+obj.value+"', "+prd_id+");";			
			myactions[1] = 'savings[1]=0';		
			myactions[2] = "ajax_submit('desc_form', 'tab_desc', 'ajax/prd_desc_update.php')";			
			return;
		} else if(act_setup=='auto_save') {
			ajax_submit('desc_form', 'tab_desc', 'ajax/prd_desc_update.php');
			retrieve_prd_tab(obj.value);
			savings[1]=0;
			return;
		} else if(act_setup=='auto_ignore') {
			//nothing	
		}
	}
	$('old_prd_tab').value = obj.value;
	retrieve_prd_tab(obj.value, prd_id);								
}

function retrieve_prd_tab(obj, prd_id) {
		$('product_legend').innerHTML = product_tab_names[obj];
		$('prd_tab_view').innerHTML = "<p>Loading...<\/p>";
	 	var pars='todo=pickup&website='+$('website').value+'&prd_id='+prd_id+'&prd_tab='+obj;
	 		 	
    var myAjax = new Ajax.Request('ajax/prd_desc2.php', 
    															{method:'get',
    															parameters:pars,
    															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "var myAjax = new Ajax.Updater('prd_tab_view', 'ajax/prd_desc2.php', {method:'get',parameters:'"+pars+"'});";
																    } else {
																      $('prd_tab_view').innerHTML = transport.responseText;
																      load_js();
																    }
																	  }
    															});								
}

function richedit(prd_id) {
	$('tiny_editor').src='tiny_mce.php?prd_id='+prd_id+'&website='+$('website').value+'&prd_tab='+$('prd_tab').value+'&mode=edit'; 
	show_tiny_mce($('tiny_editor').src); 
	revealModal('tiny_mce');	
}

function rollback() {
	myactions = new Array();	
	if($('website')) {
		if($('old_website').value != $('website').value) {
			$('website').value = $('old_website').value;		
		}	
	}
	
	if($('prd_tab')) {
		if($('old_prd_tab').value != $('prd_tab').value) {
			$('prd_tab').value = $('old_prd_tab').value;		
		}	
	}	
}

function change_category(obj, prd_id) {
	if(0 && savings[6]==1) {				
		if(act_setup=='ask_for_action') {	
			revealModal('modalConfirm');	
			myactions = new Array();	
			myactions[0] = "retrieve_category('"+obj.value+"', "+prd_id+");";			
			myactions[1] = 'savings[6]=0';		
			myactions[2] = "ajax_submit('cate_form', 'tab_cate', 'ajax/prd_cate_update.php')";			
			return;
		} else if(act_setup=='auto_save') {
			ajax_submit('cate_form', 'tab_cate', 'ajax/prd_cate_update.php');
			retrieve_category(obj.value);
			savings[6]=0;
			return;
		} else if(act_setup=='auto_ignore') {
			//nothing	
		}
	}
	
	$('old_web_id').value = obj.value;
	retrieve_category(obj.value, prd_id);								
}

function retrieve_category(value, prd_id) {
		$('tab_cate').innerHTML = "<p>Loading...<\/p>";
	 	var pars='todo=pickup&web_id='+value+'&prd_id='+prd_id;
	 	
	 	//var myAjax = new Ajax.Updater($('tab_cate'), 'ajax/prd_cate.php', {method:'post',parameters:pars});		
    var myAjax = new Ajax.Request('ajax/prd_category.php', 
    															{method:'get',
    															parameters:pars,
    															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "var myAjax = new Ajax.Updater('tab_cate', 'ajax/prd_category.php', {method:'get',parameters:'"+pars+"'});";
																    } else {
																      $('tab_cate').innerHTML = transport.responseText;
																    }
																	  }
    															});	
}

function retrieve_description(value, prd_id) {
		$('tab_desc').innerHTML = "<p>Loading...<\/p>";
	 	var pars='todo=pickup&website='+value+'&prd_id='+prd_id;
	 	
	 	//var myAjax = new Ajax.Updater($('tab_desc'), 'ajax/prd_desc.php', {method:'post',parameters:pars});		
    var myAjax = new Ajax.Request('ajax/prd_desc.php', 
    															{method:'get',
    															parameters:pars,
    															onSuccess: function(transport) {
																	  if (transport.responseText.match(/ACCESS DENIED/ig)){
																      revealModal('modalPage');
																      myactions[0] = "var myAjax = new Ajax.Updater('tab_desc', 'ajax/prd_desc.php', {method:'get',parameters:'"+pars+"'});";
																    } else {
																      $('tab_desc').innerHTML = transport.responseText;
																    }
																	  }
    															});	
}

var desc_href = '';
function hide_tiny_mce() {	
	b = frames['tiny_editor']; 
	if(desc_href != b.location.href) {	
		//alert('have to refresh!');
		//alert(desc_href);
		//alert(b.location.href);
		ajax_submit('desc_form', 'tab_desc', 'ajax/prd_desc_update.php');
	} 
	hideModal('tiny_mce');	
}

function show_tiny_mce(str) {
	desc_href = str;	
}

var edit_mode = false;
function edit_description() {	
	toggle('product_description');
	toggle('btn_edit');
	toggle('btn_preview');
	toggle('view_description');	
	tinyMCE.execCommand('mceAddControl', false, 'product_description');
	edit_mode = true;
}

function preview_description() {
	tinyMCE.execCommand('mceRemoveControl', false, 'product_description');
	toggle('product_description');
	toggle('btn_edit');
	toggle('btn_preview');
	toggle('view_description');	
	edit_mode = false;
}

function item_view_sort(orderby, updown, prd_id) {
	div = $('tab_item');
	div.innerHTML = "<p>Loading...<\/p>";
	var url = 'ajax/prd_item_update.php';
	var pars = 'todo=sort_view&orderby='+orderby+'&updown='+updown+'&prd_id='+prd_id; /* just for example */
	var myAjax = new Ajax.Updater(div, url, {method:'get',parameters:pars});
}

function product_view_sort(orderby, updown) {
	div = $('product_list_div');
	div.innerHTML = "<p>Loading...<\/p>";
	var url = 'ajax/prd_product_list_update.php';
	var pars = 'todo=sort_view&orderby='+orderby+'&updown='+updown; /* just for example */
	var myAjax = new Ajax.Updater(div, url, {method:'get',parameters:pars});
}

function pricelist_view_sort(orderby, updown) {
	div = $('price_list_div');
	div.innerHTML = "<p>Loading...<\/p>";
	var url = 'ajax/prd_price_list_update.php';
	var pars = 'todo=sort_view&orderby='+orderby+'&updown='+updown; /* just for example */
	var myAjax = new Ajax.Updater(div, url, {method:'get',parameters:pars});
}

function taxlist_view_sort(orderby, updown) {
	//div = $('tax_list_div');
	//div.innerHTML = "<p>Loading...<\/p>";
	//var url = 'ajax/prd_tax_list_update.php';
	//var pars = 'todo=sort_view&orderby='+orderby+'&updown='+updown; /* just for example */
	//var myAjax = new Ajax.Updater(div, url, {method:'get',parameters:pars});
	document.tax_list_form.todo.value="sort_view";
	document.tax_list_form.orderby.value=orderby;
	document.tax_list_form.updown.value=updown;
	ajax_submit('tax_list_form', 'tax_list_div', 'ajax/prd_tax_list_update.php')
}

function actlist_view_sort(orderby, updown) {
	//div = $('tax_list_div');
	//div.innerHTML = "<p>Loading...<\/p>";
	//var url = 'ajax/prd_tax_list_update.php';
	//var pars = 'todo=sort_view&orderby='+orderby+'&updown='+updown; /* just for example */
	//var myAjax = new Ajax.Updater(div, url, {method:'get',parameters:pars});
	document.act_list_form.todo.value="sort_view";
	document.act_list_form.orderby.value=orderby;
	document.act_list_form.updown.value=updown;
	ajax_submit('act_list_form', 'act_list_div', 'ajax/act_list_update.php')
}

function loglist_view_sort(orderby, updown) {
	//div = $('tax_list_div');
	//div.innerHTML = "<p>Loading...<\/p>";
	//var url = 'ajax/prd_tax_list_update.php';
	//var pars = 'todo=sort_view&orderby='+orderby+'&updown='+updown; /* just for example */
	//var myAjax = new Ajax.Updater(div, url, {method:'get',parameters:pars});
	document.log_list_form.todo.value="sort_view";
	document.log_list_form.orderby.value=orderby;
	document.log_list_form.updown.value=updown;
	ajax_submit('log_list_form', 'log_list_div', 'ajax/log_list_update.php')
}

function loglist_search() {
	document.log_list_form.todo.value="sort_view";
	document.log_list_form.fixed_order.value=1;
	ajax_submit('log_list_form', 'log_list_div', 'ajax/log_list_update.php')	
}

function salelist_search() {
	document.sale_list_form.todo.value="sort_view";
	document.sale_list_form.fixed_order.value=1;
	ajax_submit('sale_list_form', 'sale_list_div', 'ajax/sale_list_update.php')	
}

function purchaselist_search() {
	document.purchase_list_form.todo.value="sort_view";
	document.purchase_list_form.fixed_order.value=1;
	ajax_submit('purchase_list_form', 'purchase_list_div', 'ajax/purchase_list_update.php')	
}

function shiplist_out_search() {
	document.ship_list_out_form.todo.value="sort_view";
	document.ship_list_out_form.fixed_order.value=1;
	ajax_submit('ship_list_out_form', 'tab_out', 'ajax/ship_list_out_update.php')	
}

function shiplist_in_search() {
	document.ship_list_in_form.todo.value="sort_view";
	document.ship_list_in_form.fixed_order.value=1;
	ajax_submit('ship_list_in_form', 'tab_in', 'ajax/ship_list_in_update.php')	
}

function product_search() {
	document.search_result_form.todo.value="sort_view";
	document.search_result_form.fixed_order.value=1;
	ajax_submit('search_result_form', 'search_result_div', 'ajax/product_result_update.php')	
}
function price_view_sort(orderby, updown, prd_id) {
	div = $('tab_price');
	div.innerHTML = "<p>Loading...<\/p>";
	var url = 'ajax/prd_price_update.php';
	var pars = 'todo=sort_view&orderby='+orderby+'&updown='+updown+'&prd_id='+prd_id; /* just for example */
	var myAjax = new Ajax.Updater(div, url, {method:'get',parameters:pars});
}

function account_view_sort(orderby, updown) {
	div = $('account_list_div');
	div.innerHTML = "<p>Loading...<\/p>";
	var url = 'ajax/acc_list_update.php';
	var pars = 'todo=sort_view&orderby='+orderby+'&updown='+updown; /* just for example */
	var myAjax = new Ajax.Updater(div, url, {method:'get',parameters:pars});
}

function user_view_sort(orderby, updown) {
	div = $('tab_user');
	div.innerHTML = "<p>Loading...<\/p>";
	var url = calls[2];
	var pars = 'todo=sort_view&orderby='+orderby+'&updown='+updown; /* just for example */
	var myAjax = new Ajax.Updater(div, url, {method:'get',parameters:pars});
}

function saveme(tab_id) {
	//savings[tab_id] = 1;
	//$('ajax_save_'+tab_id).className='btn';
}

function tab_updated(tab_name) {
	if (typeof tabber_conf == 'undefined') {
   	return;
	}
	for(var i=0; i < tabber_conf.length; i++) {
		if(tabber_conf[i]['name'] == tab_name) {
			tabber_conf[i]['updated'] = 1; 	
		}	
	}	
}

function tab_released(tab_name) {
	for(var i=0; i < tabber_conf.length; i++) {
		if(tabber_conf[i]['name'] == tab_name) {
			tabber_conf[i]['updated'] = 0; 	
		}	
	}	
}

function ajax_check(formname, divname, ajax_url) {
	var pars = 'entrance=ajax';
	//alert('var f = document.'+formname+';');
	eval('var f = document.'+formname+';');
	var elem = f.elements;
	var flength = elem.length; 	
	for (i=0; i < flength; i++) {
		if ((elem[i].type!='checkbox') || ((elem[i].type='checkbox')&&(elem[i].checked))) {
			pars += '&'+ elem[i].name + '=' + elem[i].value;
		}
	}		
	//$('SYSTEM_MESSAGE').innerHTML = pars;
	div = $(divname);
	//div.innerHTML = "<p>Loading...<\/p>";
  //var myAjax = new Ajax.Updater(div, ajax_url, {method:'post',parameters:pars});	
  var myAjax = new Ajax.Request(ajax_url, {method:'post',
  														parameters:pars,
  														  onSuccess: function(transport) {
  														  		//alert(transport.responseText);	  														  															   
																    if (transport.responseText.match(/INVALID LOGIN/ig)) {
																      div.innerHTML = transport.responseText;
																      revealModal('modalPage');
																    } else if(transport.responseText.match(/WELCOME USER/ig)) {																     
																      div.innerHTML = transport.responseText;
																      hideModal('modalPage');																      
																      run_actions(myactions);
																      myactions = new Array();
																    } else {
																      div.innerHTML = transport.responseText;
																      revealModal('modalPage');																    	
																    }
																  }  														
  														});		
}

//privilege

// and now our improved toggler!
function toggle_obj(obj) {
	var el = $(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '' );
}

// You don't need to change anything in this function:

function update_value(strURL, tbx, id) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage1(self.xmlHttpReq.responseText, id);
}
}
self.xmlHttpReq.send(getquerystring1(tbx, id));	
}

function xmlhttpPost(strURL, chk) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
//$('SYSTEM_MESSAGE').innerHTML = self.xmlHttpReq.responseText;
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring(chk));
}

// The following function obtains two variables from your form (email and message)
// and builds a string that gets sent to your PHP script. Change this function to
// obtain whatever fields you want from your form.

function getquerystring(chk) {
qstr = chk.value;
if(chk.checked) {
	qstr += '&status=1';	
} else {
	qstr += '&status=0';
}
//alert(qstr);
return qstr;
}

function getquerystring1(tbx, id) {
chk = $('p'+id);
qstr = chk.value;
qstr += '&value='+tbx.value;	
//alert(qstr);
return qstr;
}
function updatepage(str){
//document.getElementById("result").innerHTML = str;
//alert(str);
}
function updatepage1(str, id){
	toggle('v'+id);
	toggle('tbx'+id);
	el = $('v'+id);
	el.innerHTML = str;
}

function putIF(hldr,w,h,url) 
       // description of the arguments below
{
   holder=document.getElementById(hldr); //wrap around div
   holder.style.display='block';  // the div gets styled	
   
   /*
   bg=document.getElementById(hldr+'-bg'); //wrap around div
   bg.style.display='block';  // the div gets styled
	 */
	 	
   holder.style.left=(screen.width - parseInt(w))/2 + 'px';
   holder.style.top=(screen.height - parseInt(h))/2 + 'px';
   holder.style.width=parseInt(w) + 2 + 'px';
   holder.innerHTML+='<a href="javascript:void(0)" onclick="closeIF(\'desktop\')"><img src="images/publish_x.png" alt="No" border="0" height="16" width="16"></a>';
   IF=document.createElement('iframe');  // iframe is created in the DOM
   IF.setAttribute('height', h);  // simple DOM methods
   IF.setAttribute('width', w);
   IF.setAttribute("src", url);
   holder.appendChild(IF); // now we add it to the div   
     // final step is to put in additional controls
	 blanket_size();
   toggle('blanket');     
}

function closeIF(obj)
 // the close is simple we just clear out the div
{
   bg=document.getElementById(obj+'-bg'); //wrap around div
   bg.style.display='none';  // the div gets styled	
   holder=document.getElementById(obj); //wrap around div
   holder.style.display='none';  // the div gets styled
   
   holder.innerHTML = '';
   toggle('blanket');
}


function reorder(key) {
	var divs = document.getElementsByTagName("div");
	for(var i=0; i<divs.length; i++) {
		if(divs[i].className==key) {			
			divs[i].style.display=(divs[i].style.display=='none') ? '' : 'none';
		}
	}		
}

function switch_cal(key, opt) {
	if(opt) {
		toggle('span_price_discount_'+key);
		toggle('price_discount_'+key);
		toggle('span_price_unit_'+key);
		toggle('price_unit_'+key);	
	} else {
		toggle('span_price_discount_'+key);
		toggle('price_discount_'+key);
		toggle('span_price_unit_'+key);
		toggle('price_unit_'+key);	
	}
	
	$('price_switch_'+key).value = opt;
	//alert($('price_switch_'+key).value);
} 

function show_shipping_charge() {
		showModalDialog('ship_pickup', 500, 500);		
}


function revealModal1(divID, d_height)
{

}

function showModalDialog(div, d_width, d_height) {
		window.onscroll = function () { 
  		popUpDiv = document.getElementById(div);
			popUpDiv_height=document.documentElement.scrollTop + document.documentElement.clientHeight/2-(d_height/2);
			popUpDiv.style.top = popUpDiv_height + 'px';	
			//alert(document.documentElement.scrollTop);
   	};
    document.getElementById(div).style.display = "block";
    document.getElementById(div).style.top = document.body.scrollTop;    
    blanket_size();
    toggle('blanket');
    
		var blanket = document.getElementById('blanket');
		blanket_height = parseInt(blanket.style.height);
		popUpDiv = document.getElementById(div);
		popUpDiv_height=document.documentElement.scrollTop + document.documentElement.clientHeight/2-(d_height/2);
		popUpDiv.style.top = popUpDiv_height + 'px';
		
		if (typeof window.innerWidth != 'undefined') {
			viewportwidth = window.innerHeight;
		} else {
			viewportwidth = document.documentElement.clientHeight;
		}
		if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
			window_width = viewportwidth;
		} else {
			if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
				window_width = document.body.parentNode.clientWidth;
			} else {
				window_width = document.body.parentNode.scrollWidth;
			}
		}
		
		window_width=window_width/2-(d_width/2);
		popUpDiv.style.left = window_width + 'px';	
																																								
}

function populate_product_ex() {	
	ajax_submit('pickup_sugg', 'filler', 'ajax/update_product_info.php');
	var selObj = document.getElementById('prd_id');
  for (var i = 1; i < selObj.options.length; i++) {
    //selObj.options[i] = null;
    selObj.remove(i);
  }
  selObj.options.length=1;
}	

function add_item_continue_ex() {
	toggle('blanket');
	toggle('win_xp3');	
	ajax_submit('cate_form', 'sugg_div', 'ajax/prd_sugg_update.php');
}

function add_item_sale() {
	//alert(cur_sku_id);
	//document.items_form.new_item_sku.value = 'haha'
	$(cur_sku_id).value = document.items_form.new_item_sku.value;
	toggle('blanket');
	toggle('item_pickup');	
	//alert(document.items_form.new_item_sku.value);
}

function add_item_purchase() {
	$(cur_sku_id).value = document.items_form.new_item_sku.value;
	toggle('blanket');
	toggle('item_pickup');	
	//ajax_submit('items_form', 'tab_items', 'ajax/purchase_items_update.php', 'pmb_add_item');
}

function add_coupon_continue_ex() {
	toggle('blanket');
	toggle('coupon_pickup');	
	ajax_submit('items_form', 'tab_items', 'ajax/sale_items_update.php')
}

function switch_coupon_type(v) {	
	switch(v)
	{
	case '1':
	  hidden_obj('div_prd'); 
	  $('applied_on').value='';
	  
	  break;    
	case '2':
	  hidden_obj('div_prd'); 
	  $('applied_on').value='applied_on_items';
	  break;
	case '3':
	  show_obj('div_prd'); 
	  $('applied_on').value='applied_on_product';
	  break;
	}	
}

function number_format( number, decimals, dec_point, thousands_sep ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://crestidg.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57     
 
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "." : dec_point;
    var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}

function build() {
	toggle('blanket');
	toggle('item_pickup');	
	ajax_submit('items_form', 'tab_info', 'ajax/build_info_update.php');
}

function transfer() {
	toggle('blanket');
	toggle('item_pickup');	
	ajax_submit('items_form', 'tab_info', 'ajax/transfer_info_update.php');
}
