//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Shopping Cart, Version 3.1
//// This code is Copyright (c) 2005 - 2006 Acclaim Images, all rights reserved.
//// This code may not be used without the express written permission 
//// of Acclaim Images.
//// Written by Barbara Mikula of AcclaimImages.com
//// If interested in using this code please contact fred@acclaimimages.com
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// these are the sizing, pricing, etc variables for print sales
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var pft = 1.5;									//the profit we want to figure in on framing
var dpi = 149;									//the dpi that we want to print out at

var long_side=[60,40,36,30,20,14,10];				//the long side of available prints
var short_side=[40,30,24,20,16,11,8];				//the short side of available prints
var start_price1=[525.00,275.00,200.00,145.00,95.00,60.00,40.00];		//paper print prices
var start_price2=[900.00,500.00,385.00,270.00,180.00,120.00,80.00];	//canvas prices
var price1=[-1,-1,-1,-1,-1,-1,-1,-1];
var price2=[-1,-1,-1,-1,-1,-1,-1,-1];

var mat_charge = 0.03;									//the price per sq inch on mats
var reg_acrylic_price = 0.05;
var ng_acrylic_price = 0.07;
var glazing_choice=['None', 'Regular Acrylic', 'Non-glare Acrylic'];
var shipping_charge = 0;
var ship=[0.00,10.00, 20.00, 60.00, 40.00, 120.00];	//rates for [digital, reg flat US, express flat US, international flat, US framed (12 lb), international framed (12 lb)]
var medium_choice=['None', 'Archival Quality Matte Paper', 'Archival Quality Gloss Paper', 'Stretched Canvas'];

//frame codes divided by print medium
//paper
var frame_codes1=['None', 'DA380', 'DA300', 'DA200', 'DA100'];
var frame_names1=['None','3/4\" Flat Wood','7/16\" Flat Aluminum','5/8\" Clamshell Aluminum','5/16\" Clamshell Aluminum'];
var frame_by_inch1=[0.00, 0.83, 0.47, 0.45, 0.33];
//canvas
var frame_codes2=['None','DA387','DA005','DA153','DA197','DA198'];
var frame_names2=['None','3\" Walnut & Black w/linen','2 1/2\" Oak w/linen','3\" Walnut w/linen','3\" Silver Finish w/linen','3\" Gold Finish w/linen'];
var frame_by_inch2=[0.00, 1.00, 1.05, 1.25, 1.25, 1.25];

var PU_prices = [0.00, 69.95]; // make sure this is consistent with the df pages
var PU_confirm_count = 0; // this so you only get the warning once in a series
var PU_warning = "This version is for personal decor use only - either as a print or electronically. If you would like to use it for any other purpose please click 'Cancel' to go back and license this image as stock.      If you would like to continue, please click 'OK'.";

var IC_prices = [0.00, 250.00, 300.00];   //// this needs to be on cartDescriptions.js, cartScripts.js, and RMdefinitions.js as well - make sure they match

var tax = 0.00;
var print_img_price_list = "";
var special_instructions = "";
var aid = "";
var acclaim_sales_ID = "";
var error_sorry = 'We cannot process your request at this time. Please call our Customer Service line, toll free (888) 618-8723 or (541) 618-8723.';
var print_message = 'Prints are for personal decor use only and may not be copied or reproduced. Would you like to continue?';

var now = new Date();	
var now_D = now.getDate();
var now_M = now.getMonth();
var now_Y = now.getYear();

var conv_px_width = 0;
var conv_px_height = 0;

var have_shipping = 0;

var custAC = "";
var custAC_text = "";

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// these are general cookie handling functions
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function cookies_Ok(){
	var test_string = "";
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "test=testing; "+expires+"; path=/;";
	test_string = read_cookie('test');
	if (test_string == null) {
		alert('Your browser does not support our cookies and you will not be able to price or purchase images online. Please contact our Customer Services department during our regular business hours at the bottom of this page for assistance.');
		kill_cookie2('test');
		} else {kill_cookie2('test');}
	return;
}

