
/////////////////////////////////////////////////////////////////////////////
//debugging functions
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////testing and stuff

function set_new_visitor_id(value) {
	var new_visitor_id = value+",,1,0";
	create_cookie('visitor', new_visitor_id);
	alert("Visitor ID is now: "+value);
	return;
}


function test_call(product_code) {
	alert("Pulling all "+product_code+" from shopping_cart db");
	getTESTContents(product_code);
}

function test_call2(visitor_id) {
	alert("Pulling all "+visitor_id+" items from shopping_cart db");
	getTESTContents2(visitor_id);
}

function sendTESTContents(cart_data) {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/TEST.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/TEST.php";
		} else { alert(error_sorry);}
//	var myurl = "http://www.acclaimimages.com/studio/php/TEST.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand;
	myRequest.open("POST", modurl, true);
	myRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	myRequest.send('cart_data='+cart_data);

	myRequest.onreadystatechange = testResponse;

}

function getTESTContents(product_code) {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/TEST.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/TEST.php";
		} else { alert(error_sorry);}
//	var myurl = "http://www.acclaimimages.com/studio/php/TEST.php";
	var myRand = parseInt(Math.random()*9999999999);
	var modurl = myurl +"?rand="+myRand+"&product_code="+product_code;
	myRequest.open("GET", modurl, true);
	myRequest.onreadystatechange = testResponse;
	myRequest.send(null);
}

function getTESTContents2(visitor_id) {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/TEST2.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/TEST2.php";
		} else { alert(error_sorry);}
//	var myurl = "http://www.acclaimimages.com/studio/php/TEST2.php";
	var myRand = parseInt(Math.random()*9999999999);
	var modurl = myurl +"?rand="+myRand+"&visitor_id="+visitor_id;
	myRequest.open("GET", modurl, true);
	myRequest.onreadystatechange = testResponse;
	myRequest.send(null);
}

function testResponse() {
	if (myRequest.readyState ==4) {
		if (myRequest.status == 200) {
			var myText = myRequest.responseText;
			document.getElementById('cartbox').innerHTML = myText;
			}
		} 
		else {
		document.getElementById('cartbox').innerHTML = '<img src="throbber.gif">';
	}
}

function fresh_visitor() {
	kill_cookie('visitor');
	create_visitor_id();
	return;
}

function add_image_to_cart(image_numbers) {
	image_numbers = image_numbers.replace(/ /g, "");
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/get_old_image_info.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/get_old_image_info.php";
		} else { alert(error_sorry);}
//	var myurl = "http://www.acclaimimages.com/studio/php/get_old_image_info.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand;
	myRequest.open("POST", modurl, true);
	myRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	myRequest.send("&image_numbers="+image_numbers);
	myRequest.onreadystatechange = addToCartResponse;
}


function addToCartResponse() {
	if (myRequest.readyState ==4) {
		if (myRequest.status == 200) {
			var reply = myRequest.responseText;
			var string_of_images = reply.split("::");
			document.getElementById('wait').innerHTML = string_of_images[1];
			lb_digital_to_cart (string_of_images[0]);
			}
		} else {
		document.getElementById('wait').innerHTML = '<img src="throbber.gif">';
	}
}

function clean_up_db_mess() {	// Dec 4, 2007 Vsitor db breakdown error message clean-up
	if (document.cookie && document.cookie.indexOf('visitor') > -1) {
		visitor_info = read_cookie('visitor').split(',');
		if (visitor_info[0].indexOf(' ') > -1) {
			fresh_visitor();
			}
		}
	return;
}

/////////////////////////////////////////////////////////////////////////////
//debugging functions - end
/////////////////////////////////////////////////////////////////////////////


function initialize() {  //this is in the body tag as an onLoad, so things can be added here
	create_visitor_id();
//	quickie();
//	clean_up_db_mess(); // Dec 4, 2007 Vsitor db breakdown error message clean-up
//	x_marks_the_spot('http://www.acclaimimages.com/_gallery/_pages/0013-0505-2411-4513.html');
	return;
}

function x_marks_the_spot(treasure) {
	if (parent.document.location==treasure){alert("Hi Guys!");}
	return;
}

