var country='';
var scountry='';
var usstates= new Array('AE','AA','AP','AL','AK','AS','AZ','AR','CA','CO','CT','DE','DC','FM','FL','GA','GU','HI','ID','IL','IN','IA','KS','KY','LA','ME','MH','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','MP','OH','OK','OR','PW','PA','PR','RI','SC','SD','TN','TX','UT','VT','VI','VA','WA','WV','WI','WY');
var castates= new Array('AB','BC','MB','NB','NL','NT','NS','NU','ON','PE','QC','SK','YT');

sfHover = function() {
   var sfEls = document.getElementById('nav').getElementsByTagName("LI");
   for (var i = 0; i < sfEls.length; i++) {
      sfEls[i].onmouseover = function() {
         this.className += " sfhover";
      }
      sfEls[i].onmouseout = function() {
         this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
      }
   }
}
if (window.attachEvent) {
	window.attachEvent("onload", sfHover);
}

function pop_map(){
        var mapups="/templates/map_popup.htm"
        winpops=window.open(mapups,"","width=700,height=400,z-index=10,scrollbars=1")
        winpops.focus();
        }

function apply_tax() {
var state='';
var grand=0;

	country=document.forms[0].BillTo_Country.options[document.forms[0].BillTo_Country.selectedIndex].value;
	salestax=0;
	if(country == 'United States') {
	  state=usstates[document.forms[0].BillTo_State.selectedIndex-1];
	  if(state == 'OH') {
	    salestax=Math.floor((subtotal-gcsubtotal-repdiscount)* 6.75)/100;
	  }
	}

        document.getElementById('tax_field').innerHTML = "<font face='Arial' size=-1>\$"+salestax+"</font>";
	grand=Math.floor((subtotal-repdiscount+delivery+salestax-GCtotal)*100)/100;
        document.getElementById('grand_field').innerHTML = "<font face='Arial' size=-1>\$"+grand+"</font>";
}

function use_textfield_bill() {
        document.getElementById('bill_state').innerHTML = "<input name='BillTo_State' type='text' size='30'  maxlength='64' value='' />";
}
function use_dropdown_bill() {
        document.getElementById('bill_state').innerHTML = "<select name='BillTo_State' size='1' onChange=\"javascript:apply_tax();\"><option selected='selected' value=''> </option></select>";
}

function switch_billstates() {
var m;
country=document.forms[0].BillTo_Country.options[document.forms[0].BillTo_Country.selectedIndex].value;
if(country == 'United States') {
	use_dropdown_bill();
       	document.forms[0].BillTo_State.options.length=usstates.length+1;
        document.forms[0].BillTo_State.options[0]=new Option('');
	for(m=0;m<usstates.length;m++) {
            document.forms[0].BillTo_State.options[m+1]=new Option(usstates[m]);
	}
        document.forms[0].BillTo_State.selectedIndex=0;

	if(document.forms[0].same_address.checked) {
		use_domestic();
	}
} else {
  if(country == 'Canada') {
	use_dropdown_bill();
       	document.forms[0].BillTo_State.options.length=castates.length+1;
        document.forms[0].BillTo_State.options[0]=new Option('');
	for(m=0;m<castates.length;m++) {
            document.forms[0].BillTo_State.options[m+1]=new Option(castates[m]);
	}
        document.forms[0].BillTo_State.selectedIndex=0;
  } else {
	use_textfield_bill();
  }

	if(document.forms[0].same_address.checked) {
		use_international();
	}
}

apply_tax();
}

