﻿function test() {

	AdminService.HelloWorld(onHelloWorldRequestComplete, onUpdateInvokeError);
}

function onHelloWorldRequestComplete(result) {
}

function onUpdateInvokeError(result) {
}


function addCostume() {
	var characterId = getQueryStringArgument("CharacterId");
	var costumePicId = $('#ctl00_m_MainContent_m_CharacterImageToSet').val();
	var costumeDesc = $('#ctl00_m_MainContent_m_AddCharacterDesc').val();
	AdminService.AddCharacterCostume(characterId, costumePicId, costumeDesc, onAddCostumeResponse, onUpdateInvokeError);
	$('#m_AddCharacterCostumeDlg').jqmHide()
}

function delCostume(id) {
	var characterId = getQueryStringArgument("CharacterId");
	AdminService.DeleteCharacterCostume(characterId, id, onAddCostumeResponse, onUpdateInvokeError);
}


function onAddCostumeResponse(result) {
	$('#ctl00_m_MainContent_m_CostumeTable').html(result);
	$('#ctl00_m_MainContent_m_Costumes').show();
	$("a[rel*=lightbox]").lightBox();
}


function delCharacter(id) {
	var locId = getQueryStringArgument("LocationId");
	AdminService.DeleteCharacterFromLocation(locId, id, onAddCharacterToLocationResponse, onUpdateInvokeError);
}

function addCharacterLocation() {
	var locationId = getQueryStringArgument("LocationId");
	var characterId = $('#ctl00_m_MainContent_m_AddCharacterDropDown').val();
	var costumePicId = $('#ctl00_m_MainContent_m_CharacterImageToSet').val();
	var costumeDesc = $('#ctl00_m_MainContent_m_AddCharacterDesc').val();
	AdminService.AddCharacterToLocation(locationId, characterId, costumePicId, costumeDesc, onAddCharacterToLocationResponse, onUpdateInvokeError);
	$('#m_AddCharacterDlg').jqmHide()
}

function setCharacterLocationImage() {
	var locationPicId = $('#ctl00_m_MainContent_m_CharacterImageToSet').val();
	var characterImageId = $('#ctl00_m_MainContent_m_SetCharacterDropDown').val();
	var costumeDesc = $('#ctl00_m_MainContent_m_SetCharacterDesc').val();
	AdminService.SetCharacterLocationImage(characterImageId, locationPicId, costumeDesc, onAddCharacterToLocationResponse, onUpdateInvokeError);
	$('#m_SetCharacterPicDlg').jqmHide()
}

function onAddCharacterToLocationResponse(result) {
	if (result != null && result != "") {
		$('#ctl00_m_MainContent_m_CharactersTable').html(result);
		$('#ctl00_m_MainContent_m_Characters').show();
	}
}


function addFeatutedToLocation() {
	var locationId = getQueryStringArgument("LocationId");
	var photoId = $('#ctl00_m_MainContent_m_CharacterImageToSet').val();
	var desc = $('#ctl00_m_MainContent_m_AddFeaturedDesc').val();
	AdminService.AddFeaturedToLocation(locationId, photoId, desc, onAddFeaturedToLocationResponse, onUpdateInvokeError);
	$('#m_AddFeaturedDlg').jqmHide()
}


function onAddFeaturedToLocationResponse(result) {
	if (result != null && result != "") {
		$('#ctl00_m_MainContent_m_FeaturedPhotosTable').html(result);
		$('#ctl00_m_MainContent_m_FeaturedPhotos').show();
	}
}



function addCharacterTrip() {
	var tripReportId = getQueryStringArgument("TripReportId");
	var characterId = $('#ctl00_m_MainContent_m_AddCharacterDropDown').val();
	var costumePicId = $('#ctl00_m_MainContent_m_CharacterImageToSet').val();
	var costumeDesc = $('#ctl00_m_MainContent_m_AddCharacterDesc').val();
	AdminService.AddCharacterToTripReport(locationId, tripReportId, costumePicId, costumeDesc, onAddCharacterToTripReportResponse, onUpdateInvokeError);
	$('#m_AddCharacterDlg').jqmHide()
}

function setCharacterTripImage() {
	var locationPicId = $('#ctl00_m_MainContent_m_CharacterImageToSet').val();
	var characterImageId = $('#ctl00_m_MainContent_m_SetCharacterDropDown').val();
	var costumeDesc = $('#ctl00_m_MainContent_m_SetCharacterDesc').val();
	AdminService.SetCharacterTripReportImage(characterImageId, locationPicId, costumeDesc, onAddCharacterToTripReportResponse, onUpdateInvokeError);
	$('#m_SetCharacterPicDlg').jqmHide()
}

function onAddCharacterToTripReportResponse(result) {
	if (result != null && result != "") {
		$('#ctl00_m_MainContent_m_CharactersTable').html(result);
		$('#ctl00_m_MainContent_m_Characters').show();
	}
}


function setCharacterMainImage() {
	var characterId = getQueryStringArgument("CharacterId");
	var costumePicId = $('#ctl00_m_MainContent_m_CharacterImageToSet').val();
	AdminService.SetCharacterMainImage(characterId, costumePicId, onSetMainImageResponse, onUpdateInvokeError);
}

function setLocationMainImage() {
	var locationId = getQueryStringArgument("LocationId");
	var costumePicId = $('#ctl00_m_MainContent_m_CharacterImageToSet').val();
	AdminService.SetLocationMainImage(locationId, costumePicId, onSetMainImageResponse, onUpdateInvokeError);
}

function onSetMainImageResponse(result) {
	if (result != null && result != "") {
		$('#m_MainImageCell').html(result);
	}
}


function getQueryStringArgument (sArgName) 
{
	var sSearchStr = location.search.substring(1);
	if (sSearchStr == null) 
		return null;
		
	var aArgs = sSearchStr.split('&');
	var aArgParts;
	for (var iArgCnt = 0; iArgCnt < aArgs.length; iArgCnt++) {
		aArgParts = aArgs[iArgCnt].split('=');
		if (aArgParts[0].toLowerCase() == sArgName.toLowerCase()) 
		{
			var sValue = aArgParts[1].split('+').join(' ');
			return unescape(sValue);
			
		}
	}
	return null;
}