function create_visitor_id() { // fundamental 'if we don't know them, get them an id'
	var visitor_info = [];  // added by Barb - 05/22/08 - add an [3] to the visitor cookie
	if (document.cookie && document.cookie.indexOf('visitor') > -1) {
		visitor_info = read_cookie('visitor').split(',');  // added by Barb - 05/22/08
		if (visitor_info[3] == ''){ create_cookie('visitor', visitor_info[0]+','+visitor_info[1]+','+visitor_info[2]+',0');}  // added by Barb - 05/22/08 
		return;
		} else {
		getNewVisitorId();
		}
	return;
}


function check_visitor(){  // the basic 'return an id' call
	var visitor_info = [];
	if (document.cookie && document.cookie.indexOf('visitor') > -1) {
		visitor_info = read_cookie('visitor').split(',');
		} else {
		create_visitor_id();
		visitor_info = read_cookie('visitor').split(',');
		}
	if (visitor_info[0].indexOf(' ') > -1) {alert("An error has occured with your Visitor ID. "+error_sorry);}  //check for bogus Visitor IDs
	return visitor_info;
}


function popUp_reminder() {
	var visitor_info = [];
	visitor_info = read_cookie('visitor').split(',');
	if (visitor_info[3] !== '1') {
		create_cookie('visitor', visitor_info[0]+','+visitor_info[1]+','+visitor_info[2]+',1');
		alert("Reminder - Your Browser must allow Pop-ups to use the features of this site.");
		return true;
		}
	return true;
}


function cart_window(){
	var hgt = screen.height-100;
	var wdt= screen.width-300;
	var win_properties = 'directories=no,height='+hgt+',location=no,menubar=no';
	win_properties += ',resizable=yes,scrollbars=yes, status=no,toolbar=no,width='+wdt+',top=0,left=0';
	var cart_win = window.open("http://www.acclaimimages.com/studio/cart.html", "cart_win", win_properties);
	popUp_reminder();
	cart_win.focus();
	return;
}

function convert_cart(){ //this converts the old 'myCart' cookie to a db driven cart - may be depricated May 1, 2007
	if (document.cookie && document.cookie.indexOf('myCart') > -1)	{
	var cart_data = read_cookie('myCart');	
	kill_cookie('myCart');
	var visitor_info = read_cookie('visitor').split(',');
	sendCartContents(visitor_info[0], cart_data);
	}
	return;
}


/////////////////////////////////////////////////////////// single add of print from studio to cart db
function printStudio_to_db() {
	var visitor_info = check_visitor();
	var info = read_cookie('printStudio').split(',');
	var cart_data = info.join("|");
	sendCartContents(visitor_info[0], cart_data);
}

/////////////////////////////////////////////////////////// single add of image from calc to cart db
function calc_to_db() {
	var visitor_info = check_visitor();
	var info = read_cookie('calcCookie').split(',');
	var cart_data = info[0]+"|"+info[1]+"|"+info[2];
	sendCartContents(visitor_info[0], cart_data);
}

/////////////////////////////////////////////////////////// group or single add of defaulted print
function from_lightbox(string_of_prints) { // just for prints
	var answer = confirm("Prints are for personal decor use only and may not be copied or reproduced. Would you like to continue?");
	if (answer){
		var visitor_info = read_cookie('visitor').split(',');
		var next_num = give_item_number(0)*1;
		var calc_string = ""; // this is just used for digital
		sendPrintLBContents(visitor_info[0], string_of_prints, next_num, calc_string);
		return;
	} else { return;}
}

function sendPrintLBContents(visitor_id, cart_data, next_num, calc_string) {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/print_LB_to_cart.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/print_LB_to_cart.php";
		} else { alert(error_sorry);}
//	var myurl = "http://www.acclaimimages.com/studio/php/print_LB_to_cart.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand;
	myRequest.open("POST", modurl, true);
	myRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	myRequest.send("&visitor_id="+visitor_id+"&cart_data="+cart_data+"&next_num="+next_num+"&calc_string="+calc_string);
	myRequest.onreadystatechange = LBaddResponse;

}
/////////////////////////////////////////////////////////// group or single add of unpriced image
function lb_digital_to_cart (string_of_images) { // for digital images
	now_Y=now_Y.toString();
	if (now_Y.length < 4) {now_Y=now_Y-0+1900;}
	var calc_string = '0|-1|-1|-1|-1|-1|-1|'+now_D+'|'+now_M+'|'+now_Y+'|-1|||-1';
	var visitor_info = read_cookie('visitor').split(',');
	var next_num = give_item_number(0)*1;
	sendDigitalLBContents(visitor_info[0], string_of_images, next_num*1, calc_string);
	return;
}

