var ListingsCount = 0;

function TaskPopup(Path, ReceiptID)
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 650, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Path + 'Admin/Popups/TaskPopup.aspx?ReceiptID=' + ReceiptID, 'TaskPopup', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}

function FlyerDetailTracking(Path, AgentFlyerGUID)
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 650, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Path + '/Admin/Popups/FlyerDetailTracking.aspx?AgentFlyerGUID=' + AgentFlyerGUID, 'FlyerDetailTracking', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}


function InvoiceDetail(InvoiceNo)
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 650, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open('/GothamPhotoCompany_ClientAccess/Popups/Payments/InvoiceDetail.aspx?InvoiceNo=' + InvoiceNo, 'InvoiceDetail', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}

function TemplateImagesPicker(AgentFlyerGUID, FieldName, FieldExtraData)
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 650, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open('/GothamPhotoCompany_ClientAccess/Popups/Wizards/Flyer/ImageManager.aspx?AgentFlyerGUID=' + AgentFlyerGUID + '&FieldName=' + FieldName + '&' + FieldExtraData, 'TemplateImagesPicker', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}

function MMSponsorImagesPicker()
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 650, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open('/GothamPhotoCompany_ClientAccess/Popups/Wizards/Flyer/MMSponsorImagesPicker.htm', 'MMImagesPicker', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}


function FlyerCreditUpdate(Path, TemplateOutgoingMailID)
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 600, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Path + '/Admin/Popups/FlyerCreditUpdate.aspx?TemplateOutgoingMailID=' + TemplateOutgoingMailID, 'FlyerCreditUpdate', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}

function PDFFlyer(Path, GUID)
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 600, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Path + '/Popups/Wizards/Flyer/GeneratePDF.aspx?GUID=' + GUID, 'PDFFlyer', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}

function ReSendFlyer(Path, GUID)
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 600, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Path + '/Popups/Wizards/Flyer/ReSend.aspx?GUID=' + GUID, 'ReSendFlyer', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}

function CreateNewFromFlyer(Path, GUID)
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 600, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Path + '/Popups/Wizards/Flyer/ReSend.aspx?CreateNewFrom=1&GUID=' + GUID, 'ReSendFlyer', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}	

function ReSendNoEditFlyer(Path, GUID)
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 600, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Path + '/Popups/Wizards/Flyer/ReSend.aspx?NoEdit=1&GUID=' + GUID, 'ReSendFlyer', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}	

function FinishFlyer(Path, GUID)
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 600, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	document.location = Path + '/Wizards/Flyer/Step1.aspx?GUID=' + GUID;
	//window.open(Path + '/Popups/Wizards/Flyer/Cancel.aspx?GUID=' + GUID, 'FinishFlyer', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}

function CancelFlyer(Path, GUID)
	{
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 600, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Path + '/Popups/Wizards/Flyer/Cancel.aspx?GUID=' + GUID, 'CancelFlyer', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
	}

function FlyerWizard(Path, JobID) {
	document.location = (Path + '/Wizards/Flyer/default.aspx?JobID=' + JobID);
}

function FlyerImageManagerPopup(Path, AgentFlyerGUID) {
var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 600, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Path + '/GothamPhotoCompany_ClientAccess/Popups/Wizards/Flyer/ImageManager.aspx?AgentFlyerGUID=' + AgentFlyerGUID, 'ImageManager', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
}

function AgentContactPopup(Path, AgentID) {
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 600, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Path + '/Admin/Popups/AgentContact.aspx?AgentID=' + AgentID, 'AgentContactPopup', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
}

