var PayPal;

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function chg_size(formname,flagsize)
	{
	 I = chg_img('images/small/',formname);
	}
function chg_img(dirpath, formname)
	{
	itemname="";
	dtext="";
	LrgLink="";
	countfile="";
	formname=formname.toLowerCase();
	selectbox = document.forms[formname+"_form"].item_num;
	if(document.forms[formname+"_form"].fsize[1].checked)
		{flagsize = document.forms[formname+"_form"].fsize[1].value;}
	else
		{flagsize = document.forms[formname+"_form"].fsize[0].value;}
	passed_items = selectbox.options[selectbox.selectedIndex].value;
	items = passed_items.split(",");
	itemnum=items[0];
	itemname=items[1];
	item_price=items[3]-0;
	if(flagsize=="4x6"){item_price+=10;}
	switch(item_price) {
		case 24:
			item_price = "21.95";
			break;
		case 25:
			item_price = "26.95";
			break;
		case 26:
			item_price = "27.95";
			break;
		case 27:
			item_price = "28.95";
			break;
		case 28:
			item_price = "32.95";
			break;
		case 29:
			item_price = "36.95";
			break;
		case 30:
			item_price = "39.95";
			break;
		case 31:
			item_price = "54.95";
			break;
		case 32:
			item_price = "54.95";
			break;
		case 33:
			item_price = "39.95";
			break;
		case 34:
			item_price = "24.95";
			break;
		case 35:
			item_price = "32.95";
			break;
		case 36:
			item_price = "33.95";
			break;
		case 37:
			item_price = "36.95";
			break;
		case 38:
			item_price = "38.95";
			break;
		case 39:
			item_price = "42.95";
			break;
		case 40:
			item_price = "45.95";
			break;
		case 41:
			item_price = "64.95";
			break;
		case 42:
			item_price = "66.95";
			break;
		case 43:
			item_price = "60.95";
			break;
		}
	desc=items[2];
	switch(desc){
		case "International Flags":
			dtext="<p class='description'>Available for most counties, CF Flag brand, high quality, long-lasting, international flags are constructed using heavyweight nylon and reinforced at the the fly ends with four rows of lock stiching. All flags are specifically made for outdoor use.<span>$"+item_price+"</span></p>";
			break;
		case "State Flags":
			dtext="<p class='description'>Available for all US States and select territories, CF Flag brand, high quality, long-lasting, international flags are constructed using heavyweight nylon and reinforced at the the fly ends with four rows of lock stiching. All flags are specifically made for outdoor use.<span>$"+item_price+"</span></p>";
			break;
		case "Military Flags":
			dtext="<p class='description'>Available for US military services plus select historical military flags, high quality, long-lasting, international flags are constructed using heavyweight nylon and reinforced at the the fly ends with four rows of lock stiching. All flags are specifically made for outdoor use.<span>$"+item_price+"</span></p>";
			break;
		case "Confederate Flags":
			dtext="<p class='description'>Available for select historic Confederate flags, CF Flag brand, high quality, long-lasting, international flags are constructed using heavyweight nylon and reinforced at the the fly ends with four rows of lock stiching. All flags are specifically made for outdoor use.<span>$"+item_price+"</span></p>";
			break;
		case "Canadian Flags":
			dtext="<p class='description'>Available for all Canadian provinces plus Canadian national flag, CF Flag brand, high quality, long-lasting, international flags are constructed using heavyweight nylon and reinforced at the the fly ends with four rows of lock stiching. All flags are specifically made for outdoor use.<span>$"+item_price+"</span></p>";
			break;
		case "Pirate Flags":
			dtext="<p class='description'>Flag-It brand high quality sun-resistant decals printed on durable vinyl stock with ultra-violet blocking inks and manufactured with non-permanent adhesive featuring the skull and crossed bones of the jolly roger pirate flag<span>$"+item_price+"</span></p>";
			break;
		case "USA Flags":
			dtext="<p class='description'>Flag-It brand high quality sun-resistant decals printed on durable vinyl stock with ultra-violet blocking inks and manufactured with non-permanent adhesive proudly featuring the stars and stripes.<span>$"+item_price+"</span></p>";
			break;
		case "Miscellaneous Flags":
			dtext="<p class='description'>Available for select novelty flags such as the pirate Jolly Roger, ecology and dive flags, CF Flag brand, high quality, long-lasting, international flags are constructed using heavyweight nylon and reinforced at the the fly ends with four rows of lock stiching. All flags are specifically made for outdoor use.<span>$"+item_price+"</span></p>";
			break;
		}
	mydiv = document.getElementById(formname+"_div");
	divcollection = mydiv.getElementsByTagName("TD");
	if(dtext != "")divcollection[4].innerHTML=dtext;
	document.forms[formname+"_form"].select_btn.disabled=false;
	dirpath = "images/small/"
	
	var urltext = dirpath + itemnum + ".gif";
	var MarkitImg = new Image();
	MarkitImg.src = urltext;
	document.forms[formname+"_form"].small_img.src = MarkitImg.src;
	if(itemnum=="000") document.forms[formname+"_form"].select_btn.disabled = true;
	itemobj = document.forms[formname+"_form"].itemname;
	itemobj.value = itemname;
	}
