 var isPaginationPage = false;

 function fireSorts()
 {
  if(isPaginationPage)
  {
   createPriceSort();
   createNameSort();

   // check for cookie that saves last view of page.
   var prevSort = getCookie(sortViewId);  

   if(prevSort==3)
   { 	sortPrice();	}
   else if(prevSort==2)
   { 	sortName(); 	}
   
   var thisPage = getCookie(pageViewId);

   if(thisPage)
   {
    if(thisPage == "ALL")
    { goToPage(1);
      setTimeout("viewAll();",1200); }
    else
    { goToPage(thisPage); }
   }
  }
 }

 function emailPage()
 {
 }

 function largeView(imageURL)
 {
   var imgPop = window.open(imageURL,'imgPop','menubar=no,scrollbars=no,width=550,height=550');  
   imgPop.focus();
 }

function writeReview(itemID,itemImage,itemName)
{
	eval("var reviewpopup = window.open('http://storeapps.net/reviews/premiumpet/write.php?ID="+itemID+"&itemImage="+itemImage+"&itemName="+itemName+"','review_popup','menubar=no,scrollbars=0,width=450,height=560')");
	reviewpopup.focus();
}

var prevMenu = '';
var prevMenuHeader = '';
function showDropdownMenu(divID)
{
 if(prevMenu!=divID)
 {
  if(prevMenu)
  {
   document.getElementById(prevMenu).style.display='none';
   document.getElementById(prevMenuHeader).className = '';
  }
 }
 if(divID)
 {
  document.getElementById(divID).style.display = 'inline';
  prevMenuHeader = divID + "header";
  document.getElementById(prevMenuHeader).className = 'selectedMenu';
 }
 prevMenu = divID;
}

function showme(pageurl){
	window.open(pageurl,"showmewin","toolbars=no,scrollbars=yes,status=yes,height=550,width=550,top=100,left=100");
}
function submittocart(){
	var selectelems = document.getElementById("select");
	for(i=0;i<selectelems.length;i++){
		if(selectelems[i].selectedIndex == 0){
			alert("Please Select a options");
			selectelems[i].focus;
			return false;
		}
	}
}

function loadRandomImages(holderID)
{
 var imgObjs = document.getElementById(holderID).getElementsByTagName("img");
 var x =0;
 while(imgObjs[x])
 { 
  var imgList = imgObjs[x].src + '';
  var aryImgList = imgList.split("?"); 
  var aryL = aryImgList.length;
  aryL--;  
  var ran_unrounded=Math.random()*aryL;
  var ran_number=Math.floor(ran_unrounded); 
  imgObjs[x].src = aryImgList[ran_number];
  x++;
 }
}

function addToWishlist(pageID,pageName,imgLoc)
{
 pageName = pageName.replace("&","and");
 var strLocation = "http://www.fastpivotsoftware.com/legacy/"+
                   "wishlist/v2/addlist.php?"+
		   "storeID=yhst-90697721009690&"+
		   "pageID="+pageID+"&pageName="+
		   pageName+"&imgLoc="+imgLoc;
 var WLpopup = window.open(strLocation,"WLpopup","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,width=305,height=540");
 WLpopup.focus();
}


