var mainimagesloc = "../images/";

var parenthref = "http://www.craftyshops.com";


var base= new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9","A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z","a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")
var pass=""
var z=23;
var y=28;
var f= new Array();
var K= new Array();
for (x=0; x<10; x++){
f[x]=x<<9
f[x]+=23
}
for (x=10; x<36; x++){
y=y<<1
v= Math.sqrt(y)
v = parseInt(v,16)
v+=5
f[x]=v
y++
}
for (x=36; x<62; x++){
z=z<<1
v= Math.sqrt(z)
v = parseInt(v,16)
v+=74
f[x]=v
z++
}
var iCounter = 3 //How many retries
function inc(){
iCounter--
if (iCounter > 0)
{
if (confirm("\nPassword is incorrect.\n\n\n\nRetry?"))
Check()
else
alert('Password incorrect.');
history.go(-1);

// You may use this element istead if you want.
// location.href='denied.html' //Cancel html file

}
else
alert('Your three tries are up.  Access Denied.');
history.go(-1);

// You may use this element istead if you want.
// location.href='denied.html' // 3 times incorrect html file

}
function Check(){
pass = prompt("Enter your password.","")
if(pass==null || pass==""){
history.go(-1)}
else{
var lpass=(pass.length)+1
for (l=1; l<lpass; l++){
K[l]=pass.charAt(l)
}
var code=0;
for (y=1; y<lpass; y++){
for(x=0; x<62; x++){
if (K[y]==base[x]){
code+=f[x]
code*=y
      }
   }
}

<!-- STEP TWO: Put access code here!  -->
if (code==55106198) 		// code==[your access code]

go()
else
inc()
   }
}
function go(){
location.href=pass+".html";
}
// End -->



<!-- Begin
timeout =0; // Close window after __ number of seconds?
// 0 = do not close, anything else = number of seconds



function getImageWindowCode(imageName, imageLoc) {

text = "<html><head><title>Preview</title></head>";
text += "<script language=\"javascript\">";
text += "function changeImage(imagesrc) {";
text += "    document.images[0].src = imagesrc\;";
text += "}";

text += "</script>";
text += "<body bgcolor='white'><center>";
text += "<form name=imageform>";
text += "<img name='mainimage' src='" + imageLoc + imageName + ".jpg' width=300 height=350 >";
text += "<br>";
text += "<table><tr><td><a  href=\"javascript:changeImage('" + imageLoc + imageName + "F.jpg');\" title='Click to Enlarge'> <img name=mainimage width=50 height=50 src='" + imageLoc + imageName + "F.jpg' width=300 height=350 ></a></td>";
text += "<td><a  href=\"javascript:changeImage('" + imageLoc + imageName + "B.jpg');\" title='Click to Enlarge'> <img name=mainimage width=50 height=50 src='" + imageLoc + imageName + "B.jpg' width=300 height=350 ></a></td>";
text += "<td><a  href=\"javascript:changeImage('" + imageLoc + imageName + "O.jpg');\" title='Click to Enlarge'> <img name=mainimage width=50 height=50 src='" + imageLoc + imageName + "O.jpg' width=300 height=350 ></a></td>";
text += "</tr>";
text += "<tr><td>Front</td><td>Back</td><td>Other</td></tr>";
text += "</table>";
text += "</form>";
text += "</center></body></html>";

return text;

}




function ShowImages(ImageName, ImageLoc, WIDTH, HEIGHT) {
alert("in showimages");
windowprops = "left=50,top=50,width=" + (WIDTH+50) + ",height=" + (HEIGHT+100);

windowpropslong = "left=50,top=50,width=" + (WIDTH+50) + ",height=" + (HEIGHT+100);

text = getImageWindowCode(ImageName, ImageLoc);


if (WIDTH < HEIGHT) {

preview = window.open("picturewide.html", "previewlong", windowpropslong);

preview.document.open();

preview.document.write(text);

if (window.focus) {preview.focus()}
preview.document.close();
} else {
preview = window.open("picturetall.html", "preview", windowprops);
preview.document.open();
preview.document.write(text);

if (window.focus) {preview.focus()} 
preview.document.close();
}
}