function sendDigitalLBContents(visitor_id, cart_data, next_num, calc_string) {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/digital_LB_to_cart.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/digital_LB_to_cart.php";
		} else { alert(error_sorry);}
//	var myurl = "http://www.acclaimimages.com/studio/php/digital_LB_to_cart.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand;
	myRequest.open("POST", modurl, true);
	myRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	myRequest.send("&visitor_id="+visitor_id+"&cart_data="+cart_data+"&next_num="+next_num+"&calc_string="+calc_string);
	myRequest.onreadystatechange = LBaddResponse;

}
////the response for both images and prints from LB to cart
function LBaddResponse() {
	if (myRequest.readyState ==4) {
		if (myRequest.status == 200) {
			var myText = myRequest.responseText;
			var new_count = myText.split('::'); //yeah, it's a band-aid
			create_cookie('itemCount',(new_count[0]*1));
//			LBconfirm_pop();
			cart_window();
			}
		} 

}

/////////////////////////////////////////////////////////////////////////////
//ajax
/////////////////////////////////////////////////////////////////////////////
function getXMLHTTPRequest() {
	try {
	req = new XMLHttpRequest();
	} catch(err1) {
		try {
		req = new ActiveXObject("Mszm12.XMLHTTP");
		} catch(err2) {
			try {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(err3) {
				req = false;
			}
		}
	}
	return req;
}
	
var myRequest = getXMLHTTPRequest();

function getNewVisitorId() {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/create_visitor_id.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/create_visitor_id.php";
		} else { alert(error_sorry);}

	var myRand = parseInt(Math.random()*9999999999);
	var modurl = myurl+"?rand="+myRand;
	myRequest.open("POST", modurl, true);
	myRequest.onreadystatechange = create_visitor_idResponse;
	myRequest.send(null);
}

//
//function quickie() {
//	if (document.cookie && document.cookie.indexOf('visitor') > -1) {var visitor_info = read_cookie('visitor').split(',');}
//	if (visitor_info[0] == '857') {
//		if (location.href.charAt(9) == 'w') {
//		alert("www page");
//		} else if (location.href.charAt(9) == 'c') {
//		alert(" not a www page");
//		} else { alert('oops!');}
//	}
//	return;
//}


function create_visitor_idResponse() {//callback
	if (myRequest.readyState == 4) {
		if (myRequest.status == 200) {
			var myText = myRequest.responseText;
			var info = myText.split('::'); //yeah, it's a band-aid
			create_cookie('visitor', info[0]);
//			convert_cart(); // depricated Dec 14, 2007
		}
	} 
}



function basicDoNothingResponse() {
	if (myRequest.readyState ==4) {
		if (myRequest.status == 200) {
			var myText = myRequest.responseText;
//			document.getElementById('td1').innerHTML = "";
			}
		} 
//		else {
//		document.getElementById('td1').innerHTML = '<img src="throbber.gif">';
//	}
}


//////add

function sendCartContents(visitor_id, cart_data) {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/add_to_cart.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/add_to_cart.php";
		} else { alert(error_sorry);}
//	var myurl = "http://www.acclaimimages.com/studio/php/add_to_cart.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand+"&visitor_id="+visitor_id+"&cart_data="+cart_data;
	myRequest.open("GET", modurl, true);
	myRequest.send(null);
	myRequest.onreadystatechange = basicDoNothingResponse;

}

//////get cart 
function get_cart_loaded() { //this is an onLoad function wth cart.html
	var visitor_info = check_visitor();
	getCartContents(visitor_info[0]);
}

function getCartContents(visitor_id) {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/get_cart_load.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/get_cart_load.php";
		} else { alert(error_sorry);}
//	var myurl = "http://www.acclaimimages.com/studio/php/get_cart_load.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand+"&visitor_id="+visitor_id;
	myRequest.open("GET", modurl, true);
	myRequest.onreadystatechange = getCartContentsResponse;
	myRequest.send(null);
}

function getCartContentsResponse() {
	if (myRequest.readyState == 4) {
		if (myRequest.status == 200) {
			var messy_cart_data = myRequest.responseText;
			var hold_cart = messy_cart_data.split("::");
			var ready_cart = [];
				for (i = 1; i < hold_cart.length-1; i++){	// yet another freakin bandaid
				ready_cart[i-1] = hold_cart[i];
				}
			}
		if (ready_cart == "") {
//			alert("There is nothing in your cart.");
			document.getElementById('cartbox').innerHTML = "Your shopping cart is empty.<p>If you are experiencing problems please call customer service at 888-618-8723 (toll-free) or 541-618-8723.<P><a href=\"javascript:window.close();\"><font color='red'>close this window</font></a>";
			} else {
			display_cart(ready_cart);
			}	
		} else {
		document.getElementById('cartbox').innerHTML = '<img src="throbber.gif">';
	}
}