var oldMenu = "ln0";
var Gobj = ''; var Gend = ''; var Gx = '';
var Sobj = ''; var Send = ''; var Sx = '';
var GMobj = ''; var GMend = ''; var GMx = '';
var SMobj = ''; var SMend = ''; var SMx = '';
var resetTo = 0;
var thisObj = '';
var oldImgDiv = '';

 function expandView(divID)
 {
   if(!oldImgDiv)
   { oldImgDiv = document.getElementById('div-image'); }
   oldImgDiv.style.display = 'none';
   oldImgDiv = document.getElementById(divID); 
   oldImgDiv.style.display = 'inline';
 }

 function popView()
 {
  var popHTML = document.getElementById('divImgPopup').innerHTML;
  var IMGpopup = window.open('','IMGpopup','width=960,height=650,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no');
  IMGpopup.document.open();
  IMGpopup.document.write("<ht"+"ml><he"+"ad><tit"+"le>Image Zoom<\/ti"+"tle><META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"><META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\"><\/he"+"ad>");
  IMGpopup.document.write("<bo"+"dy bgcolor='#FFFFFF' text='#000000' leftmargin=2 topmargin=10>");
  IMGpopup.document.write("<\/body><\/html>");
  IMGpopup.document.write(popHTML);
  IMGpopup.document.focus();
 }

 function resetMenus()
 {
  var y = 0;
  thisObj = "ln_img" + y;
  while(document.getElementById(thisObj))
  {
   if(y!=resetTo)
   {document.getElementById(thisObj).style.height = "1px";}
   y++;
   thisObj = "ln_img" + y;
  }

  y = 0;
  thisObj = "ln" + y;
  while(document.getElementById(thisObj))
  {
   if(y!=resetTo)
   {document.getElementById(thisObj).style.height = "100px";}
   y++;
   thisObj = "ln" + y;
  }

  y = 0;
  thisObj = "ln_more" + y;
  while(document.getElementById(thisObj))
  {
   if(y!=resetTo)
   {document.getElementById(thisObj).style.display="inline";}
   else
   {document.getElementById(thisObj).style.display="none";}
   y++;
   thisObj = "ln_more" + y;
  }
 }

 function growObj()
 {
  Gx = Gx + 15;
  if(Gx<=Gend)
  {  Gobj.style.height = Gx+"px";
     setTimeout("growObj()",10);  }
  else { Gobj.style.height = Gend+"px"; }
 }
 function growMenuObj()
 {
  GMx = GMx + 15;
  if(GMx<=GMend)
  {  GMobj.style.height = GMx+"px";
     setTimeout("growMenuObj()",10);  }
  else { GMobj.style.height = GMend+"px";
         resetMenus();  }
 }
 function shrinkObj()
 {
  Sx = Sx - 15;
  if(Sx > Send)
  {  Sobj.style.height = Sx+"px";
     setTimeout("shrinkObj()",10);  }
  else { Sobj.style.height = Send+"px"; }
 }
 function shrinkMenuObj()
 {
  SMx = SMx - 15;
  if(SMx > SMend)
  {  SMobj.style.height = SMx+"px";
     setTimeout("shrinkMenuObj()",10);  }
  else { SMobj.style.height = SMend+"px"; }
 }

 function showMenu(x,h)
 {
  var newMenu = "ln" + x;
  if(newMenu!=oldMenu)
  {
   var objNew = document.getElementById(newMenu);
   var objOld = document.getElementById(oldMenu);
   objNew.className = "ln_menu_main";
   objOld.className = "ln_menu";
   var newImg = "ln_img"+x;
   Gobj = document.getElementById(newImg);
   Gend = 135; Gx = 1;
   growObj();

   GMobj = document.getElementById(newMenu);
   GMend = menuHs[x]; GMx = 100;
   growMenuObj();

   var oldImg = oldMenu.replace("ln","ln_img");
   Sobj = document.getElementById(oldImg);
   Send = 1; Sx = 135;
   shrinkObj();

   SMobj = document.getElementById(oldMenu);
   var o = oldMenu.replace("ln","");
   SMend = 100; SMx = menuHs[o];
   shrinkMenuObj();
   
   if(document.getElementById("ln_more"+x))
   { document.getElementById("ln_more"+x).style.display = "none"; }

   resetTo = x;
   oldMenu = newMenu;
  }
 }

function savePage()
   {
      var browsername = navigator.appName; 
      if(browsername=="Microsoft Internet Explorer")
      {  window.external.AddFavorite(window.location,document.title);  }
      else
      {  alert ("Please press CONTROL + 'D' on your keyboard to bookmark this page!");  }
  }
