//********************************************************************************************
// utils.js
//
//		JavaScript File containing general methods for the presentation aspect of the site.
//
// Revision History   
//		Paul   12/14/2001      Original Version
//
//
//********************************************************************************************

var M_S_IT_LOGO = "logo";
var M_S_IT_ARTIST = "artist";
var M_S_IT_ARTWORK = "artwork";
var M_S_IT_LICENSEE = "licensee";
var M_S_IT_ARTWORK_THUMBNAIL = "thumbnail"
var M_S_IT_NEWSLETTER = "newsletter";


//********************************************************************************************
// Method:	ShowImages
// Author:	Paul Rausch
// Date:	12/15/2001
//********************************************************************************************
function ShowImagesByCategory(sid)
{
	
	var oFrm;
	
	oFrm = document.frm;
	
	
	if(oFrm.lstCategory[oFrm.lstCategory.selectedIndex].value==0)
	{
		alert("Please select a theme.");
	}
	else
	{
		window.location.href='../artwork/display.asp?sid=' + sid + '&cid=' + oFrm.lstCategory[oFrm.lstCategory.selectedIndex].value;
	}
	
}


//********************************************************************************************
// Method:	ShowImages
// Author:	Paul Rausch
// Date:	12/15/2001
//********************************************************************************************
function ShowImagesByCategoryNav(sid)
{
	
	var oFrm;
	
	oFrm = document.artwork;
	
	
	if(oFrm.lstCategory[oFrm.lstCategory.selectedIndex].value==0)
	{
		alert("Please select a theme.");
	}
	else
	{
		window.location.href='display.asp?sid=' + sid + '&cid=' + oFrm.lstCategory[oFrm.lstCategory.selectedIndex].value;
	}
	
}


//********************************************************************************************
// Method:	ShowImagesByArtistCategoryNav
// Author:	Paul Rausch
// Date:	12/15/2001
//********************************************************************************************
function ShowImagesByArtistCategoryNav(iArtistID,sid)
{
	
	var oFrm;
	
	oFrm = document.artwork;
	
	
	if(oFrm.lstCategory[oFrm.lstCategory.selectedIndex].value==0)
	{
		alert("Please select a theme.");
	}
	else if(oFrm.lstCategory[oFrm.lstCategory.selectedIndex].value=='nr')
	{
		window.location.href='../artwork/displaybyartist.asp?sid=' + sid + '&arstid=' + iArtistID + '&nr=1';
	}
	else
	{
		window.location.href='../artwork/displaybyartist.asp?sid=' + sid + '&arstid=' + iArtistID + '&cid=' + oFrm.lstCategory[oFrm.lstCategory.selectedIndex].value;
	}
	
}

//********************************************************************************************
// Method:	ShowCategoryArtistsNav
// Author:	Nathan Smith
// Date:	5/31/2002
//********************************************************************************************
function ShowCategoryArtistsNav(sid, cid)
{
	
	var oFrm;
	var iArtistID;
	oFrm = document.artwork;
	iArtistID = oFrm.lstArtist.value
	
	
	if(oFrm.lstArtist[oFrm.lstArtist.selectedIndex].value==0)
	{
		alert("Please select an Artist.");
	}
	else if(oFrm.lstArtist[oFrm.lstArtist.selectedIndex].value=='nr')
	{
		window.location.href='../artwork/displaybyartist.asp?sid=' + sid + '&arstid=' + iArtistID + '&nr=1';
	}
	else
	{
		window.location.href='../artwork/displaybyartist.asp?sid=' + sid + '&arstid=' + iArtistID + '&cid=' + cid;
	}
	
}