function window_gotfocus(page)
	{
	if (PayPal && !PayPal.closed){
		PayPal.close();
	}else{
		if (window.gframe){
			window.gframe.location.href = "increment_counter.asp?page="+page;
			}
		else{
			var newframe = document.createElement("IFRAME");
			newframe.id = "gframe";
			newframe.height = 5;
			newframe.width = 30;
			newframe.src = "increment_counter.asp?page="+page; 
			newframe.visibility="hidden";
			document.body.appendChild(newframe);
		}
	}
}
//function open_window(linkstr)
//	{
//	PayPal = window.open(linkstr,'cartwin','width=600,height=400,scrollbars,location,resizable,status')
//	}
function goTo(formname, item_class)
	{
	formname=formname.toLowerCase();
	selectbox = document.forms[formname+"_form"].item_num;
	passed_items = selectbox.options[selectbox.selectedIndex].value;
	items = passed_items.split(",");
	itemnum=items[0];
	if(document.forms[formname+"_form"].fsize[1].checked)
		{flagsize = document.forms[formname+"_form"].fsize[1].value;}
	else
		{flagsize = document.forms[formname+"_form"].fsize[0].value;}	
	if(itemnum != "000")
		{
		var PayPalLink="cart.asp?item=" + itemnum + "&rtn=" + item_class + "&fsize=" + flagsize;
		//if (window.gframe){
		//	window.gframe.location.href = "items_ordered.asp?item=" + itemnum;
		//	}
		//else{
		//	var newframe = document.createElement("IFRAME");
		//	newframe.id = "gframe";
		//	newframe.src = "items_ordered.asp?item=" + itemnum + "&cost=" + item_price; 
		//	newframe.visibility="hidden";
		//	document.body.appendChild(newframe);
		//	}
		window.location.href=PayPalLink;
		//if (!PayPal || PayPal.closed) 
		//	{
		//	PayPal = window.open(PayPalLink,'cartwin','width=625,height=425,scrollbars,location,resizable,status');
			//i=confirm(PayPalLink);
		//	}
		//else
		//	{
		//	PayPal.location.href = PayPalLink;
		//	}
		}
	}
	
function goLarge(formname,itemclass)
	{
	//var selectbox = document.forms[formname+"_form"].item_num;
	//var itemnum = selectbox.options[selectbox.selectedIndex].value;
	formname=formname.toLowerCase();
	selectbox = document.forms[formname+"_form"].item_num;
	passed_items = selectbox.options[selectbox.selectedIndex].value;
	items = passed_items.split(",");
	itemnum=items[0];
	var itemname = document.forms[formname+"_form"].itemname.value;
	var LrgLink = "images/" + itemclass + "/large/" 
	LrgLink = LrgLink.toLowerCase() + itemname + ".jpg";
	LrgLink = "images/large/" + itemnum + ".gif"
	switch(itemclass){
		case 'Mark-It':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=520 width=350,left=20,top=20";
			break;
		case 'Patches':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=425 width=625,left=20,top=20";
			break;
		case 'Decals':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=425 width=625,left=20,top=20";
			break;
		case 'Flags':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=425 width=625,left=20,top=20";
			break;
		case 'Stickers':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=520 width=350,left=20,top=20";
			break;
		case 'Bears':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=520 width=350,left=20,top=20";
			break;
		case 'Signs':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=280 width=420,left=20,top=20";
			break;
		case 'Tattoos':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=520 width=350,left=20,top=20";
			break;
		case 'Hangers':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=520 width=300,left=20,top=20";
			break;
		case 'Foods':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=520 width=350,left=20,top=20";
			break;
		case 'Novelty':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=520 width=350,left=20,top=20";
			break;
		case 'Bumperstickers':
			winsize = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=400 width=550,left=20,top=20";
			break;
		}
	if (itemnum!="000") {window.open(LrgLink,'MyWindow',winsize);}
	}
	