function Start(URL, WIDTH, HEIGHT) {

windowprops = "left=50,top=50,width=" + (WIDTH+50) + ",height=" + (HEIGHT+50);

windowpropslong = "left=50,top=50,width=" + (WIDTH+50) + ",height=" + (HEIGHT+50);

text = "<html><head><title>Preview</title></head><body bgcolor='white'";

if (timeout != 0) text +=" onLoad=\"setTimeout('window.close()', " + timeout*1000 + ");\"";

text += "><center><img src='" + URL + "' width=" + WIDTH + " height=" + HEIGHT + " >";

if (timeout != 0) text +="<br><font face='arial, helvetica' size='-1'>Preview closes after " + 

timeout + " seconds.</font>";

text += "</center></body></html>";

if (WIDTH < HEIGHT) {

preview = window.open("picturewide.html", "previewlong", windowpropslong);

preview.document.open();

preview.document.write(text);

if (window.focus) {preview.focus()}
preview.document.close();
} else {
preview = window.open("picturetall.html", "preview", windowprops);
preview.document.open();
preview.document.write(text);

if (window.focus) {preview.focus()} 
preview.document.close();
}
}

function open_new_index_page(indexpage, mainframe) {
  window.open(indexpage);
  parent.frames[0].document.close()
// parent.frames[1].document.open()
  parent.frames[0].location = mainframe;
  parent.frames[0].document.close()
}

function open_new_index_page(indexpage) {
  window.open(indexpage);
  //parent.frames[2].document.close()
// parent.frames[1].document.open()
 // parent.frames[2].location = mainframe;
//  parent.frames[2].document.close()
}

function update_nav_buttons()
{
var i = 0; 
var k = 0; 
 {for (i = 0;i < parent.main.document.form1.elements.length;i++)
  {for (k=1;k<=items_ordered;k++)
   {
if ((itemlist[k].code ==  parent.main.document.form1.elements[i].name) && (k<=items_ordered) && (i<=parent.main.document.form1.elements.length))
         parent.main.document.form1.elements[i].value = itemlist[k].quan
   }
  }
 }   
}

function navButtonChange(id, bNav){
alert('in navButtonChange');
if (bNav = true) {
alert('in function id : ' + id);
document.getElementById(id).scr="menu-1-on.gif";
}
}


function format(val, post)
{
    var decpoint;
    var begin;
    var end;
    var valstr;
	var temp_char;

    valstr = "" + val;
	//alert('valstr = ' + valstr);
    decpoint = valstr.indexOf(".")
    if (decpoint != -1) {
	    //alert('decpoint = ' + decpoint);
        begin = valstr.substring(0,decpoint);
        end = valstr.substring(decpoint+1,valstr.length);
		//alert('begin = ' + begin + '\nend= ' + end);
    }
    else {
        begin = valstr;
        end = "";
    } 
	if (end.length < post)
	 {while (end.length < post)
	    {
        end += "0";
        }
	 }
     
	end = end.substring(0,post);
	//alert('begin = ' + begin + '\nend= ' + end);
    return (begin+"."+end);
}

var craftyshopslink = "javascript:parent.open_new_index_page('http://www.giftyshops.com')";


function getVar(name)
         {
         get_string = document.location.search;         
         return_value = '';
         
         do { //This loop is made to catch all instances of any get variable.
            name_index = get_string.indexOf(name + '=');
            
            if(name_index != -1)
              {
              get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);
              
              end_of_value = get_string.indexOf('&');
              if(end_of_value != -1)                
                value = get_string.substr(0, end_of_value);                
              else                
                value = get_string;                
                
              if(return_value == '' || value == '')
                 return_value += value;
              else
                 return_value += ', ' + value;
              }
            } while(name_index != -1)
            
         //Restores all the blank spaces.
         space = return_value.indexOf('+');
         while(space != -1)
              { 
              return_value = return_value.substr(0, space) + ' ' + 
              return_value.substr(space + 1, return_value.length);
							 
              space = return_value.indexOf('+');
              }
          
         return(return_value);        
         }