function kill_cookie2(name) {
	var order = "; ";
	var date = new Date();
	date.setTime(date.getTime()+(-1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();

	document.cookie = name+"="+order+expires+"; path=/;";
	return;
}

function create_cookie(name,value) {
	var order = value + "; ";
	var date = new Date();
	date.setTime(date.getTime()+(180*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = name+"="+order+expires+"; path=/; domain=.acclaimimages.com;";
	return;
}

///////////////// ADDED BY FRED FOR VISITOR LOGINS ON 012407
function create_session_cookie(name,value) {
	var order = value + "; ";
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = name+"="+order+expires+"; path=/; domain=.acclaimimages.com;";
	return;
}

function read_cookie(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 kill_cookie(name) {
	var order = "; ";
	var date = new Date();
	date.setTime(date.getTime()+(-1*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();

	document.cookie = name+"="+order+expires+"; path=/; domain=.acclaimimages.com;";
	return;
}

function load_variable_array(name) {
	var info = [];
	info = read_cookie(name).split(',');
	return info;
}

function set_price1(){
	var info = load_variable_array('printStudio');
	for (i = 0; i < start_price1.length; i++){
	price1[i]=start_price1[i]*info[23];
	}
	return price1;
}


function set_price2(){
	var info = load_variable_array('printStudio');
	for (i = 0; i < start_price2.length; i++){
	price2[i]=start_price2[i]*info[23];
	}
	return price2;
}

function change_cookie_element(index_pos, new_value) {
	var info = load_variable_array('printStudio');
	info.splice(index_pos,1, new_value);
	var date = new Date();
	date.setTime(date.getTime()+(180*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "printStudio="+info+expires+"; path=/; domain=.acclaimimages.com;";
	return;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// going to the print set-up
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function get_defaults()	{
// REM: IF YOU WORK ON THIS TO COPY IT OVER TO PRstudio.js - IT HAS TO BE IDENTICAL ON BOTH
	var info = load_variable_array('printStudio');
	price1=set_price1();
	price2=set_price2();
	var pixel_width = info[8]*1;
	var pixel_height=info[9]*1;
	var print_medium = info[13]*1;
	var print_width = info[10]*1;
	var measure = 0;

	if (pixel_width > pixel_height) {measure = Math.ceil(pixel_width/dpi);}	
		else {measure = Math.ceil(pixel_height/dpi);}

	if (print_width == 0){
		var largest = 1;
		for (i = 0; i < long_side.length; i++){
			if ((long_side[i]<measure)&&(largest==1)){ 
				change_cookie_element(10, short_side[i]);
				change_cookie_element(11, long_side[i]);
				if (print_medium==0){
					change_cookie_element(13, 1);
					change_cookie_element(12, price1[i]);
					change_cookie_element(22, price1[i]);
				} else if (print_medium==1){change_cookie_element(12, price1[i]); change_cookie_element(22, price1[i]);}
				else if (print_medium==2){change_cookie_element(12, price1[i]); change_cookie_element(22, price1[i]);}
				else if (print_medium==3){change_cookie_element(12, price2[i]); change_cookie_element(22, price2[i]);}
				else {alert(error_sorry);}
				largest=0;
				}
			}
		}
}

function buy_print(product_code,image,caption,pixel_width,pixel_height,price_factor) {
calc_price(product_code,image);
// 26/Apr/2007 13:06 kenny
//	var answer = confirm(print_message);
//	if (answer){
//	create_print_cookie(product_code,image,pixel_width,pixel_height,price_factor);	
//	studio_window();
//	return;
//	} else {return;}
}

function buy_print2(product_code,image,caption,pixel_width,pixel_height,price_factor) {
calc_price(product_code,image);
// 27/Apr/2007 9:14 kenny
//	var answer = confirm(print_message);
//	
//	if (answer){
//	create_print_cookie(product_code,image,pixel_width,pixel_height,price_factor);	
//	window.location="http://www.acclaimimages.com/studio/studio.html"; 
//	return false;
//	}

}

function create_print_cookie(product_code,image,pixel_width,pixel_height, price_factor)	{

// this next chunk of code can go away once we have all print pricing factors in place - this is working just fine
	var check_seller = [];
	check_seller = image.split("");				
	var seller_ar = [check_seller[0],check_seller[1],check_seller[2],check_seller[3]];
	var seller = seller_ar.join("");
	var dennis_frates = '0100';
	var brian_atkinson = '0353';
	
 	if (price_factor == undefined) {price_factor=1;}
 	if (seller == dennis_frates) {price_factor=4.25;} 
 	if (seller == brian_atkinson) {price_factor=3;}
// up to here
	var info_string = "0,1,0,0,0,"+product_code+","+image+",0,"+pixel_width+","+pixel_height+",0,0,0,1,0,0,0,0,0,0,0,0,0,"+price_factor;
	create_cookie('printStudio',info_string);
	return;
}

function studio_window() {
	var hgt = screen.height-60;
	var wdt= screen.width-10;
	var win_properties = 'height='+hgt+',width='+wdt +'scrollbars=1, resizable=1,top=0,left=0';
	var studio_win = window.open("http://www.acclaimimages.com/studio/studio.html", "studio_win", win_properties);
	popUp_reminder();
	studio_win.focus();
	return;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// going to the digital calculator
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

















var now = new Date();	
var now_D = now.getDate();
var now_M = now.getMonth();
var now_Y = now.getYear();

//  SENDING A SERVER REQUEST
function getXMLHTTPRequest(){
	var req = false;
	try{req = new XMLHttpRequest();} /*  e.g. Firefox  */
	catch(err1){
		try{req = new ActiveXObject("Msxm12.XMLHTTP");} /*  some versions IE  */
		catch(err2){ 
			try{req = new ActiveXObject("Microsoft.XMLHTTP");} /*  some versions IE  */
			catch(err3){req = false;}
			}
		}
	return req;
	}
var myRequest = getXMLHTTPRequest();






function get_db_string_info_Response(){  //Barb added anything to do with IC 6/20/07
//	 RF or RM...
//	 0	license_type
//	 1	image_number
//	 2	ST_pixel_width
//	 3	ST_pixel_height
//	 4	category
//	 5	model_release
//	 6	property_release
//	 7	pricing_factor
//	 8	MD_price


//	 PR...
//	 0	license_type
//	 1	image_number
//	 2	caption
//	 3	ST_pixel_width
//	 4	ST_pixel_height


	if(myRequest.readyState == 4){
		if(myRequest.status == 200){
			var value = myRequest.responseText; 


			if (value == "Not Available") {
				alert("Sorry, this image is no longer available for purchase.");
				}
			else {
				// if "value" contains PR, RM, or RF in the beginning of the string then we split... (6-19-07) or IC
				var rm_value_pattern = /^RM/;
				var rf_value_pattern = /^RF/;
				var pr_value_pattern = /^PR/;
				var ic_value_pattern = /^IC/;
				if (rm_value_pattern.test(value) || rf_value_pattern.test(value) || pr_value_pattern.test(value) || ic_value_pattern.test(value)) {
					var split_value = value.split("|");
					var license_type = split_value[0];
					}
				else { var license_type = ''; }
				
				if (license_type == "PR") {
					var image_number = split_value[1];
					var caption = split_value[2];
					var ST_pixel_width = split_value[3];
					var ST_pixel_height = split_value[4];
	//				var db_string = image_number + "|" + caption + "|" + ST_pixel_width + "|" + ST_pixel_height;
					}
				else if (license_type == "RM") {
					var image_number = split_value[1];
					var ST_pixel_width = split_value[2];
					var ST_pixel_height = split_value[3];
					var category = split_value[4];
					var model_release = split_value[5];
					var property_release = split_value[6];
					var pricing_factor = split_value[7];
					var db_string = image_number + "|" + ST_pixel_width + "|" + ST_pixel_height + "|" + category + "|" + model_release + "|" + property_release + "|" + pricing_factor;
					}
				else if (license_type == "RF") {
					var image_number = split_value[1];
					var ST_pixel_width = split_value[2];
					var ST_pixel_height = split_value[3];
					var category = split_value[4];
					var model_release = split_value[5];
					var property_release = split_value[6];
					var pricing_factor = split_value[7];
					var MD_price = split_value[8];
					var extension = split_value[9];
					extension = extension.toLowerCase();
					var license_text = split_value[10];


					var db_string = image_number + "|" + ST_pixel_width + "|" + ST_pixel_height + "|" + category + "|" + model_release + "|" + property_release + "|" + pricing_factor + "|" + MD_price + "|" + extension;
					}
					else if (license_type == "IC") {
					//var collection_price = split_value[1];
					var license_text = split_value[2];
					var collection_number = split_value[3];
					var ST_pixel_width = split_value[4];
					var ST_pixel_height = split_value[5];
					var category = split_value[6];
					var model_release = split_value[7];
					var property_release = split_value[8];
					var item_count = split_value[9];
					var image_number = split_value[10];
					var extension = split_value[11];
					extension = extension.toLowerCase();
					
					if(item_count*1 <= 50){var collection_price = IC_prices[1];} 
					else if(item_count*1 >= 51){var collection_price = IC_prices[2];}
					else{alert(error_sorry);}

					
					var db_string = collection_number + "|" + ST_pixel_width + "|" + ST_pixel_height + "|" + category + "|" + model_release + "|" + property_release + "|" + item_count + "|" + image_number + "|" + extension;
//				alert("value: "+value);
//				alert(db_string);
					}
				else if (license_type == "") { 
					document.getElementById('image_options').innerHTML = value; 
					}
				else {}
				
				
				var product_code = license_type;

	
				if (product_code == "RF" || product_code == "RM") {
					now_Y=now_Y.toString();
					if (now_Y.length < 4) {now_Y=now_Y-0+1900;}
					var cart_string = '0|1|0|0|0|'+product_code;
					var calc_string = '0|-1|-1|-1|-1|-1|-1|'+now_D+'|'+now_M+'|'+now_Y+'|-1|||-1';
					var info = [cart_string, calc_string, db_string];
					create_cookie('calcCookie', info);
					pricing_calc_window();
					}
				else if (product_code == "PR") {
// 					the following alert "var print_message" was 
// 					commented out because it was causing the 
// 					popped up window after the confirmation to 
// 					be blocked by popup blockers. Tina said 
// 					she gets about 2 calls per day about 
// 					this problem. 3/Aug/2007 10:43 Kenny

//					var answer = confirm(print_message);
//					if (answer) {
						create_print_cookie(product_code,image_number,ST_pixel_width,ST_pixel_height,pricing_factor);	
						studio_window();
						return;
//						} else {return;}
					}else if (product_code == "IC"){
						var cart_string = '0|1|0|0|0|'+product_code;
						var calc_string = collection_price+'||'+license_text;
						var info = [cart_string, calc_string, db_string];
						create_cookie('calcCookie', info);
						pricing_calc_window();
					} else {
						alert(error_sorry);
						}
				} // else
			}else {
				alert("An error has occurred: " + myrequest.statusText);
				}
		}
	}

function calc_price(product_code,db_string) {
//	alert(product_code)
//	alert(db_string)

	if (db_string) {
		split_db_string = db_string.split("|");
		db_string = '';
		db_string = split_db_string[0];
//		alert(db_string)
		}
	else {
		var db_string = document.get_available_image_buttons.image_number.value;
		}
		
	if (product_code == 'IC') {var do_this = 'get_db_string_info_IC';}
		else {var do_this = 'get_db_string_info';} 
		
	var url = "/cgi-bin/photobase/db_images.pl?do=" + do_this + "&image_number=" + db_string + "&product_code=" + product_code;
	var myRandom=parseInt(Math.random()*99999999);
	myRequest.open("GET", url + "&rand=" + myRandom, true);
	myRequest.onreadystatechange = get_db_string_info_Response;
	myRequest.send(null);
	
	
	}
	
function calc_price_INSET(product_code,db_string) { //Barb new on sept 8, 2008
//	alert(product_code)
//	alert(db_string)

	if (db_string) {
		split_db_string = db_string.split("|");
		db_string = '';
		db_string = split_db_string[0];
//		alert(db_string)
		}
	else {
		var db_string = document.get_available_image_buttons.image_number.value;
		}
		
	if (product_code == 'IC') {var do_this = 'get_db_string_info_IC';}
		else {var do_this = 'get_db_string_info';} 
		
	var url = "/cgi-bin/photobase/db_images.pl?do=" + do_this + "&image_number=" + db_string + "&product_code=" + product_code;
	var myRandom=parseInt(Math.random()*99999999);
	myRequest.open("GET", url + "&rand=" + myRandom, true);
	myRequest.onreadystatechange = get_db_string_info_Response_INSET;
	myRequest.send(null);
	
	
	}
	

// 26/Apr/2007 12:22 kenny
//
//function calc_price(product_code,db_string) {
//	now_Y=now_Y.toString();
//	if (now_Y.length < 4) {now_Y=now_Y-0+1900;}
//	var cart_string = '0|1|0|0|0|'+product_code;
//	var calc_string = '0|-1|-1|-1|-1|-1|-1|'+now_D+'|'+now_M+'|'+now_Y+'|-1|||-1';
//	var info = [cart_string, calc_string, db_string];
//	create_cookie('calcCookie', info);
//	pricing_calc_window();
//}

function calc_price2(product_code,db_string) { // this is for the photobase sites
calc_price(product_code,db_string);
}


function just_put_in_cart(product_code,db_string) {
	var value = "";
	now_Y=now_Y.toString();
	if (now_Y.length < 4) {now_Y=now_Y-0+1900;}
	var item_num = give_item_number(0)*1;
	var cart_string = item_num+'|1|0|0|0|'+product_code;
	if (product_code == 'PU') {
		var price_factor = (db_string.split("\|"))[6];
		calc_string = (PU_prices[1]*price_factor)+'|||||||'+now_D+'|'+now_M+'|'+now_Y+'||||';
		} else {calc_string = '0|-1|-1|-1|-1|-1|-1|'+now_D+'|'+now_M+'|'+now_Y+'|-1|||-1';}
	
	if (product_code == 'PU'){
		var new_db_string = "";
		new_db_string = PU_find_size(db_string);
		value = cart_string+"|"+calc_string+"|"+new_db_string;
		var answer = confirm(PU_warning);
		if (answer){
			add_to_cart_cookie(value);
			confirm_pop();
			} else {return;}
		} else {
			value = cart_string+"|"+calc_string+"|"+db_string;
			add_to_cart_cookie(value);
			confirm_pop();
//			cart_window();
		}
}

function PU_find_size(db_string) {
	var db_info = [];
	var long_side = 0;
	var short_side = 0;
	db_info = db_string.split('\|');
	
	if ((db_info[1] < 1600) && (db_info[2] < 1600)) {return db_string;}
	
	if (db_info[1] >= db_info[2]) {
		long_side = 1600;
		short_side = (db_info[2]/(db_info[1]/1600)).toFixed(0);
		db_string = db_info[0]+"|"+long_side+"|"+short_side+"|"+db_info[3]+"|"+db_info[4]+"|"+db_info[5]+"|"+db_info[6];
		} else {
		long_side = 1600;
		short_side = (db_info[1]/(db_info[2]/1600)).toFixed(0);
		db_string = db_info[0]+"|"+short_side+"|"+long_side+"|"+db_info[3]+"|"+db_info[4]+"|"+db_info[5]+"|"+db_info[6];
		}
	return db_string;
}

function pricing_calc_window() {
	var hgt = screen.height-60;
	var wdt= screen.width-10;
	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 calc_win = window.open("http://www.acclaimimages.com/studio/RMcalc/digitalCalcPage.html", "calc_win", win_properties);
	popUp_reminder();
	calc_win.focus();
	return;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////these are the shopping cart functions
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function give_item_number(counter) {
	if (document.cookie && document.cookie.indexOf('itemCount') > -1)	{
		if (counter*1 == 0) {
			var item_number = read_cookie('itemCount');
			counter = item_number;
			item_number++;
			create_cookie('itemCount',item_number);
			}
		}else{
			counter=1;
			create_cookie('itemCount', 2);
			}
	return counter;
}

function dollar_up_print() {
	var sel_text = "";
	var info = load_variable_array('printStudio');
		change_cookie_element(12, (info[12]*1).toFixed(2));
		change_cookie_element(15, (info[15]*1).toFixed(2));
		change_cookie_element(18, (info[18]*1).toFixed(2));
		change_cookie_element(21, (info[21]*1).toFixed(2));
		change_cookie_element(22, (info[22]*1).toFixed(2));
		change_cookie_element(0, (give_item_number(info[0])));

	info = load_variable_array('printStudio');
	for (i = 0; i < info.length; i++){ 
		sel_text += info[i];
		if (i==(info.length-1)) {
			return sel_text;}
		sel_text += "|";
	}
	return;
}

function add_to_cart()	{
	var value = dollar_up_print();
	add_to_cart_cookie(value);
	confirm_pop();
	top.window.close();
}

function short_add_to_cart()	{
	var value = dollar_up_print();
	add_to_cart_cookie(value);
}

function confirm_pop()	{
	var wdt = 175;
	var hgt = 75;
	var from_left = (screen.width - 150) / 1.5;
	var from_top = (screen.height - 10) / 2;
	var win_properties = 'directories=no,height='+hgt+',location=no,menubar=no';
	win_properties += ',resizable=no,scrollbars=no, status=no,toolbar=no,width='+wdt+',top='+from_top+',left='+from_left;
	var win_name ="window"+new Date().getTime();
	confirm_win = window.open("http://www.acclaimimages.com/studio/confirm.html", "confirm_win", win_properties);
}

function LBconfirm_pop()	{
	var wdt = 175;
	var hgt = 75;
	var from_left = (screen.width - 150) / 1.5;
	var from_top = (screen.height - 10) / 2;
	var win_properties = 'directories=no,height='+hgt+',location=no,menubar=no';
	win_properties += ',resizable=no,scrollbars=no, status=no,toolbar=no,width='+wdt+',top='+from_top+',left='+from_left;
	var win_name ="window"+new Date().getTime();
	confirm_win = window.open("http://www.acclaimimages.com/studio/lightbox_confirm.html", "confirm_win", win_properties);
}

function display_cart(ready_cart) {
	var sel_text = "";
	var custAC_text = "";
	var how_many_items = 0;
	var cart_sub_total = 0;
	var cart_total = 0;
	var have_shipping = 0;
	var have_digital = 0;
	var unpriced = 0;

	var order = [];	
	var info = [];
	order = ready_cart;
	
	for (i = 0; i < order.length; i++){
		info = order[i].split("\|");

			if (info[5] == 'PR') {
				have_shipping = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[22]*1);
				cart_total = (cart_sub_total*1)
				sel_text += "<hr>";
				sel_text += PR_order(info);
				sel_text += edit_remove_table(order[i])

				} else if (info[5] == 'RM'){
				have_digital = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[6]*1);
				cart_total = (cart_sub_total*1);
				sel_text += "<hr>";
				sel_text += RM_order(info);
				sel_text += edit_remove_table(order[i])
				custAC_text += info[5]+"|"+info[20]+"|"+info[6]+"|"+RM_EULA(info)+",";
				how_many_items++;
				if (info[6]*1 == 0) {unpriced++;}
				
				} else if (info[5] == 'RR'){
				have_digital = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[6]*1);
				cart_total = (cart_sub_total*1);
				sel_text += "<hr>";
				sel_text += RR_order(info);
				sel_text += edit_remove_table(order[i])
				custAC_text += info[5]+"|"+info[20]+"|"+info[6]+"|"+RR_EULA(info)+",";
				how_many_items++;
				if (info[6]*1 == 0) {unpriced++;}
				
				} else if (info[5] == 'RF') {
				have_digital = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[6]*1);
				cart_total = (cart_sub_total*1);
				sel_text += "<hr>";
				sel_text += RF_order(info);
				sel_text += edit_remove_table(order[i])
				custAC_text += info[5]+"|"+info[20]+"|"+info[6]+"|"+RF_res[info[17]]+"|"+RF_EULA(info)+",";
				how_many_items++;
				if (info[6]*1 == 0) {unpriced++;}
				
				} else if (info[5] == 'PU') {
				have_digital = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[6]*1);
				cart_total = (cart_sub_total*1);
				sel_text += "<hr>";
				sel_text += PU_order(info);
				sel_text += remove_table(order[i])
				custAC_text += info[5]+"|"+info[20]+"|"+info[6]+"|"+PU_EULA(info)+",";
				how_many_items++;
				if (info[6]*1 == 0) {unpriced++;}
				
				} else if (info[5] == 'IC') {
				have_digital = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[6]*1);
				cart_total = (cart_sub_total*1);
				sel_text += "<hr>";
				sel_text += IC_order(info);
				sel_text += remove_table(order[i])
				custAC_text += info[5]+"|"+info[9]+"|"+info[6]+"|"+IC_EULA(info)+",";
				how_many_items++;
				if (info[6]*1 == 0) {unpriced++;}
				
				} else {alert(error_sorry);}
		}
	sel_text += "<table width='100%' cellpadding='5' border='0'><tr>";
	sel_text += "<tr><td width='100%' class='sm' align='left' colspan='2'><hr></td></tr>";
	sel_text += "<tr>";
	sel_text += "<td class='md' valign='top' align='right' colspan='2'>";
	sel_text += "Sub&nbsp;total:&nbsp;<b>$"+cart_sub_total.toFixed(2)+" USD</b></td>";
	sel_text += "</tr>";

	if (have_shipping == 1) {
	sel_text += "<tr>";
	sel_text += "<td class='sm' align='right' colspan='2'>";
	sel_text += "(Shipping costs will be added at checkout.)</td>";
	sel_text += "</tr>";}
	
	sel_text += "<tr><td colspan='2'><hr></td></tr>";
	sel_text += "<tr><td class='sm' align='left'>";
	sel_text += "<input TYPE='button' VALUE='Continue Shopping' onClick='self.close()';><br>";
	sel_text += "</td>";
	sel_text += "<td class='sm' align='right'>";
	if (unpriced == 0) {sel_text += "<p><input TYPE='button' VALUE='Buy Now' onClick='open_purchase_window()';><br>";}
		else {
		sel_text += "<font color='red'><b>You still have unpriced items in your shopping cart.</b><br>";
		sel_text += "Please either price these items or remove them before proceeding with your purchase.</font>";
		}
	sel_text += "</td></tr>";
	sel_text += "<tr><td width='100%' class='sm' align='left' colspan='2'>";
	sel_text += "<p><input TYPE='button' VALUE='Empty Cart' onClick='empty_cart()';>";
	sel_text += "</td></tr>";
	sel_text += "<tr><td width='100%' class='md' align='right' colspan='2'><hr>";
	sel_text += "</table>";
	document.getElementById('cartbox').innerHTML = sel_text;
	return;
}

function edit_remove_table(order) {
	var table_text = "";
	info = order.split("\|");
	
	table_text += "<table width='100%' cellpadding='0' border='0' valign='top'>";
	table_text += "<tr><td class='sm' valign='top' width='110' align='center'>";
	table_text += "<a href=\"javascript:delete_from_cart("+info[0]+");\"><u>Remove Item</u></a></td>";
	table_text += "<td class='sm' valign='top' align='left'>";
	table_text += "&nbsp;<a href=\"javascript:edit_item('"+order+"');\"><u>Edit Item</u></a>";
	table_text += "</td></tr></table>";
	return table_text;
}

function remove_table(order) {
	var table_text = "";
	var info = order.split("\|");
	
	table_text += "<table width='100%' cellpadding='0' border='0' valign='top'>";
	table_text += "<tr><td class='sm' valign='top' width='110' align='center'>";
	table_text += "<a href=\"javascript:delete_from_cart("+info[0]+");\"><u>Remove Item</u></a></td>";
	table_text += "<td class='sm' valign='top' align='left'>";
	table_text += "&nbsp;";
	table_text += "</td></tr></table>";
	return table_text;
}

function custAC_pop(which)	{
	var wdt = 350;
	var hgt = 475;
	var from_left = (screen.width/8);
	var from_top = (screen.height/8);
	var win_properties = 'directories=no,height='+hgt+',location=no,menubar=no';
	win_properties += ',resizable=no,scrollbars=no, status=no,toolbar=no,width='+wdt+',top='+from_top+',left='+from_left;
	var win_name ="window"+new Date().getTime();
	if (which==1) {
		custACExamples_win = window.open("http://www.acclaimimages.com/studio/custAC_notesExamples.html", "custACExamples_win", win_properties);
		} else if (which==2){
		custACExamples_win = window.open("http://www.acclaimimages.com/studio/custAC_notesGetOne.html", "custACExamples_win", win_properties);
		}
}

function edit_item(value) { // this looks good
	window.close();
	var info = [];
	var cart_string = [];
	var calc_string = [];
	var db_string = [];

	info = value.split("\|");
	if (info[5] == 'PR') {
		create_cookie('printStudio', info);
		dollar_up_print();
		studio_window();
	} else if ((info[5] == 'RM')||(info[5] == 'RR')) {
		cart_string = info[0]+"|"+info[1]+"|"+info[2]+"|"+info[3]+"|"+info[4]+"|"+info[5];
		calc_string = info[6]+"|"+info[7]+"|"+info[8]+"|"+info[9]+"|"+info[10]+"|"+info[11]+"|"+info[12]+"|";
		calc_string += info[13]+"|"+info[14]+"|"+info[15]+"|"+info[16]+"|"+info[17]+"|"+info[18]+"|"+info[19];
		db_string = info[20]+"|"+info[21]+"|"+info[22]+"|"+info[23]+"|"+info[24]+"|"+info[25]+"|"+info[26];
		info = [cart_string,calc_string, db_string];
		create_cookie('calcCookie', info);
		pricing_calc_window();
	} else if (info[5] == 'RF') {
		cart_string = info[0]+"|"+info[1]+"|"+info[2]+"|"+info[3]+"|"+info[4]+"|"+info[5];
		calc_string = info[6]+"|"+info[7]+"|"+info[8]+"|"+info[9]+"|"+info[10]+"|"+info[11]+"|"+info[12]+"|";
		calc_string += info[13]+"|"+info[14]+"|"+info[15]+"|"+info[16]+"|"+info[17]+"|"+info[18]+"|"+info[19];
		db_string = info[20]+"|"+info[21]+"|"+info[22]+"|"+info[23]+"|"+info[24]+"|"+info[25]+"|"+info[26]+"|"+info[27]+"|"+info[28];
		info = [cart_string,calc_string, db_string];
		create_cookie('calcCookie', info);
		pricing_calc_window();
	}else {alert(error_sorry);}
}

function change_shipping_cookie_element(index_pos, new_value)	{
	var info = load_variable_array('myShipping');
	info.splice(index_pos,1, new_value);
	var date = new Date();
	date.setTime(date.getTime()+(180*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "myShipping="+info+expires+"; path=/; domain=.acclaimimages.com;";
	return;
}

function purchase_print() {
	dollar_up_print();
	printStudio_to_db();
	cart_window();
	top.window.close();
}

function open_purchase_window() {
	var hgt = screen.height-100;
	var wdt= 900;
	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';
	buy_win = window.open("https://www.acclaimimages.com/studio/toLP.html", "buy_win", win_properties);
	popUp_reminder();
	buy_win.focus();
	top.window.close();
}


function straight_to_cart(product_code,image,caption,pixel_width,pixel_height,price_factor) {
	var answer = confirm("Prints are for personal decor use only and may not be copied or reproduced. Would you like to continue?");
	if (answer){
		create_print_cookie(product_code,image,pixel_width,pixel_height,price_factor);
		get_defaults();
		get_total();
		dollar_up_print();
		printStudio_to_db();
		confirm_pop();
	} else {return;}
}

function add_to_cart2()	{
	var value = dollar_up_print();
	add_to_cart_cookie(value);
	confirm_pop();
}

function get_total() {
	var info = load_variable_array('printStudio');
	var total = info[12]*1+info[15]*1+info[18]*1+info[21]*1;
	change_cookie_element(22, total);
	return;
} 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// prints from lightbox to cart
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////



function LB_straight_to_cart(product_code,image,caption,pixel_width,pixel_height,price_factor, count) { // just for prints
	create_print_cookie(product_code,image,pixel_width,pixel_height,price_factor);
	get_defaults();
	get_total();
	dollar_up_print();
	var hold = read_cookie('printStudio').split(',')
	var data_string_for_cart = hold.join("|");
	return data_string_for_cart;
}






//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////here we go to linkpoint
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function get_order_out(ready_cart) {
	var order_text = "";
//	var custAC_text = "";
	var how_many_items = 0;
	var cart_sub_total = 0;
	var cart_total = 0;
	var have_shipping = 0;
	var have_digital = 0;
	var unpriced = 0;
	var give_back = [];
	var order = [];	
	var info = [];
	
	
	order = ready_cart;
	order_text += "<table width='700' cellpadding='0' border='0'><tr><td colspan='2'>";
	for (i = 0; i < order.length; i++){
		info = order[i].split("\|");
			if (info[5] == 'PR') {
				have_shipping = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[22]*1);
				order_text += PR_order(info);
				order_text += "<hr width='100%'>";
			} else if (info[5] == 'RM') {
				have_digital = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[6]*1);
				order_text += RM_order(info);
				order_text += "<hr width='100%'>";
				custAC_text += info[5]+"|"+info[20]+"|"+info[6]+"|"+RM_EULA(info)+",";
			} else if (info[5] == 'RR') {
				have_digital = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[6]*1);
				order_text += RR_order(info);
				order_text += "<hr width='100%'>";
				custAC_text += info[5]+"|"+info[20]+"|"+info[6]+"|"+RR_EULA(info)+",";
			} else if (info[5] == 'RF') {
				have_digital = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[6]*1);
				order_text += RF_order(info);
				order_text += "<hr width='100%'>";
				custAC_text += info[5]+"|"+info[20]+"|"+info[6]+"|"+RF_res[info[17]]+"|"+RF_EULA(info)+",";
			} else if (info[5] == 'IC') {
				have_digital = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[6]*1);
				order_text += IC_order(info);
				order_text += "<hr width='100%'>";
				custAC_text += info[5]+"|"+info[9]+"|"+info[6]+"|"+IC_EULA(info)+",";
			} else if (info[5] == 'PU') {
				have_digital = 1;
				cart_sub_total = cart_sub_total+(info[1]*info[6]*1);
				order_text += PU_order(info);
				order_text += "<hr width='100%'>";
				custAC_text += info[5]+"|"+info[20]+"|"+info[6]+"|"+PU_EULA(info)+",";
			} else {alert(error_sorry);}
 		give_back[i] = order[i];
		}

	order_text += "</td></tr>";

	print_img_price_list = package_order(give_back);
	
	if (have_shipping == 1) {
		order_text += "<tr>";
		order_text += "<td class='sm' align='left' width='50%'><b>Prints May Not Be Copied or Reproduced.</b></td>";
		order_text += "<td class='sm' align='right' width='50%'><a href=\"javascript:return_pop();\"><font color='red'><u>Print Return Policy</u></font></a></td>";
		order_text += "</tr>";
		order_text += "<tr><td class='sm' valign='top' align='left' colspan='2'>Prints normally ship within 1-2 business days.<br>";
		order_text += "Canvas prints require an extra day for drying prior to shipping.<br>";
		order_text += "Allow an extra 7 to 10 days for framed prints.<br>";
		order_text += "<font color='red'><b>All Print orders are shipped DHL Express.</b></font>.<br>";
		order_text += "<a href=\"javascript:ship_pop();\"><u>About Our Shipping...</u></a><br>";
		order_text += "For other shipping options please contact our Customer Service Department<br>";
		order_text += "<b>1-(888) 618-8723 or 1-(541) 618-8723</b>.";
		order_text += "</td></tr>";
		}
		if (have_digital == 1) {
		order_text += "<tr><td class='sm' valign='top' align='left' colspan='2'>After Your order for is processed you will be sent to a page ";
		order_text += "where you may download your digital file(s).<p></td></tr>";
		}
		
	if (have_shipping == 0) {
		document.getElementById("shipbox").innerHTML = "<INPUT type='hidden' name='shippingbypass' value='true'>";
		document.getElementById('shipbox').style.visibility = "visible";
		put_in_totalbuttonbox();
		}

	order_text += "<tr><td class='md' valign='top' align='right' colspan='2'><b>Order Sub Total: $"+cart_sub_total.toFixed(2)+" USD</b></td></tr>";
	order_text += "</table>";

	document.getElementById("orderbox").innerHTML = order_text;
	var ship_info_string = [0,'US',cart_sub_total];
	create_cookie('myShipping',ship_info_string);
}


function change_shipping_cookie_element(index_pos, new_value) {
	var info = load_variable_array('myShipping');
	info.splice(index_pos,1, new_value);
	var date = new Date();
	date.setTime(date.getTime()+(180*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "myShipping="+info+expires+"; path=/; domain=.acclaimimages.com;";
	return;
}

function pick_country(SorD, country) {
	if (document.cookie && document.cookie.indexOf('myShipping') > -1)	{
		var info = load_variable_array('myShipping');
		if (info[0]==SorD) {change_shipping_cookie_element(1, country);}
		} else {
		var info_string = [SorD,country,0.00];
		create_cookie('myShipping',info_string);
		}
	document.getElementById('totalbox').style.visibility = "hidden";
	take_out_creditbox();
	return;
}

function find_total() {
	var info = load_variable_array('myShipping');
	 if ((info[1]==-1)||(info[1]=="")){
	alert('Please select a country to ship your order to.');
	return;
	}else{
	get_shipping_loaded()
	}
	return;
}

function find_shipping(ready_cart) {
	var flat_print = 0;
	var framed_print = 0;
	var shipping_charge = 0;
	var sub_total = 0;
	var number_list = "";
	var visitor_info = [];
	
	var order = ready_cart;

	for (i = 0; i < order.length; i++){
		info = order[i].split("\|");
		
		if (info[5] == 'PR'){
			if (info[21]*1 < 1) {
				flat_print = flat_print + (1*info[1]);
				} else {
				framed_print = framed_print + (1*info[1]);
				}
				sub_total = sub_total + (info[22]*info[1]*1);
				special_instructions = print_message;
				number_list += info[5]+": "+info[6]+"... ";
			} else {
				sub_total = sub_total + info[6]*1;
				special_instructions = 'None at this time.';
				number_list += info[5]+": "+info[20]+"... ";
				} 	
		}
		
	var flat_packs = 0;
	if (flat_print%3 == 0) {flat_packs = flat_print/3;}
		else {flat_packs = (((flat_print-(flat_print%3))/3)+1)}
	
	var ship_info = load_variable_array('myShipping');
	if (ship_info[1] == 'US') {shipping_charge = (flat_packs*ship[2])+(framed_print*ship[4]);}
		else  {shipping_charge = (flat_packs*ship[3])+(framed_print*ship[5]);}

	var order_total = sub_total*1 + shipping_charge*1;
	
	
	var total_text ="<table width='100%' class='md'>";
	total_text +="<tr><td width='100%' align='right'>Subtotal:&nbsp;</td><td align='right'>$"+sub_total.toFixed(2)+"</td></tr>";
	total_text +="<tr><td width='100%' align='right'>Shipping:&nbsp;</td><td align='right'>$"+shipping_charge.toFixed(2)+"</td></tr>";
	total_text +="<tr><td width='100%' align='right'><hr width='72'></td><td align='right'><hr width='72'></td></tr>";
	total_text +="<tr><td width='100%' align='right'><b>Total:</b>&nbsp;</td><td align='right'><b>$"+order_total.toFixed(2)+"</b></td></tr>";
	total_text +="</table>";
	
	document.getElementById('totalbox').style.visibility = "visible";
	put_in_creditbox();
	document.getElementById("totalbox").innerHTML = total_text;

	if (document.cookie && document.cookie.indexOf('acclaimimages_referer') > -1)	{
	var refer = read_cookie('acclaimimages_referer');
	} else if (document.cookie && document.cookie.indexOf('acclaimimages_referrer') > -1)	{
	var refer = read_cookie('acclaimimages_referrer');
	} else {refer = 'None';}
	
	visitor_info = load_variable_array('visitor');
	if (visitor_info[0] == "") {
		aid = 'None';
		acclaim_sales_ID = 'None';	//acclaim_sales_ID added by barb Sept 11, 2008 to temp track employee  driven sales
	} else {
		aid = visitor_info[1];
		acclaim_sales_ID = visitor_info[0];
	}
	

	var values_text = "<input type=\"hidden\" name=\"shipping\" value=\""+(shipping_charge*1).toFixed(2)+"\">";
	values_text += "<input type=\"hidden\" name=\"subtotal\" value=\""+(sub_total*1).toFixed(2)+"\">";
	values_text += "<input type=\"hidden\" name=\"tax\" value=\""+(tax*1).toFixed(2)+"\">";
	values_text += "<input type=\"hidden\" name=\"taxexempt\" value=\"1\">";
	values_text += "<input type=\"hidden\" name=\"chargetotal\" value=\""+(order_total*1).toFixed(2)+"\">";
	values_text += "<input type=\"hidden\" name=\"print_img_price_list\" value=\"'"+print_img_price_list+"'\">";
	values_text += "<input type=\"hidden\" name=\"special_instructions\" value=\"'"+special_instructions+"'\">";
	values_text += "<input type=\"hidden\" name=\"aid\" value=\"'"+aid+"'\">";
	values_text += "<input type=\"hidden\" name=\"acclaim_sales_ID\" value=\"'"+acclaim_sales_ID+"'\">";
	values_text += "<input type=\"hidden\" name=\"comments\" value=\""+number_list+"\">";
	values_text += "<input type=\"hidden\" name=\"refer\" value=\"'"+refer+"'\">";

	document.getElementById("sendvaluesbox").innerHTML = values_text;

	return;
}

function put_in_creditbox() {
	var credit_text = "";

	credit_text += "<table class='sm' align='left' valign='top' width='700' cellpadding='0' border='0' class='sm'>";
	credit_text += "<tr><td align='right' colspan='2'><hr></td></tr>";
	credit_text += "<tr><td align='left' colspan='2'><b>Payment Information</b></td></tr>";
	credit_text += "<tr><td align='right'>Credit Card Type:&nbsp;</td><td><select size='1' name='cctype'>";
	credit_text += "<option value='' selected='true'>No Choice</option>";
	credit_text += "<option value='V'>Visa</option>";
	credit_text += "<option value='M'>MasterCard</option>";
	credit_text += "<option value='A'>American Express</option>";
	credit_text += "<option value='D'>Discover</option>";
	credit_text += "</select></td></tr>";
	credit_text += "<tr><td align='right'>Credit card number:&nbsp;</td><td><input type='text' name='cardnumber' size='20' maxlength='30'></td></tr>";
	credit_text += "<tr><td align='right'>Expires:&nbsp;</td><td><select name='expmonth' size='1'>";
	credit_text += "<option value=''>...</option>";
	credit_text += "<option value='1'>01</option>";
	credit_text += "<option value='2'>02</option>";
	credit_text += "<option value='3'>03</option>";
	credit_text += "<option value='4'>04</option>";
	credit_text += "<option value='5'>05</option>";
	credit_text += "<option value='6'>06</option>";
	credit_text += "<option value='7'>07</option>";
	credit_text += "<option value='8'>08</option>";
	credit_text += "<option value='9'>09</option>";
	credit_text += "<option value='10'>10</option>";
	credit_text += "<option value='11'>11</option>";
	credit_text += "<option value='12'>12</option>";
	credit_text += "</select> / <select name='expyear' size='1'>";
	credit_text += "<option value=''>...</option>";
	credit_text += "<option value='2006'> 2006 </option>";
	credit_text += "<option value='2007'> 2007 </option>";
	credit_text += "<option value='2008'> 2008 </option>";
	credit_text += "<option value='2009'> 2009 </option>";
	credit_text += "<option value='2010'> 2010 </option>";
	credit_text += "<option value='2011'> 2011 </option>";
	credit_text += "<option value='2012'> 2012 </option>";
	credit_text += "<option value='2013'> 2013 </option>";
	credit_text += "<option value='2014'> 2014 </option>";
	credit_text += "<option value='2015'> 2015 </option>";
	credit_text += "</select></td></tr>";
	credit_text += "<tr><td align='right'>Card Code:&nbsp;</td><td><input type='text' name='cvm' size='4'></td></tr>";
	credit_text += "<tr><td align='right'><input type='checkbox' name='cvmnotpres'></td><td>Code not present</td></tr>";
	credit_text += "<tr><td align='center' colspan='2'><input type='submit' value='Submit Secure Credit Card Payment'></td></tr>";
	credit_text += "</table>";
	
	document.getElementById("creditbox").innerHTML = credit_text;
}

function take_out_creditbox() {
	var credit_text = "";
	document.getElementById("creditbox").innerHTML = credit_text;
}

function put_in_totalbuttonbox() {
	var totalbutton_text = "";
	totalbutton_text += "<input TYPE='button' VALUE='Get Order Total' onClick='find_total()';><p>";
	document.getElementById("totalbuttonbox").innerHTML = totalbutton_text;
}

function take_out_totalbuttonbox() {
	var totalbutton_text = "";
	document.getElementById("totalbuttonbox").innerHTML = totalbutton_text;
}


function same_address(form) {
	var sel_text = "";
	sel_text += "<input type='hidden' name='scompany' value='"+form.bcompany.value+"'>";
	sel_text += "<input type='hidden' name='sname' value='"+form.bname.value+"'>";
	sel_text += "<input type='hidden' name='saddr1' value='"+form.baddr1.value+"'>";
	sel_text += "<input type='hidden' name='saddr2' value='"+form.baddr2.value+"'>";
	sel_text += "<input type='hidden' name='scity' value='"+form.bcity.value+"'>";
	sel_text += "<input type='hidden' name='sstate' value='"+form.bstate.value+"'>";
	sel_text += "<input type='hidden' name='szip' value='"+form.bzip.value+"'>";
	sel_text += "<input type='hidden' name='sstate2' value='"+form.bstate2.value+"'>";
	sel_text += "<input type='hidden' name='scountry' value='"+form.bcountry.value+"'>";

	document.getElementById("shipaddressbox").innerHTML = sel_text;	
	return;
}

function package_order(give_back){	// this is strictly to give to LP to generate output for DB, etc
	var info2 = [];
	var hold_EULA = "";
	for (i = 0; i < give_back.length; i++){

		info = give_back[i].split("\|");

		if (info[5] == 'PR') {
			if ((info[13]*1==1)||(info[13]*1==2)){info.splice(19,1, frame_codes1[info[19]]);}
				else {info.splice(19,1, frame_codes2[info[19]]);}
			info.splice(13,1, medium_choice[info[13]]);
			info.splice(14,1, glazing_choice[info[14]]);
			info2 = [info[5]+"\|\|"+info[6]+"\|\|"+info[7]+"\|\|"+info[10]+"\|\|"+info[11]+"\|\|"+info[12]+"\|\|"+info[13]+"\|\|"+info[14]+"\|\|"+info[15]+"\|\|"+info[2]+"\|\|"+info[16]+"\|\|"+info[17]+"\|\|"+info[18]+"\|\|"+info[19]+"\|\|"+info[20]+"\|\|"+info[21]+"\|\|"+info[22]+"\|\|"+info[1]+"\|\|"+info[8]+"\|\|"+info[9]+"\|\|"+info[0]];
			}else if ((info[5] == 'RM')||(info[5] == 'RR')||(info[5] == 'RF')||(info[5] == 'PU')||(info[5] == 'IC')) {
				info2 = [];
				hold_EULA = "";
				for (x=5; x < info.length; x++){
					info2[x-5] = info[x];
					}

				if (info[5] == 'RM') {hold_EULA = RM_EULA(info);}
				else if (info[5] == 'RR') {hold_EULA = RR_EULA(info);}
				else if (info[5] == 'RF') {hold_EULA = RF_EULA(info);}
				else if (info[5] == 'PU') {hold_EULA = PU_EULA(info);}
				else if (info[5] == 'IC') {hold_EULA = IC_EULA(info);}
				info2.splice(14, 1, hold_EULA);
			}else {alert("1 "+error_sorry);}

		give_back[i] = info2.join("\|\|");
	}
return give_back;
}

function PR_order(value) {
	var item_text = "";
	var info = [];
	info = value;
	if (info[16]==0) {var mat_color="None";}
		else {mat_color=info[16];}

	var glass = glazing_choice[info[14]*1];

	if ((info[13]*1==1)||(info[13]*1==2)){var frame_name = frame_codes1[info[19]*1];}
	else {frame_name = frame_codes2[info[19]*1];}

	if (info[20]== 'None') {var frame_color ="";}
	else {frame_color = info[20];}

	if (info[17]*1==0) {var mat_size="";}
	if (info[17]*1==2) {mat_size="2\"";}
	if (info[17]*1==4) {mat_size="4\"";}

	item_text += "<table width='100%' cellpadding='0' border='0' valign='top'>";
	item_text += "<tr><td width='110' class='sm' valign='middle' align='center'>";
	item_text += "<img src='https://www.acclaimimages.com/_gallery/_TN/"+info[6]+"_TN.jpg'>";
	item_text += "</td>";
	item_text += "<td class='sm' valign='bottom'>";
		if (info[13]==1) {item_text += "<b>Archival Quality Matte Paper Print</b><br>";}
		else if (info[13]==2) {item_text += "<b>Archival Quality Gloss Paper Print</b><br>";}
		else if (info[13]==3) {item_text += "<b>Stretched Canvas Print</b><br>";}
		else {item_text += "No Medium Selected<br>";}
	item_text += "Image Number: <b>"+info[6]+"</b><br>";
	item_text += "Size: "+info[10]+"\" x "+info[11]+"\"<br>";
	item_text += "Matting: "+mat_size+" "+mat_color+"<br>";
	item_text += "Glazing: "+glass+"<br>";
	item_text += "Frame: "+frame_name+" "+frame_color+"<br>";
	item_text += "Quantity: "+info[1];
	item_text += "</td>";
	item_text += "<td class='sm' valign='top' align='right'><b>$"+(info[1]*info[22]*1).toFixed(2)+"</b></td></tr>";
	item_text += "</table>";

	return item_text;
}

function RM_order(value) {
	var item_text = "";
	var info = [];
	info = value;

	item_text += "<table width='100%' cellpadding='0' border='0' valign='top'>";
	item_text += "<tr><td width='110' class='sm' valign='top' align='center'>";
	item_text += "<img src='https://www.acclaimimages.com/_gallery/_TN/"+info[20]+"_TN.jpg'>";
	item_text += "</td>";
	item_text += "<td class='sm' valign='top'><b>Rights Managed Digital File</b><br>";	
	item_text += "Image Number: <b>"+info[20]+"</b><br>";
	
	if (info[6]*1 == 0) {	
		item_text += "<font color='red'><b><p>This item still requires pricing.</font></b><br>Please click the \"Edit Item\" link below<br>to price this item.";
		item_text += "</td></tr></table>";
		return item_text;
		} else {
			item_text += "Non-Exclusive Use<br>";
			item_text += "Usage:<b> "+avail_defs[info[7]]+"</b><br>";
			item_text += "Broad Use: "+RM_category_0[info[8]]+"<br>";
			
			var bits = [];
			if (info[8]*1 == 0) {bits = (RM_use_0[info[9]].split('|'));}
			if (info[8]*1 == 1) {bits = (RM_use_1[info[9]].split('|'));}
			if (info[8]*1 == 2) {bits = (RM_use_2[info[9]].split('|'));}
			if (info[8]*1 == 3) {bits = (RM_use_3[info[9]].split('|'));}
			if (info[8]*1 == 4) {bits = (RM_use_4[info[9]].split('|'));}
			if (info[8]*1 == 5) {bits = (RM_use_5[info[9]].split('|'));}
			if (info[8]*1 == 6) {bits = (RM_use_6[info[9]].split('|'));}
			if (info[8]*1 == 7) {bits = (RM_use_7[info[9]].split('|'));}
			if (info[8]*1 == 8) {bits = (RM_use_8[info[9]].split('|'));}
		
			item_text += "Specific Use: "+bits[0]+"<br>";
			if (bits[1] == 0) {item_text += "Size: "+RM_size_0[info[10]]+"<br>";}
			else if (bits[1] == 1) {item_text += "Size: "+RM_size_1[info[10]]+"<br>";}
			else if (bits[1] == 2) {item_text += "Size: "+RM_size_2[info[10]]+"<br>";}
			else if (bits[1] == 3) {item_text += "Size: "+RM_size_3[info[10]]+"<br>";}
			else if (bits[1] == 4) {item_text += "Size: "+RM_size_4[info[10]]+"<br>";}
			else if (bits[1] == 5) {item_text += "Size: "+RM_size_5[info[10]]+"<br>";}
			else{item_text += "Size: "+RM_size_6[info[10]]+"<br>";}
		
			if (bits[2] == 0) {item_text += "Circulation: "+RM_run_0[info[11]]+"<br>";}
			else if (bits[2] == 1) {item_text += "Circulation: "+RM_run_1[info[11]]+"<br>";}
			else if (bits[2] == 2) {item_text += "Circulation: "+RM_run_2[info[11]]+"<br>";}
			else if (bits[2] == 3) {item_text += "Circulation: "+RM_run_3[info[11]]+"<br>";}
			else {item_text += "Circulation: "+RM_run_4[info[11]]+"<br>";}
		
			if ((info[8]==4)&&(info[9]==0)) {item_text += "Duration of Use: "+RM_duration_3[info[12]]+"<br>";}
			else if (info[8] == '1') {item_text += "Duration of Use: "+RM_duration_2[info[12]]+"<br>";}
			else if (bits[1] == 3) {item_text += "Duration of Use: "+RM_duration_1[info[12]]+"<br>";}
			else {item_text += "Duration of Use: "+RM_duration_0[info[12]]+"<br>";}
			
			item_text += "Start Date: "+months[info[14]]+" "+info[13]+", "+info[15]+"<br>";
			item_text += "Industry: "+RM_industy[info[16]]+"<br>";
		
			item_text += "Territory: "; 
				var t = [];
				t = info[17].split('.');
				for (x = 0; x < t.length; x++){item_text += RM_territories[t[x]]+"<br>";}
		
			item_text += "End User Details: <br>";
			item_text += format_end_user(info[18])+"<br>";
			item_text += "</td>";
			item_text += "<td class='sm' valign='top' align='right'><b>$"+(info[1]*info[6]*1).toFixed(2)+"</b></td></tr>";
			item_text += "</table>";
			return item_text;
			}
}

function RR_order(value) {
	var item_text = "";
	var info = [];
	info = value;

	item_text += "<table width='100%' cellpadding='0' border='0' valign='top'>";
	item_text += "<tr><td width='110' class='sm' valign='top' align='center'>";
	item_text += "<img src='https://www.acclaimimages.com/_gallery/_TN/"+info[20]+"_TN.jpg'>";
	item_text += "</td>";
	item_text += "<td class='sm' valign='top'><b>Rights Ready Digital File</b><br>";	
	item_text += "Image Number: <b>"+info[20]+"</b><br>";
	
	if (info[6]*1 == 0) {	
		item_text += "<font color='red'><b><p>This item still requires pricing.</font></b><br>Please click the \"Edit Item\" link below<br>to price this item.";
		item_text += "</td></tr></table>";
		return item_text;
		} else {
			item_text += "Non-Exclusive Use<br>";
			item_text += "Broad Use: "+RR_category_0[info[8]]+"<br>";
			item_text += "Duration of Use: 5 Years<br>";			
			item_text += "Start Date: "+months[info[14]]+" "+info[13]+", "+info[15]+"<br>";
			item_text += "Industry: "+RM_industy[info[16]]+"<br>";
			item_text += "Territory: Worldwide<br>"; 
			item_text += "End User Details: <br>";
			item_text += format_end_user(info[18])+"<br>";
			item_text += "</td>";
			item_text += "<td class='sm' valign='top' align='right'><b>$"+(info[1]*info[6]*1).toFixed(2)+"</b></td></tr>";
			item_text += "</table>";
			return item_text;
			}
}


function IC_order(info) { // this is the basic layout for IC
	var item_text = "<table width='100%' cellpadding='0' border='0' valign='top'>";
	item_text += "<tr><td width='110' class='sm' valign='top' align='center'>";
	item_text += "<img src='https://www.acclaimimages.com/_gallery/_TN/"+info[16]+"_TN.jpg'>";
	item_text += "</td>";
	item_text += "<td class='sm' valign='top'><b>Royalty Free Digital File Collection</b><br>";
	item_text += "Collection Number: <b>"+info[9]+"</b><br>";
	item_text += "Non-Exclusive Use<br>";
	item_text += "Number of Images: "+info[15]+"<br>";
	item_text += "Resolution Independent EPS File<br>";
	item_text += "End User Details: <br>";
	item_text += format_end_user(info[7])+"<br>";
	item_text += "</td>";
	item_text += "<td class='sm' valign='top' align='right'><b>$"+(info[1]*info[6]*1).toFixed(2)+"</b></td></tr>";
	item_text += "</table>";
			return item_text;
		} 


function RF_order(value) {
	var item_text = "";
	var info = [];
	info = value;

	item_text += "<table width='100%' cellpadding='0' border='0' valign='top'>";
	item_text += "<tr><td width='110' class='sm' valign='top' align='center'>";
	item_text += "<img src='https://www.acclaimimages.com/_gallery/_TN/"+info[20]+"_TN.jpg'>";
	item_text += "</td>";
	item_text += "<td class='sm' valign='top'><b>Royalty Free Digital File</b><br>";
	item_text += "Image Number: <b>"+info[20]+"</b><br>";
	
	if (info[6]*1 == 0) {	
		item_text += "<font color='red'><b><p>This item still requires pricing.</font></b><br>Please click the \"Edit Item\" link below<br>to price this item.";
		item_text += "</td></tr></table>";
		return item_text;
		}else {
			item_text += "Non-Exclusive Use<br>";
			item_text += "Usage:<b> "+avail_defs[info[7]]+"</b><br>";
			item_text += "Version: "+RF_res[info[17]]+"<br>";
			if ((info[28])&&(info[28].indexOf('eps') !=-1)) {
				item_text += "Size: Resolution Independent EPS File<br>";
				} else {
				item_text += "Size: "+info[15]+" x "+info[16]+" pixels<br>";
				}			
			item_text += "End User Details: <br>";
			item_text += format_end_user(info[18])+"<br>";
			item_text += "</td>";
			item_text += "<td class='sm' valign='top' align='right'><b>$"+(info[1]*info[6]*1).toFixed(2)+"</b></td></tr>";
			item_text += "</table>";
			return item_text;
		} 
}

function PU_order(value) {
	var item_text = "";
	var info = [];
	info = value;

	item_text += "<table width='100%' cellpadding='0' border='0' valign='top'>";
	item_text += "<tr><td width='110' class='sm' valign='top' align='center'>";
	item_text += "<img src='https://www.acclaimimages.com/_gallery/_TN/"+info[20]+"_TN.jpg'>";
	item_text += "</td>";
	item_text += "<td class='sm' valign='top'><b>Personal Use Digital File</b><br>";	
	item_text += "Image Number: <b>"+info[20]+"</b><br>";
	
	if (info[6]*1 == 0) {	
		item_text += "<font color='red'><b><p>This item still requires pricing.</font></b><br>Please click the \"Edit Item\" link below<br>to price this item.";
		item_text += "</td></tr></table>";
		return item_text;
		} else {
			item_text += "Non-Exclusive Use<br>";
			item_text += "Broad Use: Personal Use Only<br>";
			item_text += "Size: "+info[21]+" x "+info[22]+" pixels<br>";			
			item_text += "Start Date: "+months[info[14]]+" "+info[13]+", "+info[15]+"<br>";
			item_text += "</td>";
			item_text += "<td class='sm' valign='top' align='right'><b>$"+(info[1]*info[6]*1).toFixed(2)+"</b></td></tr>";
			item_text += "</table>";
			return item_text;
			}
}

function format_end_user(end_user) {
	end_user = end_user.replace(/__/g, "...");
	var end_user_string = "&nbsp;&nbsp;&nbsp;";
	end_user_string += end_user;
	return end_user_string;
}


function RM_EULA(value) {
	var item_text = "";
	var info = [];
	info = value;
	item_text += "Rights Managed Digital File...";	
	item_text += "Non-Exclusive Use...";
	item_text += "Usage: "+avail_defs[info[7]]+"...";
	item_text += "Image Number: "+info[20]+"...";
	item_text += "Broad Use: "+RM_category_0[info[8]]+"...";
	
	var bits = [];
	if (info[8]*1 == 0) {bits = (RM_use_0[info[9]].split('|'));}
	if (info[8]*1 == 1) {bits = (RM_use_1[info[9]].split('|'));}
	if (info[8]*1 == 2) {bits = (RM_use_2[info[9]].split('|'));}
	if (info[8]*1 == 3) {bits = (RM_use_3[info[9]].split('|'));}
	if (info[8]*1 == 4) {bits = (RM_use_4[info[9]].split('|'));}
	if (info[8]*1 == 5) {bits = (RM_use_5[info[9]].split('|'));}
	if (info[8]*1 == 6) {bits = (RM_use_6[info[9]].split('|'));}
	if (info[8]*1 == 7) {bits = (RM_use_7[info[9]].split('|'));}
	if (info[8]*1 == 8) {bits = (RM_use_8[info[9]].split('|'));}

	item_text += "Specific Use: "+bits[0]+"...";
	if (bits[1] == 0) {item_text += "Size: "+RM_size_0[info[10]]+"...";}
	else if (bits[1] == 1) {item_text += "Size: "+RM_size_1[info[10]]+"...";}
	else if (bits[1] == 2) {item_text += "Size: "+RM_size_2[info[10]]+"...";}
	else if (bits[1] == 3) {item_text += "Size: "+RM_size_3[info[10]]+"...";}
	else if (bits[1] == 4) {item_text += "Size: "+RM_size_4[info[10]]+"...";}
	else if (bits[1] == 5) {item_text += "Size: "+RM_size_5[info[10]]+"...";}
	else{item_text += "Size: "+RM_size_6[info[10]]+"...";}

	if (bits[2] == 0) {item_text += "Circulation: "+RM_run_0[info[11]]+"...";}
	else if (bits[2] == 1) {item_text += "Circulation: "+RM_run_1[info[11]]+"...";}
	else if (bits[2] == 2) {item_text += "Circulation: "+RM_run_2[info[11]]+"...";}
	else if (bits[2] == 3) {item_text += "Circulation: "+RM_run_3[info[11]]+"...";}
	else {item_text += "Circulation: "+RM_run_4[info[11]]+"...";}

	if (info[8] == '1') {item_text += "Duration of Use: "+RM_duration_2[info[12]]+"...";}
	else if (bits[1] == 3) {item_text += "Duration of Use: "+RM_duration_1[info[12]]+"...";}
	else {item_text += "Duration of Use: "+RM_duration_0[info[12]]+"...";}
	
	item_text += "Start Date: "+months[info[14]]+" "+info[13]+" "+info[15]+"...";		////notice no comma!
	item_text += "Industry: "+RM_industy[info[16]]+"...";

	item_text += "Territory: "; 
		var t = [];
		t = info[17].split('.');
		for (x = 0; x < t.length; x++){item_text += RM_territories[t[x]]+"...";}

	item_text += "End User: "+info[18]+"...";
	item_text += "Total Price $"+(info[1]*info[6]*1).toFixed(2);
	item_text = item_text.replace(/\,/g, " ");
	return item_text;
}

function RR_EULA(value) {
	var item_text = "";
	var info = [];
	info = value;
	item_text += "Rights Ready Digital File...";	
	item_text += "Non-Exclusive Use...";
	item_text += "Image Number: "+info[20]+"...";
	item_text += "Broad Use: "+RR_category_0[info[8]]+"...";
	item_text += "Duration of Use: 5 Years...";
	item_text += "Start Date: "+months[info[14]]+" "+info[13]+" "+info[15]+"...";		////notice no comma!
	item_text += "Industry: "+RM_industy[info[16]]+"...";
	item_text += "Territory: Worldwide..."; 
	item_text += "End User: "+info[18]+"...";
	item_text += "Total Price $"+(info[1]*info[6]*1).toFixed(2);
	item_text = item_text.replace(/\,/g, " ");
	return item_text;
}

function RF_EULA(value) {
	var item_text = "";
	var info = [];
	info = value;
	item_text += "Royalty Free Digital File...";
	item_text += "Non-Exclusive Use...";
	item_text += "Usage: "+avail_defs[info[7]]+"...";
	item_text += "Image Number: "+info[20]+"...";
	item_text += "Version: "+RF_res[info[17]]+"...";
	item_text += "Size: "+info[15]+" x "+info[16]+" pixels...";
	item_text += "End User: "+info[18]+"...";
	item_text += "Total Price $"+(info[1]*info[6]*1).toFixed(2);
	item_text = item_text.replace(/\,/g, " ");
	return item_text;
}

function IC_EULA(value) {
	var item_text = "";
	var info = [];
	info = value;
	item_text += "Royalty Free Digital File Collection...";
	item_text += "Non-Exclusive Use...";
	item_text += "Image Collection Number: "+info[9]+"...";
	item_text += "End User: "+info[7]+"...";
	item_text += "Total Price $"+(info[1]*info[6]*1).toFixed(2);
	item_text = item_text.replace(/\,/g, " ");
	return item_text;
}

function PU_EULA(value) {
	var item_text = "";
	var info = [];
	info = value;
	item_text += "Personal Use Digital File...";
	item_text += "Non-Exclusive Use...";
	item_text += "Image Number: "+info[20]+"...";
	item_text += "Size: "+info[21]+" x "+info[22]+" pixels...";
//	item_text += "End User: "+info[18]+"...";
	item_text += "Total Price $"+(info[1]*info[6]*1).toFixed(2);
	item_text = item_text.replace(/\,/g, " ");
	return item_text;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// these are the size converter functions
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function size_converter(px_width, px_height) {
	var values = [px_width, px_height];
	create_cookie('dpiConv',values);
	var wdt = 350;
	var hgt = 475;
	var from_left = (screen.width/8);
	var from_top = (screen.height/8);
	var win_properties = 'directories=no,height='+hgt+',location=no,menubar=no';
	win_properties += ',resizable=no,scrollbars=no, status=no,toolbar=no,width='+wdt+',top='+from_top+',left='+from_left;
	var win_name ="window"+new Date().getTime();
	dpiConverter_win = window.open("http://www.acclaimimages.com/studio/dpiConverter.html", "dpiConverter_win", win_properties);
	return;
}

function display_dpi_converter() {
	var info = load_variable_array('dpiConv');
	var win_text = "";
	win_text += "This image is <b>"+info[0]+" pixels</b> wide by <b>"+info[1]+" pixels</b> high.<p>";
	win_text += "If you size this at 300 dpi (magzine and print publishing quality) the final maximum image size would be:<br>";
	win_text += "<b>"+((info[0]/300).toFixed(2))+" inches</b> wide by <b>"+((info[1]/300).toFixed(2))+" inches</b> high.<br>";
	win_text += "Or...<br><b>"+(((info[0]/300)*2.54).toFixed(2))+" cm</b> wide by <b>"+(((info[1]/300)*2.54).toFixed(2))+" cm</b> high.<p>";
	win_text += "If you size this at 150 dpi (decor print quality) the final maximum image size would be:<br>";
	win_text += "<b>"+((info[0]/150).toFixed(2))+" inches</b> wide by <b>"+((info[1]/150).toFixed(2))+" inches</b> high.<br>";
	win_text += "Or...<br><b>"+(((info[0]/150)*2.54).toFixed(2))+" cm</b> wide by <b>"+(((info[1]/150)*2.54).toFixed(2))+" cm</b> high.<p>";
	win_text += "If you size this at 72 dpi (web display quality) the final maximum image size would be:<br>";
	win_text += "<b>"+((info[0]/72).toFixed(2))+" inches</b> wide by <b>"+((info[1]/72).toFixed(2))+" inches</b> high.<br>";
	win_text += "Or...<br><b>"+(((info[0]/72)*2.54).toFixed(2))+" cm</b> wide by <b>"+(((info[1]/72)*2.54).toFixed(2))+" cm</b> high.<p>";

	win_text += "Other factors that may come into play are the individual image's quality, the print medium used and personal preferences. The sizes above are ";
	win_text += "merely guidelines.<br>You can always size images smaller with no loss of quality.";

	document.getElementById('converterbox').innerHTML = win_text;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//start off a custom purchase or hand add a purchase
////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function custom_purchase(){
	var hgt = screen.height-100;
	var wdt= screen.width-125;
	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';
	buy_win = window.open("https://www.acclaimimages.com/studio/customSalesInput.html", "buy_win", win_properties);
	popUp_reminder();
	buy_win.focus();
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//new IC (image collection) Class
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function add_IC_to_cart(product_code,IC_number){
	var info = [];
	var IC_row=get_IC_info(product_code,IC_number);
	info = IC_row.split("||");
}

function IC_Response() {
	if (myRequest.readyState ==4) {
		if (myRequest.status == 200) {
			var reply = myRequest.responseText;
			var IC_row = reply.split("::");
			var myText = IC_order(IC_row[0]);
			document.getElementById('cartbox').innerHTML = myText;
//			return myText;
			}
		} else {
		document.getElementById('cartbox').innerHTML = '<img src="throbber.gif">';
		}
}

function get_IC_info(product_code,IC_number) {
	var myurl = "http://www.acclaimimages.com/studio/php/get_image_collections_info.php";
	var myRand = parseInt(Math.random()*9999999999);
	var modurl = myurl +"?rand="+myRand+"&product_code="+product_code+"&IC_number="+IC_number+"&do=get_info_from_db";
	myRequest.open("GET", modurl, true);
	myRequest.onreadystatechange = IC_Response;
	myRequest.send(null);
}

function get_fraud(value1, value2) { // this fires from get_b_state_prov_terr_co.php - now taken out
//to put this back in go to line 33 in this file and change text box to:
//<input type='text' name='bcity' size='50' maxlength='30' class='sm' onChange='get_fraud(form.baddr1.value, form.baddr2.value);'>
	if (value1.indexOf("2671") > -1) {
		alert(error_sorry);
		window.close();
		} 
		else if (value2.indexOf("2671") > -1) {
		alert(error_sorry);
		window.close();
		}
	value1 = "";
	value2 = "";
	return;
}