//********************************************************************************************
// Method:	ListImagesPerPgNav
// Author:	Gary Anderson
// Date:	07/19/2004
//********************************************************************************************
function ListImagesPerPgNav(sid, cid, iArtistID)
{
	
	var oFrm;
	var iImgPgID;
	oFrm = document.viewimages;
	iImgPgID = oFrm.lstImgPerPg.value
	
	
	if(oFrm.lstImgPerPg[oFrm.lstImgPerPg.selectedIndex].value==0)
	{
		alert("Please select a page number.");
	}
	else if(oFrm.lstImgPerPg[oFrm.lstImgPerPg.selectedIndex].value=='nr')
	{
		window.location.href='../artwork/displaybyartist.asp?sid=' + sid + '&arstid=' + iArtistID + '&nr=1';
	}
	else
	{
		window.location.href='../artwork/displaybyartist.asp?sid=' + sid + '&arstid=' + iArtistID + '&cid=' + cid + '&ipp=' + iImgPgID;
	}
	
}
//********************************************************************************************
// Method:	ListKeywordImagesPerPgNav
// Author:	Mario Zappa
// Date:	2/1/2008
//********************************************************************************************
function ListKeywordImagesPerPgNav(sid, key, iArtistID, all)
{
	
	var oFrm;
	var iImgPgID;
	oFrm = document.viewimages;
	iImgPgID = oFrm.lstImgPerPg.value
	
	
	if(oFrm.lstImgPerPg[oFrm.lstImgPerPg.selectedIndex].value==0)
	{
		alert("Please select a page number.");
	}
	else if(oFrm.lstImgPerPg[oFrm.lstImgPerPg.selectedIndex].value=='nr')
	{
		window.location.href='../artwork/display_search.asp?sid=' + sid + '&arstid=' + iArtistID + '&nr=1&all=' + all;
	}
	else
	{
		window.location.href='../artwork/display_search.asp?sid=' + sid + '&arstid=' + iArtistID + '&key=' + key + '&ipp=' + iImgPgID + '&all=' + all;
	}
	
}

//********************************************************************************************
// Method:	ShowCategoryArtistsNav
// Author:	Nathan Smith
// Date:	5/31/2002
//********************************************************************************************
function ShowCollectionsNav()
{
	
	var oFrm;
	var iArtistID;
	var iCollectionID;
	
	oFrm = document.collection;
	iArtistID = oFrm.lstArtist.value
	iCollectionID = oFrm.lstCollection.value
	
	
	if(oFrm.lstCollection[oFrm.lstCollection.selectedIndex].value==0)
	{
		alert("Please select a Collection.");
	}
	else if(oFrm.lstCollection[oFrm.lstCollection.selectedIndex].value=='nr')
	{
		window.location.href='../artists/displaycollection.asp?cid=' + iCollectionID + '&arstid=' + iArtistID + 'nr=1';
	}
	else
	{
		window.location.href='../artists/displaycollection.asp?cid=' + iCollectionID + '&arstid=' + iArtistID;
	}
	
}

//********************************************************************************************
// Method:	SetPaging
// Author:	Paul Rausch
// Date:	12/15/2001
//********************************************************************************************
function SetPaging(lPageNum)
{
	
	var oFrm;
	
	oFrm = document.frm;
	
	oFrm.hdnCurrentPage.value = lPageNum;
	oFrm.submit();
}

//********************************************************************************************
// Method:	DeleteBasketItem
// Author:	Paul Rausch
// Date:	12/15/2001
//********************************************************************************************
function DeleteBasketItem(lBasketItemID)
{
	
	var oFrm;
	
	oFrm = document.frm;
	
	oFrm.hdnBasketItemID.value = lBasketItemID;
	oFrm.submit();
}


//********************************************************************************************
// Method:	SubmitForm
// Author:	Paul Rausch
// Date:	12/15/2001
//********************************************************************************************
function SubmitForm(sAction)
{
	
	var oFrm;
	var sMsg="";
	
	oFrm = document.frm;

	if(oFrm.FirstName.value=="")
	{
		sMsg = sMsg + "Please enter a first name.\r\n";
	}	
	if(oFrm.LastName.value=="")
	{
		sMsg = sMsg + "Please enter a last name.\r\n";
	}	
	if(oFrm.Email.value=="")
	{
		sMsg = sMsg + "Please enter an email address.\r\n";
	}	
	if(oFrm.CompanyName.value=="")
	{
		sMsg = sMsg + "Please enter a company name.\r\n";
	}	
	if(oFrm.Phone.value=="")
	{
		sMsg = sMsg + "Please enter a phone number.\r\n";
	}	
	if(oFrm.Address.value=="")
	{
		sMsg = sMsg + "Please enter an address.\r\n";
	}	
	
	if(sMsg=="")
	{
		oFrm.hdnAction.value = sAction;
		oFrm.submit();
	}
	else
	{
		alert(sMsg);
	}
}

//********************************************************************************************
// Method:	openWindow
// Author:	Kris Nyreen
// Date:	6/29/2002
//********************************************************************************************
var win1='';
	var blnOpen = false;

	//function to open new window
	function openWindow(sURL)
	{
		closeWindow();
		blnOpen=true;
		win1 = open(sURL, 'NewWindow', "width=550,height=500,scrollbars=yes,resizable=yes,toolbar=no,left=312,top=0");
	}
	//function to close window
	function closeWindow()
	{
		if ((blnOpen==true) && (!win1.closed))
			{
			win1.close();	
			}
		blnOpen=false;
	}