function format(val, post)
{
    var decpoint;
    var begin;
    var end;
    var valstr;
	var temp_char;

    valstr = "" + val;
	//alert('valstr = ' + valstr);
    decpoint = valstr.indexOf(".")
    if (decpoint != -1) {
	    //alert('decpoint = ' + decpoint);
        begin = valstr.substring(0,decpoint);
        end = valstr.substring(decpoint+1,valstr.length);
		//alert('begin = ' + begin + '\nend= ' + end);
    }
    else {
        begin = valstr;
        end = "";
    } 
	if (end.length < post)
	 {while (end.length < post)
	    {
        end += "0";
        }
	 }
     
	end = end.substring(0,post);
	//alert('begin = ' + begin + '\nend= ' + end);
    return (begin+"."+end);
}



<!-- calc start -->


function item_tot_price(i)
{
 total_item_price = (itemlist[i].price * itemlist[i].quan);
 return total_item_price;
}





function all_order_totals()

{order_total = 0;
if (item_num > 0)
 {  
for (i =1;i < item_num;i++)
 {order_total = order_total + item_tot_price(i);
}
   
 } return (order_total );
}

function shipping_order_totals()

{order_total = 0;
if (item_num > 0)
 {  
for (i =1;i < item_num;i++)
 {order_total = order_total + item_tot_price(i)}
   
 } return (add_shipping(order_total));
}

function tax_order_totals()

{order_total = 0;

if (item_num > 0)
 {  
for (i =1;i < item_num;i++)
 {order_total = order_total + item_tot_price(i)}

 } return (calc_tax(order_total));
}

function percent_off_order_totals()

{
order_total = 0;

if (item_num > 0)
 {  
for (i =1;i < item_num;i++)
 {order_total = order_total + item_tot_price(i)}

 } 
return (calc_percent_off(order_total));
}


function sub_order_totals()

{
order_total = 0;

if (item_num > 0)
 {  
for (i =1;i < item_num;i++)
 {order_total = order_total + item_tot_price(i)}

 }
return (calc_subtotal(order_total));
}


function overall_order_totals()

{order_total = 0;
if (item_num > 0)
 {  
for (i =1;i < item_num;i++)
 {order_total = order_total + item_tot_price(i)}
   
 } return (order_total + add_shipping(order_total) + calc_tax(order_total) - calc_percent_off(order_total) );
}


function add_shipping(order_total) {


if (order_total > 0) {

  ship_amount = add_shipping_FDF();
  ship_amount = ship_amount/1 + add_shipping_BDC()/1;
  ship_amount = ship_amount/1 + add_shipping_FDE()/1;

}


//if (parent.discount_shipping_flag == 'TRUE') {
//var actual_total = order_total - calc_percent_off(order_total);
//if (actual_total >= parent.ship_discount_limit) {

//ship_amount = 0.00;
//}
//}

return (ship_amount);

}  

function calc_percent_off(order_total) {
percent_off = 0;
if (parent.discount_flag == 'TRUE' ) { 
if (order_total > parent.percent_off_limit) {
  for (i =1;i < item_num;i++) {

  	percent_off =  (percent_off/1 + item_discount(i));
  }
} 
}
  return (percent_off);

}

function calc_subtotal(order_total) {
if (order_total > 50) {
  
  order_total = order_total - calc_percent_off(order_total);
 } 
  return (order_total);
}


function item_discount(i)
{
discount = 0;
discount = eval(itemlist[i].price * parent.globalpercentoff);
formatted_discount = format(discount,2);
quantity = itemlist[i].quan;
tot_item_discount = (eval(formatted_discount * quantity));
return (tot_item_discount);
}

function item_price_minus_discount(i)
{
percent_off = 0;
if (parent.discount_flag == 'TRUE') {
 if (all_order_totals() > parent.percent_off_limit ) { 
	percent_off = itemlist[i].price * parent.globalpercentoff;
 } 
}
return ((itemlist[i].price/1) - format(percent_off, 2));
}





function calc_tax(order_total) {
var percentage = .00;

if (order_total > 0) {
  
  tax_amount = (order_total * percentage);
  } 
  return (tax_amount);
}
  

<!-- calc end -->





