function undo()
{
	window.history.back();
}

function checkAll(theForm,x) 
	{ 	
		var name = x.name;
				
  		for (var i=0;i<theForm.elements.length;i++) 
  		{
	  	  var e = theForm.elements[i];
			var eName = e.name;	
				
    		if ((e.type == "checkbox") && eName.indexOf(name)==0) 
			{
				e.checked = document.getElementById(name).checked;			
			}
		} 
	}
function checkAllBox(theForm) 
	{ 							
  		for (var i=0;i<theForm.elements.length;i++) 
  		{
	  	  var e = theForm.elements[i];			
				
    		if ((e.type == "checkbox")) 
			{
				e.checked = theForm.checkAll.checked;			
			}
		} 
	}
function clearBox(theForm) 
	{ 	
		var value = theForm.pName.value;
				
  		if(value == "Enter Keyword")
  		{
  			theForm.pName.value = "";
  			theForm.pName.focus();
  		}else if(value == "")
  		{
  			theForm.pName.value = "Enter Keyword";  			
  		}
  		 
	}
function resizeImages(width)
{

   maxSize = width;

   for (x=0;x<document.images.length;x++)
   {  
  
	if(document.images[x].name == "item")
	{
      iHeight = document.images[x].height;
      iWidth = document.images[x].width;

      if (iHeight > iWidth){
         sizeGuide = iHeight;
         size2 = iWidth;
      }else{
         sizeGuide = iWidth;
         size2 = iHeight;
      }


      if (sizeGuide > maxSize){

         sizeRatio = sizeGuide / size2;
         newSize1 = maxSize;
         newSize2 = newSize1 / sizeRatio;

         if (iHeight > iWidth){
            document.images[x].height = newSize1;
            document.images[x].width = newSize2;
         }else{
            document.images[x].width = newSize1;
            document.images[x].height = newSize2;
         }

      }
      
	}
   }

 }
 
function resizeImage(img,width)
{

	var oh = parseFloat(img.height,0);
	var ow = parseFloat(img.width,0);

	var fh;
	var fw;
	var a;
		a = parseFloat(ow,0) / parseFloat(oh,0);
	if(parseFloat(oh,0)>parseFloat(ow,0))
	{
		fh = parseFloat(width,0);
		fw = parseFloat(a,0) * parseFloat(fh,0);	
	} else
	{
		fw = parseFloat(width,0);	
		fh = (parseFloat(fw,0) / parseFloat(a,0));		
	}	
		img.height = parseInt(fh);
		img.width = parseInt(fw);

}
	
function openChangePWWindow()
{
	window.open("AccountSettingsController?root=pwchangewin","newWindow","height=200,width=400");
}

function addToPartyWindow(prodId)
{
	window.open("AddtoPartyController?root=pwchangewin&prodId="+prodId,"newWindow","height=200,width=300");
}
function addPhotoWindow(albumId)
{
	window.open("PhotoAlbumController?root=openAddPhoto&albumId="+albumId,"newWindow","height=200,width=450");
}
function openWindow(ref)
{
	window.open(ref,"newWindow","height=200,width=450");
}
function addMenu(partyId)
{
	window.open("MenuController?root=add&partyId="+partyId,"newWindow","height=300,width=600,scrollbars=1");
}
function addItem(catId,partyId)
{
	window.open("BudgetController?root=add&catId="+catId+"&partyId="+partyId,"newWindow","height=200,width=500,scrollbars=1");
}
function editItem(budgetId)
{
	window.open("BudgetController?root=edit&budgetId="+budgetId,"newWindow","height=250,width=500,scrollbars=1");
}

function inviteFriendToParty(partyId)
{
	window.open("PartyGuestListController?root=invFrndsPage&partyId="+partyId,"newWindow","height=500,width=600,scrollbars=1,status=yes");
}

function inviteContactsToParty(partyId)
{
	window.open("PartyGuestListController?root=invCntsPage&partyId="+partyId,"newWindow","height=500,width=600,scrollbars=1,status=yes");
}

function openPrivacy()
{
	window.open("HowItWorks?root=privacyPolicy","privacyWindow","scrollbars=1,status=yes");
}

function openContacts()
{
	window.open("HowItWorks?root=CntsPage","newWindow","height=500,width=600,scrollbars=1,status=yes");
}

function submitPage(theForm)
{	

	theForm.action = "ProductDisplayController";
	theForm.method = "post";
	theForm.submit();
}