function NotesPopup(Path, QS) {
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 600, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	//QS Exampes:
	//PurchaseID=10
	//JobID=20
	window.open(Path + '/Admin/Popups/Notes.aspx?' + QS, 'NotesPopup', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
}

function DownloadPopup(Path, JobID, Type) {
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 400, popH = 400;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open(Path + '/Popups/Download.aspx?JobID=' + JobID + '&Type=' + Type, 'DownloadPopup', 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
}

function FileDownload(FileID) {
	var w = 480, h = 340;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var popW = 400, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	window.open('/Popups/FileManagement/FileDownload.aspx?FileID=' + FileID, 'DEcuShareFileDownload' + FileID, 'toolbar=no,location=no,scrollbars=yes,width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos );
}

function showHideFileUpload() {
	var stl = document.getElementById('trFileUpload').style;
	if (stl.display == 'block') stl.display = 'none';
	else stl.display = 'block';
}

function confirmDelete() {
	return confirm("Do you really want to delete this item? If you click Yes, this item will be removed from the system and all of its data is lost.");
}

function download(FileID) {
	window.location.href = '/Popups/FileManagement/FileDownload.aspx?FileID=' + FileID;
}

var selectedFileIDs = '';
var selectedFolderIDs = '';

//-------------------------------------------------------------
// Select all the checkboxes (Hotmail style)
//-------------------------------------------------------------
function SelectAllCheckboxes(spanChk){

	// Added as ASPX uses SPAN for checkbox 
	var xState = spanChk.checked;
	var elm = document.getElementsByTagName('input');
	for(var i = 0; i < elm.length; i++) {
		if(elm[i].type == "checkbox" && elm[i].title != spanChk.title) {
			//elm[i].click();
			if(elm[i].checked != xState) elm[i].click();
			//elm[i].checked=xState;
		}
	}
}

//-------------------------------------------------------------
//----Select highlish rows when the checkboxes are selected
//
// Note: The colors are hardcoded, however you can use 
//       RegisterClientScript blocks methods to use Grid's
//       ItemTemplates and SelectTemplates colors.
//-------------------------------------------------------------
function HighlightRow(chkB, id, type)    {
	var xState = chkB.checked;
	if(xState) {
		chkB.parentElement.parentElement.style.backgroundColor='lightcoral';
        chkB.parentElement.parentElement.style.color='white'; 
		if (type == 1) {	// folder
			selectedFolderIDs += (',' + id + ',');
		}
		else if (type == 2) {	// file
			selectedFileIDs += (',' + id + ',');
		}
    } else {
		chkB.parentElement.parentElement.style.backgroundColor='white'; 
        chkB.parentElement.parentElement.style.color='black'; 
		if (type == 1) {	// folder
			selectedFolderIDs = selectedFolderIDs.replace((',' + id + ','), '');
		}
		else if (type == 2) {	// file
			selectedFileIDs = selectedFileIDs.replace((',' + id + ','), '');
		}
	}
}

function minmax(ctrl)
{
	var e = document.getElementById('tblEvents');
	if (e.style.display == 'block')
	{
		ctrl.src = '/images/Site/max.gif';
		e.style.display = 'none';
	} else {
		ctrl.src = '/images/Site/min.gif';
		e.style.display = 'block';
	}
}

function HideNav()
{
	if (window.parent.frames.length != 0)
	{
		var ctrl = document.getElementById('divNav');
		if (ctrl != null) ctrl.style.display = 'none';
	}
}

function errimg(img)
{
	img.src = '/images/spacer.gif';
}

var timeoutID;
function loadClip(source, target1ID, target2ID)
{
	var target1 = document.getElementById(target1ID);
	var target2 = document.getElementById(target2ID);
	var filename = source.options[source.selectedIndex].value;

	if (filename == '') {
		target1.readOnly = false;
		target2.readOnly = false;
		target1.value = '';
		target2.value = '';
		return;
	}

	var url = '';
	if (cbFeatured != '') var e1 = document.getElementById(cbFeatured);
	var e2 = document.getElementById(rblOrientation + '_0');
	var e3 = document.getElementById(rblOrientation + '_1');
	if (cbFeatured != '' && e1.checked)
		url = clipartLocation + 'Featured/' + filename;
	else if (e2.checked)
		url = clipartLocation + 'Portrait/' + filename;
	else if (e3.checked)
		url = clipartLocation + 'Landscape/' + filename;
	else return;
	target1.readOnly = true;
	target2.readOnly = true;
	target1.value = url;
	target2.value = url;

	var img = document.getElementById('imgClipArtPreview');
	img.style.visibility = 'visible';
	img.src = url;
	clearTimeout(timeoutID);
	timeoutID = setTimeout('document.getElementById("imgClipArtPreview").style.visibility = "hidden"', 3000);
}

function checkint(ctrl, min, max) {
	if (!isNaN(ctrl.value)) {
		var tmp = parseInt(ctrl.value);
		if (tmp <= max && tmp >= min) return true;
	}
	alert('Must be a valid integer between ' + min + ' and ' + max);
	return false;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// -->