//////get cust ac info

function check_custAC_shipping() { //this is an onLoad function wth cart.html
	var visitor_info = check_visitor();
	getcustAC_shipping(visitor_info[0]);
}

function getcustAC_shipping(visitor_id) {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/get_cart_load.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/get_cart_load.php";
		} else { alert(error_sorry);}
//	var myurl = "https://www.acclaimimages.com/studio/php/get_cart_load.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand+"&visitor_id="+visitor_id;
	myRequest.open("GET", modurl, true);
	myRequest.onreadystatechange = getcustAC_shippingResponse;
	myRequest.send(null);
}

function getcustAC_shippingResponse() {
	if (myRequest.readyState ==4) {
		if (myRequest.status == 200) {
			var custAC_text = "";
			var have_digital = 0;
			var have_shipping = 0;
			var messy_cart_data = myRequest.responseText;
			var hold_cart = messy_cart_data.split("::");
			var ready_cart = [];
				for (i = 1; i < hold_cart.length-1; i++){	// yet another freakin bandaid
				ready_cart[i-1] = hold_cart[i];
				}
				for (i = 0; i < ready_cart.length; i++){
					var info = ready_cart[i].split('|');
					if (info[5] == 'PR') {
					have_shipping = 1;
					} else if (info[5] == 'RM') {
					have_digital = 1;
					custAC_text += info[5]+"|"+info[20]+"|"+info[6]+"|"+RM_EULA(info)+",";
					} else if (info[5] == 'RF') {
					have_digital = 1;
					custAC_text += info[5]+"|"+info[20]+"|"+info[6]+"|"+RF_res[info[17]]+"|"+RF_EULA(info)+",";
					}
				}
				load_custAC_form(have_digital, have_shipping);
				document.getElementById('xbox').focus();
				document.getElementById('xbox').style.visibility = "hidden";
			}

		} else {
		document.getElementById('xbox').innerHTML = '<img src="throbber.gif">';
		document.getElementById('xbox').style.visibility = "visible";
	}
}



//////get e_comm
function get_e_comm_loaded() { 
	var visitor_info = check_visitor();
	get_e_commContents(visitor_info[0]);
}

function get_e_commContents(visitor_id) {
//	if (location.href.charAt(9) == 'w') { 	//   Sept 11, 2008 Barb changes to fix 'www' bug
//		var myurl = "http://www.acclaimimages.com/studio/php/get_cart_load.php";
//		} else if (location.href.charAt(9) == 'c') { 
//		var myurl = "http://acclaimimages.com/studio/php/get_cart_load.php";
//		} else { alert(error_sorry);}
	var myurl = "https://www.acclaimimages.com/studio/php/get_cart_load.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand+"&visitor_id="+visitor_id;
	myRequest.open("POST", modurl, true);
	myRequest.onreadystatechange = get_e_commContentsResponse;
	myRequest.send(null);
}

function get_e_commContentsResponse() {
	if (myRequest.readyState == 4) {
		if (myRequest.status == 200) {
			var messy_cart_data = myRequest.responseText;
			var hold_cart = messy_cart_data.split("::");
			var ready_cart = [];
				for (i = 1; i < hold_cart.length-1; i++){	// yet another freakin bandaid
				ready_cart[i-1] = hold_cart[i];
				}
			}
		if (parent.document.location=="https://www.acclaimimages.com/studio/customSalesInput.html"){get_cust_pricing_loaded();}
			else if (parent.document.location=="https://www.acclaimimages.com/studio/cust_Sale_All_Disc.html"){get_cust_pricing_loaded();}
			else if (parent.document.location=="https://www.acclaimimages.com/studio/cust_Sale_Item_Disc.html"){get_cust_pricing_loaded();}
			else {get_order_out(ready_cart);}
		document.getElementById('xbox').focus();
		document.getElementById('xbox').style.visibility = "hidden";
		} else {
		document.getElementById('xbox').innerHTML = '<img src="throbber.gif">';
		document.getElementById('xbox').style.visibility = "visible";
	}
}