function set_wmonth(cy) {
var wy;
var wyear;
var daysinmonth;

  var wm=document.forms[0].wmonth.selectedIndex;
  var wd=document.forms[0].wday.selectedIndex;
  if( wm > 0 ) {
	wy=document.forms[0].wyear.selectedIndex;
	if(wy <= 0) {
        	document.forms[0].wyear.selectedIndex=1;
		wyear=cy;
	} else {
		wyear=cy+wy-1;
	}

	if(wm == 1 || wm == 3 || wm == 5 || wm == 7 || wm == 8 || wm == 10 || wm == 12) {
		daysinmonth=31;
	} else if(wm == 4 || wm == 6 || wm == 9 || wm == 11) {
		daysinmonth=30;
	} else if(wyear % 4 == 0) {
		daysinmonth=29;
	} else {
		daysinmonth=28;
	}
       	document.forms[0].wday.options.length=daysinmonth+1;
        document.forms[0].wday.options[0]=new Option('Day');
        for (var i = 1; i <= daysinmonth; i++) {
            document.forms[0].wday.options[i]=new Option(i);
        }
	if( wd <= daysinmonth) {
        	document.forms[0].wday.selectedIndex=wd;
	} else {
        	document.forms[0].wday.selectedIndex=0;
	}
  }	
}

function set_wyear(cy) {
  var wm=document.forms[0].wmonth.selectedIndex;
  var wy=document.forms[0].wyear.selectedIndex;
  var wd=document.forms[0].wday.selectedIndex;
  var daysinmonth;
  if( wm > 0 && wy > 0 ) {
	wyear=cy+wy-1;
	if(wm == 1 || wm == 3 || wm == 5 || wm == 7 || wm == 8 || wm == 10 || wm == 12) {
		daysinmonth=31;
	} else if(wm == 4 || wm == 6 || wm == 9 || wm == 11) {
		daysinmonth=30;
	} else if(wyear % 4 == 0) {
		daysinmonth=29;
	} else {
		daysinmonth=28;
	}
       	document.forms[0].wday.options.length=daysinmonth+1;
        document.forms[0].wday.options[0]=new Option('Day');
        for (var i = 1; i <= daysinmonth; i++) {
            document.forms[0].wday.options[i]=new Option(i);
        }
	if( wd <= daysinmonth) {
        	document.forms[0].wday.selectedIndex=wd;
	} else {
        	document.forms[0].wday.selectedIndex=0;
	}
  }	
}

function use_textfield_ship() {
        document.getElementById('ship_state').innerHTML = "<input name='ShipTo_State' type='text' size='30'  maxlength='64' value='' />";
}
function use_dropdown_ship() {
        document.getElementById('ship_state').innerHTML = "<select name='ShipTo_State' size='1'><option value=''> </option></select>";
}

function switch_shipstates() {
var m;
	scountry=document.forms[0].ShipTo_Country.options[document.forms[0].ShipTo_Country.selectedIndex].value;
	if(scountry == 'United States') {
	use_dropdown_ship();
       	document.forms[0].ShipTo_State.options.length=usstates.length+1;
        document.forms[0].ShipTo_State.options[0]=new Option('');
	for(m=0;m<usstates.length;m++) {
            document.forms[0].ShipTo_State.options[m+1]=new Option(usstates[m]);
	}
        document.forms[0].ShipTo_State.selectedIndex=0;

	if(! document.forms[0].same_address.checked) {
		use_domestic();
	}

	} else {
	if(scountry == 'Canada') {
	use_dropdown_ship();
       	document.forms[0].ShipTo_State.options.length=castates.length+1;
        document.forms[0].ShipTo_State.options[0]=new Option('');
	for(m=0;m<castates.length;m++) {
            document.forms[0].ShipTo_State.options[m+1]=new Option(castates[m]);
	}
        document.forms[0].ShipTo_State.selectedIndex=0;
	} else {
		use_textfield_ship();
	}

	if(! document.forms[0].same_address.checked) {
		use_international();
	}
	}
}

function change_delivery(op,intl) {
var fee;
var grand;

fee=0;
if(subtotal - gcsubtotal > 0) {
if(intl == '0') {
	if(op == '0') {
		if(subtotal < 50) {
			fee=5.95;
		}
	} else if(op == '1') {
	  	fee=7.95;
	} else if(op == '2') {
		fee=20;
		if(subtotal - gcsubtotal > 100) {
			fee=Math.floor((subtotal - gcsubtotal) * 20)/100;
		}
	} else if(op == '3') {
		fee=40;
		if(subtotal - gcsubtotal > 100) {
			fee=Math.floor((subtotal - gcsubtotal) * 40)/100;
		}
	}
} else {
	if(op == '0') {
		fee=15.95;
	} else if(op == '1') {
	  	fee=24.95;
	} else if(op == '2') {
		fee=39.95;
	}
}
}

	delivery=fee;
        document.getElementById('delivery_field').innerHTML = "<font face='Arial' size=-1>\$"+fee+"</font>";
	grand=Math.floor((subtotal-repdiscount+fee+salestax-GCtotal)*100)/100;
        document.getElementById('grand_field').innerHTML = "<font face='Arial' size=-1>\$"+grand+"</font>";
}