function remove_nil_items(inputlist)
{var i = 0; 
 var j = 1; 
  for (i=1;i<item_num;i++)
   {if (itemlist[i].quan != 0)
    {temp_array[j]=itemlist[i]
     items_ordered =j 
     j=j+1
     } 
   } 
  itemlist = temp_array
  item_num = items_ordered + 1
}

function update_this_page()
{
var i = 0; 
var k = 0; 
 {for (i = 0;i < parent.main.document.form1.elements.length;i++)
  {for (k=1;k<=items_ordered;k++)
   {
if ((itemlist[k].code ==  parent.main.document.form1.elements[i].name) && (k<=items_ordered) && (i<=parent.main.document.form1.elements.length))
         parent.main.document.form1.elements[i].value = itemlist[k].quan
   }
  }
 }   
}

function item_quan(code)
{
var loc = check_if_in(code)
if (loc > 0)
 var quantities = itemlist[loc].quan
else
 var quantities = 0;
return quantities
}

function item_option(code)
{
var loc = check_if_in(code)
if (loc > 0)
 var options = itemlist[loc].option
else
 var options = null;
return optoins
}

function display_pic(graphic,price)
{
parent.frames[0].document.close()
// parent.frames[1].document.open()
parent.frames[0].document.write(st_astr);
parent.frames[0].document.write('<img src=images/' + graphic + '><br>' + price);
parent.frames[0].document.write('<p><a href="javascript:parent.updatenav_nav()">Navigation Table</a>');
parent.frames[0].document.write(en_astr);
parent.frames[0].document.close()
}

function createArray(n)
//n		size of array
//init	what you want all values initialized to
{               this.length = n
		var i = 0
		for (i = 1 ; i < n ; i++) 
			this[i] = null;	
                return this
}


function product(code,price,desc,quan,url,shop,option,ship)
{ this.price = 0
  this.code = code
  this.price = price
  this.desc = desc
  this.quan = quan
  this.url = url
  this.shop = shop
  this.option = option
  this.ship = ship
 return this;
}

var itemlist = new createArray(50);
var temp_array = new createArray(50);
var maxarray = 50;
function initialize_arrays(arraysa)
{
for (i = 1;i < maxarray;i++)
{
arraysa[i] = new product('',0,'',0,'','','',0)
}
}

function updatemain_order()
{
parent.frames[2].document.close()
// parent.frames[1].document.open()

parent.frames[2].location = "../html/order.html";

//parent.frames[2].location = "../../html/order.html";

parent.frames[2].document.close()
}

function updatenav_nav()
{
  parent.frames[0].document.close()
  // parent.frames[0].document.open()
  parent.frames[0].location = "navigate.htm";
  parent.frames[0].document.close()
}

function check_if_in(code_check) // this works
{
var i = 1
loc = 0;
// line 47
while ((i < item_num) && (itemlist[i].code != code_check))
  i = i + 1;
   if (itemlist[i].code == code_check)
    loc = i
   else
    loc = -1;
//alert('loc is ' + loc);
return loc;
}


function additem(codes,prices,descrip,url,shop,option,ship)
{
// adds another item to a variable length array
// remember to do it via new product()
// line 61
loc = check_if_in(codes)

if (loc != -1){
  // update existing item
  olditem =  itemlist[loc].quan
   itemlist[loc] = new product(codes,prices,descrip,olditem + 1,url,shop,option,ship)}
    else // new item
    {olditem =  itemlist[item_num].quan
    itemlist[item_num] = new product(codes,prices,descrip,olditem + 1,url,shop,option,ship);
    items_ordered = item_num
    item_num = item_num + 1
     }
    remove_nil_items(itemlist)
     
    parent.frames[0].document.close();
    parent.frames[0].location = url;
   // parent.frames[0].document.close();
   // parent.frames[0].location = "maintitle.html";
   
 }

function gotourl(url)
{
    parent.frames[0].document.close();
    parent.frames[0].location = url;
   
 }