//////check out shipping
function get_shipping_loaded() {
	var visitor_info = check_visitor();
	get_shippingContents(visitor_info[0]);
}

function get_shippingContents(visitor_id) {
//	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
//		var myurl = "http://www.acclaimimages.com/studio/php/get_cart_load.php";
//		} else if (location.href.charAt(9) == 'c') {
//		var myurl = "http://acclaimimages.com/studio/php/get_cart_load.php";
//		} else { alert(error_sorry);}
	var myurl = "https://www.acclaimimages.com/studio/php/get_cart_load.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand+"&visitor_id="+visitor_id;
	myRequest.open("POST", modurl, true);
	myRequest.onreadystatechange = get_shippingContentsResponse;
	myRequest.send(null);
}

function get_shippingContentsResponse() {
	if (myRequest.readyState == 4) {
		if (myRequest.status == 200) {
			var messy_cart_data = myRequest.responseText;
			var hold_cart = messy_cart_data.split("::");
			var ready_cart = [];
				for (i = 1; i < hold_cart.length-1; i++){	// yet another freakin bandaid
				ready_cart[i-1] = hold_cart[i];
				}
			}
		find_shipping(ready_cart);
		document.getElementById('xbox').focus();
		document.getElementById('xbox').style.visibility = "hidden";
		} else {
		document.getElementById('xbox').innerHTML = '<img src="throbber.gif">';
		document.getElementById('xbox').style.visibility = "visible";
	}
}

//////update
function updateCartContents(visitor_id, cart_data) {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/update_cart.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/update_cart.php";
		} else { alert(error_sorry);}
//	var myurl = "http://www.acclaimimages.com/studio/php/update_cart.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand+"&visitor_id="+visitor_id+"&cart_data="+cart_data;
	myRequest.open("GET", modurl, true);
	myRequest.onreadystatechange = basicDoNothingResponse;
	myRequest.send(null);
}

//////delete
function empty_cart(){
	delete_from_cart('all');
	kill_cookie('myCart');
	kill_cookie('myShipping');
	kill_cookie('itemCount');
	kill_cookie('myPurchase');
	window.close();
	return;
}

function delete_from_cart(item_number_array){
	var visitor_info = read_cookie('visitor').split(',');
	deleteCartContents(visitor_info[0], item_number_array);
	return;
}

function deleteCartContents(visitor_id, item_number_array) {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "http://www.acclaimimages.com/studio/php/delete_from_cart.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "http://acclaimimages.com/studio/php/delete_from_cart.php";
		} else { alert(error_sorry);}
//	var myurl = "http://www.acclaimimages.com/studio/php/delete_from_cart.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand+"&visitor_id="+visitor_id+"&item_number_array="+item_number_array;
	myRequest.open("GET", modurl, true);
	myRequest.onreadystatechange = basicRefreshCartResponse;
	myRequest.send(null);
}


//////generic

function basicRefreshCartResponse() {
	if (myRequest.readyState ==4) {
		if (myRequest.status == 200) {
			var myText = myRequest.responseText;
			document.getElementById('cartbox').innerHTML = "";
			get_cart_loaded();
			}
		} else {
		document.getElementById('cartbox').innerHTML = '<img src="throbber.gif">';
	}
}



//////get custom pricing cart 

function get_cust_pricing_loaded() { 
	var visitor_info = check_visitor();
	get_cust_pricingContents(visitor_info[0]);
}

function get_cust_pricingContents(visitor_id) {
//	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
//		var myurl = "http://www.acclaimimages.com/studio/php/get_cart_load.php";
//		} else if (location.href.charAt(9) == 'c') {
//		var myurl = "http://acclaimimages.com/studio/php/get_cart_load.php";
//		} else { alert(error_sorry);}
	var myurl = "https://www.acclaimimages.com/studio/php/get_cart_load.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand+"&visitor_id="+visitor_id;
	myRequest.open("POST", modurl, true);
	myRequest.onreadystatechange = get_cust_pricingContentsResponse;
	myRequest.send(null);
}

function get_cust_pricingContentsResponse() {
	if (myRequest.readyState == 4) {
		if (myRequest.status == 200) {
			var messy_cart_data = myRequest.responseText;
			var hold_cart = messy_cart_data.split("::");
			var ready_cart = [];
				for (i = 1; i < hold_cart.length-1; i++){	// yet another freakin bandaid
				ready_cart[i-1] = hold_cart[i];
				}
			}
		display_handAddCart(ready_cart);
		document.getElementById('xbox').focus();
		document.getElementById('xbox').style.visibility = "hidden";
		} else {
		document.getElementById('xbox').innerHTML = '<img src="throbber.gif">';
		document.getElementById('xbox').style.visibility = "visible";
	}
}