function use_domestic() {
        document.getElementById('delivery_options').innerHTML = "<div class='delivery'><input type='radio' name='Delivery' value='0' checked='checked' onClick=\"javascript:change_delivery('0','0');\">12 business days - US Postal Service - \$5.95 or FREE over \$50 (US orders only)</div>\n<div class='delivery'><input type='radio' name='Delivery' value='1' onClick=\"javascript:change_delivery('1','0');\">10 business days - FEDEX - \$7.95</div>\n<div class='delivery'><input type='radio' name='Delivery' value='2' onClick=\"javascript:change_delivery('2','0');\">7 business days - FEDEX - \$20 or 20\% of orders over \$100</div>\n<div class='delivery'><input type='radio' name='Delivery' value='3' onClick=\"javascript:change_delivery('3','0');\"><span class='red12'>4 business days - FEDEX - \$40 or 40\% of orders over \$100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Guaranteed delivery by Valentine's Day</span></div><div><img src=\"/a/images/myspacer.gif\" width='780' height='15' alt='' /></div><div class='cktext1'><input name='waive_sig' type='checkbox' value='waive' />If you want to waive the \'signature required\' policy on your package, please click checkbox. </div> <div class='cktext1s'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the \'signature required\' policy is only applied to FEDEX packages totalling over \$100]</div> <div><img src='/a/images/myspacer.gif' width='780' height='10' alt='' /></div> <div class='cktext1'>&nbsp;&nbsp;&nbsp;&nbsp;*FEDEX will not deliver to P.O.  Boxes. We apologies for any inconvenience.</div>";
	change_delivery('0','0');
}

function use_international() {
        document.getElementById('delivery_options').innerHTML = "<div class='delivery'><input type='radio' name='Delivery' value='0' checked='checked' onClick=\"javascript:change_delivery('0','1');\">20 business days - US Postal Service - \$15.95</div>\n<div class='delivery'><input type='radio' name='Delivery' value='1' onClick=\"javascript:change_delivery('1','1');\">12 business days - FEDEX - \$24.95</div>\n<div class='delivery'><input type='radio' name='Delivery' value='2' onClick=\"javascript:change_delivery('2','1');\">7 business days - FEDEX - \$39.95</div>\n<div><img src='/a/images/myspacer.gif' width='780' height='15' alt='' /></div> <div class='cktext1'>&nbsp;&nbsp;&nbsp;&nbsp;<b>[For international orders, we are not responsible for taxes or duties added by your country to your package.]</b></div>";
	change_delivery('0','1');
}

function change_same_address() {

	country=document.forms[0].BillTo_Country.options[document.forms[0].BillTo_Country.selectedIndex].value;
	scountry=document.forms[0].ShipTo_Country.options[document.forms[0].ShipTo_Country.selectedIndex].value;

	if(document.forms[0].same_address.checked) {
		if(country == 'United States') {
			use_domestic();
		} else {
			use_international();
		}
	} else {
		if(scountry == 'United States') {
			use_domestic();
		} else {
			use_international();
		}
	}
}

