#!/usr/bin/perl


$redir = "https://www.etsy.com/shop/BriMarie";
print "Status: 301 Moved Permanently\n";
print "Location: $redir\n\n";


### Cookies

 $hostip = $ENV{'REMOTE_ADDR'};
 require 'cookie.lib';

 $cartid = "nocookies";

 if (&GetCookies('cart')) {
   $cartid = $Cookies{'cart'};
 }
 else {
  ($sec,$min,$hr,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
   $cartid = "$sec$hr$min.$hostip";
   &SetCookies('cart',$cartid);
 }
# if (not &GetCookies('cart')) {
#    $cartid = "nocookies";
# }


#####################################################

print "Content-type:text/html\n\n";

$flag = 0;
@values = split(/&/,$ENV{'QUERY_STRING'});
          foreach $i (@values) {
            ($varname, $mydata) = split(/=/,$i);
             if ($varname eq "did") {
		$flag = 1;
		$deptid = $mydata;
             }
             if ($varname eq "start") {
		$start = $mydata;
             }
	  }

open(FILE, "data.dat") || die &error_file;
 while(<FILE>) {
  chomp;		
  @datafile = split(/\n/);
  foreach $line (@datafile) {
   next if /#.*/;
   ($depart, $prodid, $prodtitle, $proddetail, $prodprice, $prodimage, $prodthumb, $s1, $s2, $s3, $t1, $wsprice, $wsunit, $wsmin, $rtla, $wsa, $prodbrief) = split(/::/,  $line);
    if ($deptid eq $depart && $rtla eq "1") {
    push(@pdp,$depart);
    push(@pid,$prodid);
    push(@ptl,$prodtitle);
    push(@pdt,$proddetail);
    push(@ppr,$prodprice);
    push(@pim,$prodimage);
    push(@ptm,$prodthumb);
    push(@wsu,$wsunit);
    push(@wsm,$wsmin);
    push(@pbf,$prodbrief);
    }
   }
  }
close(FILE);

$noofitems = scalar(@pdp);
$noofpages = 1 + int($noofitems/10);

if (int($noofitems / 10) == $noofitems / 10) {
  $noofpages = $noofpages - 1;
}

if (int($start / 10) != $start / 10) {
  $start = 0;
}

if ($start > $noofitems) {
  $start = 0;
}
$htmltitle = "CHARM IT! - Charms, Charm Jewelry, Charm Accessories, Disney Charms, Hello Kitty Charms - The Princess Store";

   if ($pdp[0] eq "charmitdc") {
        $htmltitle = "CHARM IT! Disney Charms - Charm It - The Princess Store";
   }
   if ($pdp[0] eq "charmithc") {
        $htmltitle = "CHARM IT! Hello Kitty Charms - Charm It - The Princess Store";
   }

   if ($pdp[0] eq "") {
    &error_file();
    }

$max = $#pdp;



print <<EndOfHTML;


<HTML>
<HEAD>

<TITLE>$htmltitle</TITLE>
<META NAME="description" 
content="$htmltitle - Come to The Princess Store for your fairy princess needs!">
<META NAME="keywords" 
content="fairy, princess, rosette, headband, $pdp[0], $htmltitle">

<LINK HREF="http://www.theprincessstore.com/images/css.css" REL="stylesheet" TYPE="text/css">
<SCRIPT language="JavaScript">
<!--

var message="(C) The Princess Store - All Rights Reserved."
function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
// --> 
</SCRIPT>
</HEAD>

<BODY topmargin="0"         bottommargin="0" 
      leftmargin="0"        rightmargin="0" 
      marginwidth="0"       marginheight="0">


<!---------- Top Nav ------------>


<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR>
<TD BGCOLOR="#ff99cc">
<A HREF="http://www.theprincessstore.com/">
<IMG SRC="http://www.theprincessstore.com/images/website/navlogo.gif" BORDER=0
ALT="The Princess Store"></A></td>
<TD BGCOLOR="#ff99cc">
<DIV ALIGN=right>
<IMG SRC="http://www.theprincessstore.com/images/website/navright.gif" BORDER=0 USEMAP="#NavRight" ISMAP></DIV></TD>
</TR>
</TABLE>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BACKGROUND="http://www.theprincessstore.com/images/website/shade.gif">&nbsp;</TD></TR></TABLE>


<!-- Image Map -->
<map name="NavRight"><area shape="rect" coords="168,60,340,78" href="http://www.theprincessstore.com/cgi-bin/cart/smart.cgi?command=review" title="View Your Cart" alt="View Your Cart"><area shape="rect" coords="227,14,281,37" href="http://www.theprincessstore.com/about/help/index.html" title="Help and Support" alt="Help and Support"><area shape="rect" coords="133,13,203,37" href="http://www.theprincessstore.com/about/contactform.html" title="Contact Information" alt="Contact Information"><area shape="rect" coords="39,13,108,37" href="http://www.theprincessstore.com/about/index.html" title="About The Princess Store" alt="About The Princess Store"></map>

<!----- //////// End Top Nav //////---->

<DIV ALIGN=center><BR>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=740>
<TR>
<TD WIDTH=10><BR></TD>




<!---------- Left Col (Search and Department Links) ------------------>

<TD WIDTH=200 VALIGN="top">
<DIV ALIGN=center>

<!--Search Box-->
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=200>
<TR>
 <TD WIDTH=10><IMG HEIGHT=17 WIDTH=10
    SRC="http://www.theprincessstore.com/images/website/tableleft.gif"></TD>
 <TD WIDTH=180 BGCOLOR="#9999cc"><BR></TD>
 <TD WIDTH=10><IMG HEIGHT=17 WIDTH=10
    SRC="http://www.theprincessstore.com/images/website/tableright.gif"></TD>
</TR>
</TABLE>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=200 BGCOLOR="#ff99cc">
<TR>
<TD HEIGHT=95>
  <FORM NAME="Search" ACTION="http://www.theprincessstore.com/cgi-bin/search.pl">
  <INPUT TYPE="hidden" VALUE="14d951d66b545178" NAME="crid">
  <DIV ALIGN=center>
  <IMG SRC="http://www.theprincessstore.com/images/website/tablesearch.gif" ALT="Search"></DIV>
  <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=180>
  <TR>
  <TD VALIGN=top width=115>
   <DIV ALIGN="right" class="smaller">
   <INPUT NAME="query" SIZE="10">&nbsp;</DIV></TD>
  <TD VALIGN=TOP WIDTH=65><INPUT 
      SRC="http://www.theprincessstore.com/images/website/butminisearch.gif" 
      BORDER=0 NAME="Search" TYPE="image"></TD>
  </TR>
  </TABLE>
  </FORM>
</TD>
</TR>
<TR><TD><IMG HEIGHT=16 WIDTH=200  SRC="http://www.theprincessstore.com/images/website/shade.gif"></TD></TR>
</TABLE><BR>

<!--Department Links-->
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=200>
<TR>
 <TD WIDTH=10><IMG HEIGHT=17 WIDTH=10
    SRC="http://www.theprincessstore.com/images/website/tableleft.gif"></TD>
 <TD WIDTH=180 BGCOLOR="#9999cc"><BR></TD>
 <TD WIDTH=10><IMG HEIGHT=17 WIDTH=10
    SRC="http://www.theprincessstore.com/images/website/tableright.gif"></TD>
</TR>
</TABLE>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=200 BGCOLOR="#ff99cc">
<TR>
 <TD>
 <DIV ALIGN=center>
 <BR>

EndOfHTML

open (LEFTNAV,"leftnav.dat") || print "Could not open file \n";
while (<LEFTNAV>) {
print $_;
	}
close(LEFTNAV);	

print <<EndOfHTML;

 <BR>
 </DIV></TD>
</TR>
<TR><TD><IMG HEIGHT=16 WIDTH=200  SRC="http://www.theprincessstore.com/images/website/shade.gif"></TD></TR>
</TABLE>

<!--Other Left Col Items-->
<BR>
<A HREF="http://www.theprincessstore.com/wholesale/index.html">
<IMG SRC="http://www.theprincessstore.com/images/website/button/wholesale.gif" 
 ALT="Wholesale Resellers" BORDER=0></A><BR><BR>
</DIV></TD>

<!----- //////// End Left Col //////---->

<!--Gutter-->
<TD WIDTH=10><BR></TD>





<!-------- Main Col -------------------------->


<TD VALIGN=top WIDTH=520>
<DIV ALIGN=center>

<!--Section Title Area-->
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=520>
<TR>
 <TD WIDTH=10><IMG HEIGHT=17 WIDTH=10
    SRC="http://www.theprincessstore.com/images/website/tableleft.gif"></TD>
 <TD WIDTH=500 BGCOLOR="#9999cc"><BR></TD>
 <TD WIDTH=10><IMG HEIGHT=17 WIDTH=10
    SRC="http://www.theprincessstore.com/images/website/tableright.gif"></TD>
</TR>
</TABLE>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=520 BGCOLOR="#ff99cc">
<TR>
<TD HEIGHT=95>
 <DIV ALIGN=center>

 <!--- ############### S E C T I O N   T I T L E ############ --->
 <IMG SRC="http://www.theprincessstore.com/images/website/titles/$pdp[0].gif"></DIV></TD>

</TR>
<TR><TD><IMG HEIGHT=16 WIDTH=520 
SRC="http://www.theprincessstore.com/images/website/shade.gif"></TD></TR>
</TABLE>
<BR>


<!----- ###### I T E M   D A T A   A R E A ####### --------------->

<DIV ALIGN=center CLASS=smaller>
<SMALL><A HREF="http://www.theprincessstore.com/">Home</A> - <A HREF="http://www.theprincessstore.com/charmit/">CHARM IT!</A> - <I>CHARM IT! Charms & Accessories</I><BR><BR></SMALL>

<TABLE BORDER=0 CELLPADDING=8 CELLSPACING=0 WIDTH=520>
<TR><TD WIDTH=132 VALIGN=top>
<IMG SRC="http://www.theprincessstore.com/images/products/charmit/logo.jpg" border="0">
<SPAN CLASS=small>
</TD><TD WIDTH=368 CLASS=smaller ALIGN=center VALIGN=top>
CHARM IT! is the original, interchangeable, charm jewelry and accessory system made just for girls! We have a huge selection of CHARM IT! charm jewelry and charmable accessories in all themes and styles that represent you! CHARM IT! offers so many jewelry possibilities. Free domestic shipping is available when you buy \$30 or more*.<BR><BR>
</DIV>
</TD></TR></TABLE>

<IMG SRC="/images/website/hr.gif" HEIGHT=1 WIDTH=520><BR><BR>
</DIV>
EndOfHTML







$iii = $start;
$number = 1;
while($iii <= $max && $number <= 10) {

print "<!--Items $iii+1 and $iii+2 ---->\n";
print "<table border=\"0\" cellpadding=\"9\" cellspacing=\"2\" width=\"480\">\n";
print "<tr><td width=240 valign=top ALIGN=center>\n";
print "<a href=\"item_detail.cgi?pid=$pid[$iii]\"><FONT COLOR=black><span class=header>$ptl[$iii]<br></span></FONT></a>\n";
$ptl[$iii] =~ s/<([^img][^>]+)>/ /g;
print "<a href=\"item_detail.cgi?pid=$pid[$iii]\"><img src=\"../images/products/$ptm[$iii]\"  border=0 alt=\"$ptl[$iii]\"></a>\n";
print "</td>\n";

if ($ptm[$iii+1] eq "") {
  print "<TD><BR>\n";
} else {

print "<td width=240 valign=top ALIGN=center>\n";
print "<a href=\"item_detail.cgi?pid=$pid[$iii+1]\"><FONT COLOR=black><span class=header>$ptl[$iii+1]<br></span></FONT></a>\n";
$ptl[$iii+1] =~ s/<([^img][^>]+)>/ /g;
print "<a href=\"item_detail.cgi?pid=$pid[$iii+1]\"><img   src=\"../images/products/$ptm[$iii+1]\" border=0 alt=\"$ptl[$iii+1]\"></a>\n";

}

print "</td>\n";
print "</tr>\n";
print "\n";
print "<tr>\n";
print "<td width=240 ALIGN=center VALIGN=top>\n";
print "<span class=smaller>$pbf[$iii]<br><BR></span>\n";
print "<span class=smaller>\$$ppr[$iii]</span><br>\n";
print "<span class=smaller>Item# $pid[$iii]<br><br></span>\n";
print "<a href=\"http://www.theprincessstore.com/cgi-bin/add.pl?pid=$pid[$iii]&q=$cartid\"><img  src=\"../images/website/button/addtocart.gif\" border=0 alt=\"Add To Cart\"></a>&nbsp;\n";
print "<A HREF=\"item_detail.cgi?pid=$pid[$iii]\"><IMG SRC=\"../images/website/button/moreinfo.gif\" WIDTH=84 HEIGHT=26 BORDER=0 ALT=\"More Info...\"></A><BR>\n";
print "</td>\n";

if ($ptm[$iii+1] eq "") {
  print "<TD><BR>\n";
} else {

print "<td width=240 ALIGN=center VALIGN=top>\n";
print "<span class=smaller>$pbf[$iii+1]<br><BR></span>\n";
print "<span class=smaller>\$$ppr[$iii+1]</span><br>\n";
print "<span class=smaller>Item# $pid[$iii+1]<br><br></span>\n";
print "<a href=\"http://www.theprincessstore.com/cgi-bin/add.pl?pid=$pid[$iii+1]&q=$cartid\"><img height=26 width=84 src=\"../images/website/button/addtocart.gif\" border=0 alt=\"Add To Cart\"></a>&nbsp;\n";
print "<A HREF=\"item_detail.cgi?pid=$pid[$iii+1]\"><IMG SRC=\"../images/website/button/moreinfo.gif\" WIDTH=84 HEIGHT=26 BORDER=0 ALT=\"More Info...\"></A><BR>\n";

}

print "</td></tr></table><br><br>\n";

$iii = $iii + 2;
$number = $number + 2;
}	


print "<IMG SRC=\"/images/website/hr.gif\" HEIGHT=1 WIDTH=520><BR><BR>\n";
$firstitem = $start+1;
$lastitem = $start+10;
if ($lastitem > $noofitems) {
  $lastitem = $noofitems;
}
print "<SMALL>Items $firstitem - $lastitem of $noofitems Items Found</SMALL><BR>\n";

if ($noofitems > 10){


if ($start >= 10){
 $prevpage = $start - 10;
 if ($prevpage == 0) {
     print "<A HREF=\"charmit.pl\?did=$pdp[0]\">\&lt;- <B>Previous</B></A> \n";
 }
 if ($prevpage != 0) {
     print "<A HREF=\"charmit.pl\?did=$pdp[0]\&start=$prevpage\">\&lt;- <B>Previous</B></A> \n";
 }
}

$iii = 0;
while($iii <= $noofpages-1) {
     $thispage = $iii*10;
     $printpage = $iii + 1;
     if ($thispage != $start && $thispage == 0) {
         print "- <A HREF=\"charmit.pl\?did=$pdp[0]\"><B>$printpage</B></A> \n";
     }
     if ($thispage != $start && $thispage != 0) {
          print "- <A HREF=\"charmit.pl\?did=$pdp[0]\&start=$thispage\"><B>$printpage</B></A> \n";
     }
     if ($thispage == $start && $thispage != 0) {
          print "- $printpage \n";
     }
     if ($thispage == $start && $thispage == 0) {
          print "$printpage \n";
     }

     $iii = $iii + 1;
}

if ($start+10 < $noofpages*10){
 $nextpage = $start + 10;
     print "- <A HREF=\"charmit.pl\?did=$pdp[0]\&start=$nextpage\"><B>Next</B> -\&gt;</A> \n";
}


}

print "<BR><BR><IMG SRC=\"/images/website/hr.gif\" HEIGHT=1 WIDTH=520><BR><BR>\n";

print <<EndOfHTML;







 

<!------ //////// END MAIN COL AREA ///////// -------->

<BR><BR></DIV></TD>
</TR>
</TABLE>


<!----------- Footer -------------->
<DIV ALIGN=center>
EndOfHTML

open (BOTTOMNAV,"bottomnav.dat") || print "Could not open file \n";
while (<BOTTOMNAV>) {
print $_;
	}
close(BOTTOMNAV);	

print <<EndOfHTML;
<br>

<span class="smaller">&copy; 2000-2011 The Princess Store - <a href="http://www.theprincessstore.com/about/tos.html" title="Click here for more information on the copyright.">All Rights Reserved</a><br>

<br>*All CHARM IT! Disney and CHARM IT! Sanrio merchandise can only be<BR>
shipped within the United States. All promotional discounts are available<BR>
for new orders only and cannot be applied to previously placed orders.<BR>
Free shipping offer is for limited time only. </span></center><br><br>

</BODY>
</HTML>

EndOfHTML

sub error_file {
	print <<END_of_html;
<HTML>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://www.theprincessstore.com/">
<title>Please Wait...</title>
<style type="text/css"><!--
<!--a:link { text-decoration: none }
a:hover { color: #ff0000; text-decoration: underline }
a:visited { text-decoration: none }
a:visited:hover { color: #ff0000; text-decoration: underline }-->
</style>
</head>

<body bgcolor="white" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0" link="#003399" vlink="#003399" alink="red">

<center>
<font size="4" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><br>
<br>
<br>
<br>
L O A D I N G<br>
<br>
</b></font><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">If this page does not refresh automaticly, <a href="http://www.theprincessstore.com/"><b>click here</b></a>.</font></center>
</body>

</HTML>
END_of_html
exit;
}