/////////////////////////////////address stuff
function addr_window(){
	var hgt = screen.height-100;
	var wdt= screen.width-300;
	var win_properties = 'directories=no,height='+hgt+',location=no,menubar=no';
	win_properties += ',resizable=yes,scrollbars=yes, status=no,toolbar=no,width='+wdt+',top=0,left=0';
	cart_win = window.open("https://www.acclaimimages.com/studio/addressForm.html", "cart_win", win_properties);
	popUp_reminder();
	cart_win.focus();
}

function load_country_drop(version) {
	if (location.href.charAt(9) == 'w') {	//   Sept 11, 2008 Barb changes to fix 'www' bug
		var myurl = "https://www.acclaimimages.com/studio/php/get_country.php";
		} else if (location.href.charAt(9) == 'c') {
		var myurl = "https://acclaimimages.com/studio/php/get_country.php";
		} else { alert(error_sorry);}
//	var myurl = "https://www.acclaimimages.com/studio/php/get_country.php";
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand+"&version="+version;
	myRequest.open("GET", modurl, true);
	myRequest.onreadystatechange = country_dropResponse;
	myRequest.send(null);
}

function country_dropResponse() {
	if (myRequest.readyState ==4) {
		if (myRequest.status == 200) {
			var myText = myRequest.responseText;
			var info = myText.split("::");
			if (info[0] == 'b') {
				get_e_comm_loaded();
				document.getElementById('billing_country').innerHTML = info[1];
				document.getElementById('shipping_country').innerHTML = "";
				} else if (info[0] == 's') {
				document.getElementById('shipping_country').innerHTML = info[1];
				document.getElementById('countryBox1').style.visibility = "visible";
				document.getElementById('countryBox2').style.visibility = "visible";
				document.getElementById('xbox').focus();
				document.getElementById('xbox').style.visibility = "hidden";
				}
			}
		} else {
		document.getElementById('xbox').innerHTML = '<img src="throbber.gif">';
		document.getElementById('xbox').style.visibility = "visible";
	}
}

function load_state_prov_terr_co_drop(place, place_title, version) {
	if (version == 'b') {
		var myurl = "https://www.acclaimimages.com/studio/php/get_b_state_prov_terr_co.php";
		} else if (version == 's') {
		var myurl = "https://www.acclaimimages.com/studio/php/get_s_state_prov_terr_co.php";
		}else if (version == 'a') {
		var myurl = "https://www.acclaimimages.com/studio/php/get_a_state_prov_terr_co.php";
		}
	var myRand = parseInt(Math.random()*99999999);
	var modurl = myurl +"?rand="+myRand+"&place="+place+"&place_title="+place_title+"&version="+version;
	myRequest.open("GET", modurl, true);
	myRequest.onreadystatechange = load_state_prov_terr_co_dropResponse;
	myRequest.send(null);
}

function load_state_prov_terr_co_dropResponse() {
	if (myRequest.readyState ==4) {
		if (myRequest.status == 200) {
			var myText = myRequest.responseText;
			var info = myText.split("::");
			if (info[0] == 'b') {
				document.getElementById('billing_address').innerHTML = info[1];
				document.getElementById('shipping_addressBox').innerHTML = "";
				} else if (info[0] == 's') {
				document.getElementById('shipping_addressBox').innerHTML = info[1];
				}
			document.getElementById('xbox').focus();
			document.getElementById('xbox').style.visibility = "hidden";
			}
		} else {
		document.getElementById('xbox').innerHTML = '<img src="throbber.gif">';
		document.getElementById('xbox').style.visibility = "visible";
	}
	document.getElementById('shipbox').style.visibility = "visible";
}

function shipping_address() {
	load_country_drop('s');
}
/////////////////////////////////////////////////////////////////////////////
//ajax - end
/////////////////////////////////////////////////////////////////////////////







function make_employee_cookie(employee_login_number) {

	document.cookie = "employee="+employee_login_number+"; expires; path=/;";
	document.cookie = "test=testing; "+expires+"; path=/;";
	return;
}
function kill_employee_cookie() {
	var order = "; ";
	var date = new Date();
	date.setTime(date.getTime()+(-1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "employee="+order+expires+"; path=/;";
	return;
}