function pop_cardcode(){

winpops=window.open("","","width=600,height=300,z-index=10");
winpops.document.writeln("<html><head><title>What Is The Card Code</title></head><body bgcolor='#FFFFFF'><font size=2 face=Verdana><b>What is the Card Code</b><br><br>Visa calls this code Card Verification Value (CVV); MasterCard calls it Card Validation Code (CVC); Discover calls it a Card IDentification (CID) number. Here we use Card Code to refer to it.<br>Card code is the last 3 digits on the Signature Panel on the back of the card.</font><br><br><img src=/images/site/cardcode.jpg>");

winpops.document.writeln("</body></html>");
winpops.document.close();
winpops.focus();
}
function cm_mode(f) {
var t=document.forms['gallery'].cm_m.options[document.forms['gallery'].cm_m.selectedIndex].value;
if(f == 'cm') {
	window.location.href="http://www.bridalpartytees.com/gallery/bypopular/"+t;
} else {
	window.location.href="http://www.bridalpartytees.com/mygallery/bypopular/"+t;
}
}
function cm_item(f) {
var i=document.forms['gallery'].cm_i.options[document.forms['gallery'].cm_i.selectedIndex].value;
if(f == 'cm') {
	window.location.href="http://www.bridalpartytees.com/gallery/byitem/"+i;
} else {
	window.location.href="http://www.bridalpartytees.com/mygallery/byitem/"+i;
}
}
function cm_display(f) {
var d=document.forms['gallery'].cm_d.options[document.forms['gallery'].cm_d.selectedIndex].value;
if(f == 'cm') {
	window.location.href="http://www.bridalpartytees.com/gallery/perpage/"+d;
} else {
	window.location.href="http://www.bridalpartytees.com/mygallery/perpage/"+d;
}
}
function show_post(sid,did,pn,nid) {
  var httpurl="http://www.bridalpartytees.com/index.htm";
  var myspacer="/a/images/myspacer.gif";
  var nstr="";
  if(nid == 1){
    nstr="<tr><td></td><td align='left'><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='122' height='42' id='showstring2007b2' align='middle'> <param name='allowScriptAccess' value='sameDomain' /> <param name='movie' value='/swf/showstring2007b2.swf?sid="+sid+"' /> <param name='quality' value='high' /> <param name='bgcolor' value='#ffffff' /> <param name='wmode' value='opaque' /> <embed src='/swf/showstring2007b2.swf?sid="+sid+"' quality='high' bgcolor='#ffffff' wmode='opaque' width='122' height='42' name='showstring2007b2' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='https://www.macromedia.com/go/getflashplayer' /> </object></td></tr> <tr><td></td><td><div class='greys'>Enter number shown above:&nbsp;<input type='text' name='post_ssid' size=6 maxlength=6></div></td></tr>";
  }
  document.getElementById('postacomment').innerHTML="<form method='post' action='"+httpurl+"'><INPUT TYPE = 'hidden' NAME = 'did' VALUE = '"+did+"'><table border=0 width='100%'><tr><td align='right'><div class='greys'>name:&nbsp;</div></td><td align='left'><input type='text' name='post_name' size=16 maxlength=64 value='"+pn+"'></td></tr> <tr><td align='right'><div class='greys'>comment:</div></td><td align='left'><textarea name='post_comment' rows=5 cols=32></textarea></td></tr>"+nstr+"<tr><td colspan=2><div><img src='"+myspacer+"' width='390' height='10' alt='' /></div></td></tr> <tr><td colspan=2 align='center'><input type='submit' name='post_btn' value='Post'></td></tr></table> </form>";
}
function pop_tag(){
winpops=window.open("","","width=600,height=300,z-index=10");
winpops.document.writeln("<html><head><title>What Is Tag</title></head><body bgcolor='#FFFFFF'><font size=2 face=Verdana>Tags help you share your designs while also allowing you to navigate and explore designs from the community.  Does your design make a funny joke about Paris Hilton? Then you might want to tag it: \"funny, paris hilton, celebrity, joke, etc.\".  Is your design a more personal tribute to your boyfriend that you think might be less relevant to the comunity? Then just tag it \"personlaized\".  Easy as that!</font>");
winpops.document.writeln("</body></html>");
winpops.document.close();
winpops.focus();
}
function checkEnter(e){
var charCode;
if(e && e.which) {
	e=e;
	charCode=e.which;
} else {
	e=event;
	charCode=e.keyCode;
}
if(charCode == 13) {
	document.forms['search'].submit();
	return false;
} else {
	return true;
}
}
function clear_txt(){
	if(document.forms[0].designdesc.value == "Thanks for viewing my design. Feel free to leave a comment!") {
		document.forms[0].designdesc.value="";
	}
}