function additem2(codes,prices,descrip,url,shop,quan,option_choice,ship)
{
var vars = url.substring(url.indexOf('?') + 1,url.length);
  
// adds another item to a variable length array
// remember to do it via new product()
// line 61
loc = check_if_in(codes)
if (loc != -1){
  // update existing item
  olditem =  itemlist[loc].quan
  
   itemlist[loc] = new product(codes,prices,descrip,quan,url,shop,option_choice,ship)}
    else // new item
    {olditem =  itemlist[item_num].quan
    itemlist[item_num] = new product(codes,prices,descrip,quan,url,shop,option_choice,ship);
    items_ordered = item_num
    item_num = item_num + 1
     }
    remove_nil_items(itemlist)
    parent.frames[0].document.close();
    parent.frames[0].location = "order.html?" + vars;
    //parent.frames[0].document.close();
    //parent.frames[0].location = "maintitle.html";
   
 }
// line 78

function subitem(codes,prices,descrip,url,shop)
{
loc = check_if_in(codes)
if ((loc != -1) && (itemlist[loc].quan > 0)) {
  // update existing item
  olditem =  itemlist[loc].quan
  //alert(' loc is before oldvalue ' + loc);
  //alert('olditem is ' + olditem);
  itemlist[loc] = new product(codes,prices,descrip,olditem - 1,url,shop)}
  //updatepage(codes) 

    parent.frames[0].document.close();
    parent.frames[0].location = "maintitle.html";
  
}




initialize_arrays(itemlist)
initialize_arrays(temp_array)



function item_sale_price(price) {

percent_off = 0;
percent_off = price * self.parent.globalpercentoff;

return (price/1 - format(percent_off, 2));
}


// ----------------  FDF Shipping ------------------

function add_shipping_FDF() {
var house_flag_quan = 0;
var yard_flag_quan = 0;
var ship_amount = 0;
var base_ship_amount = 0;
var shop_in = 0;
//if (order_total > 0) {

	for (i =1;i < item_num;i++) {
		var price = itemlist[i].price;
		var shop = itemlist[i].shop;
                if (shop == 'FDF') {
                        shop_in = 1;
			if (price.indexOf('12') == 0) {
				yard_flag_quan = yard_flag_quan/1 + (itemlist[i].quan)/1;
			}
			if (price.indexOf('45') > -1) {
				house_flag_quan = house_flag_quan/1 + (itemlist[i].quan)/1;
			}

			if (price.indexOf('55') > -1) {
				house_flag_quan = house_flag_quan/1 + (itemlist[i].quan)/1;
			}
		}


	}
        if (shop_in == 1) {
  		if (yard_flag_quan > 0 && house_flag_quan > 0) {
			base_ship_amount = 3;
		} else {

  			base_ship_amount = 2;
		}  

		var extra_ship = calc_extra_ship_FDF(house_flag_quan, yard_flag_quan);
    		ship_amount = base_ship_amount/1 + extra_ship/1;
	}
//}


return (ship_amount);

} 


function calc_extra_ship_FDF(house_flag_quan, yard_flag_quan) {
var base_yard_flag = 3;
var base_house_flag = 1;
var extra_ship = 0;


var extra_yard = yard_flag_quan - base_yard_flag;
var extra_house = house_flag_quan - base_house_flag;
if (extra_yard > 0) {
  extra_ship = extra_yard * .5;
}

if (extra_house > 0) {
  extra_ship = extra_ship/1 + (extra_house * 1)/1;

}

return extra_ship;

} 


function add_shipping_BDC() {
var outfit_quan = 0;
var ship_amount = 0;
var base_ship_amount = 2.00;
var shop_in = 0;
	for (i =1;i < item_num;i++) {
		var shop = itemlist[i].shop;
                if (shop == 'BDC') {
                        shop_in = 1;
			outfit_quan = outfit_quan/1 + (itemlist[i].quan)/1;
			
		}


	}
        if (shop_in == 1) {
		//ship_amount = base_ship_amount/1 + outfit_quan/2;
                ship_amount = base_ship_amount;
	}  


return (ship_amount);

}  


function add_shipping_FDE() {
var ship_amount = 0;
var shop_in = 0;
	for (i =1;i < item_num;i++) {
		var shop = itemlist[i].shop;
                if (shop == 'FDE') {
                       ship_amount = ship_amount/1 + (itemlist[i].ship/1 * itemlist[i].quan)/1;
			
		}


	}
          


return (ship_amount);

}  


// Modified to support Opera 
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

