


	 var CurrentLocation = String(window.location.href);
	
	 if(CurrentLocation.indexOf("art.php") > 0 ){
	 
	     //require("js/dhtmlHistory.js");
	     //For JSON 2005  
		window.dhtmlHistory.create({
			toJSON: function(o) {
					return JSON.stringify(o);
			}
			, fromJSON: function(s) {
					return JSON.parse(s);
			}
		});
		 window.onload = initializeHist;
	 }
	 
	 
	  //$(document).ready(initializeHist());

	
	function fb_parse() { 
		FB.XFBML.Host.parseDomTree(); 
     } 
	
      
      function initializeHist() {
        // initialize the DHTML History
        // framework
        dhtmlHistory.initialize();
        
        // subscribe to DHTML history change
        // events
        dhtmlHistory.addListener(historyChange);
            
        // if this is the first time we have
        // loaded the page...
        //if (dhtmlHistory.isFirstLoad()) {
         
        //}
		
	}
         
      /* Our callback to receive history change events. */
      function historyChange(newLocation, historyData) {
							 
        //debug("A history change has occurred: "
        //      + "newLocation="+newLocation
        //      + ", historyData="+historyData, 
        //      true);
		 
			if(newLocation == "Signup"){
				myShowSignupForm();
			}
			if(newLocation == "ForgotPassword"){
				showForgotPasswordForm('txtPageContent');
			}
		
			if(newLocation == "MyGalleries"){
				myShowGalleries();
			}
			
			if(newLocation == "Schools"){
				showSchoolAddForm('txtPageContent')
			}
			if(newLocation == "Continents"){
				showManageLists('continents','txtPageContent',1)
			}
			//if(newLocation == "Countries"){
		    //		showManageLists('countries','txtPageContent',1)
		    //	}
			
			if(newLocation == "Provinces"){
				showManageLists('provinces_states','txtPageContent',1)
			}
			if(newLocation == "Cities"){
				showManageCities('cities','txtPageContent',1)
			}
			
			if(newLocation == "Moods"){
				showManageLists('mood','txtPageContent',1)
			}
			if(newLocation == "Genres"){
				showManageLists('genre','txtPageContent',1)
			}
			if(newLocation == "Materials"){
				showManageLists('material','txtPageContent',1)
			}
			if(newLocation == "Medium"){
				showManageLists('medium','txtPageContent',1)
			}
			if(newLocation == "MediumTypes"){
				showManageMediumTypesLists('medium','txtPageContent',1);	
			}
			if(newLocation == "VotingResults"){
				showAdminResults('txtPageContent');	
				showBreadCrumb1('Voting Results');
			}
			
			//Page Content
			if(newLocation == "Copyright"){
				showPageContent('copyright_policy.php');window.scrollTo(0, 0);
				showBreadCrumb1('Copyright Policy');
			}
			if(newLocation == "About"){
				showPageContent('about.php');window.scrollTo(0, 0);
				showBreadCrumb1('About');
			}
			if(newLocation == "Etiquette"){
				showPageContent('etiquette.php');window.scrollTo(0, 0);
				showBreadCrumb1('Etiquette');
			}
			if(newLocation == "Privacy"){
				showPageContent('privacy_policy.php');window.scrollTo(0, 0);
				showBreadCrumb1('Privacy Policy');
			}
			if(newLocation == "Terms"){
				showPageContent('terms_of_service.php');window.scrollTo(0, 0);
				showBreadCrumb1('Terms of Service');
			}
			
			//Artist Search
			if(newLocation.substring(0,12) == "ArtistSearch"){
				var colPos = newLocation.indexOf(":");
				if(colPos > 0){
					//Use ID from URL (Was Bookmarked)
					var histSearch = newLocation.substring(colPos + 1);
					showSearchArtistForm('txtPageContent',histSearch);
				}else{
					//showSearchArtistForm('txtPageContent','');
				}
					
			}
			
			if(newLocation == "Advertising"){
				showAdvertisingForm('txtPageContent');
			}
			
			
			if(newLocation == "EditMyProfile"){
				showEditArtistProfileForm(historyData,'txtPageContent');
			}
			if(newLocation == "AddWork"){
				showJavaPlowUploadForm('txtPageContent');
			}
			
			if(newLocation.substring(0,6) == "Search"){
			       
				var colPos = newLocation.indexOf(":");
				if(colPos > 0){
				    //alert("front Search");
					//Use ID from URL (Was Bookmarked)
					var histPage = newLocation.substring(colPos + 1);
					mySearchArt(histPage);
				}else{
					//Use History ID
					mySearchArt(historyData);
				}
					
			}
			if(newLocation == "DescribeWork"){
				showDescribeWork(historyData,1,'txtPageContent')
			}
			
			if(newLocation.substring(0,7) == "ShowArt"){
				
			    var colPos = newLocation.indexOf(":");
				if(colPos > 0){
					//Use ID from URL (Was Bookmarked)
					var histArtId = newLocation.substring(colPos + 1);
					
					//Determine if you are already on this Page
					if(document.getElementById("txtShowArtID") != null){
					   if(document.getElementById("txtShowArtID").value != histArtId){
							//alert("FRONT URL SEARCH");
							showArt(histArtId,0,'txtPageContent');
					   }
					}else{
						//alert("FRONT URL SEARCH");
						showArt(histArtId,0,'txtPageContent');
					}
					//alert("use HistColin");
				}else{
					//Use History ID
					showArt(historyData,0,'txtPageContent');
					//alert("use hisotryData");
				}
				
			}
			
			if(newLocation.substring(0,13) == "InboxCritique"){
			    var person_id = $("#txtUserID").value;
			    var colPos = newLocation.indexOf(":");
				if(colPos > 0){
					//Use ID from URL (Was Bookmarked)
					var histArtId = newLocation.substring(colPos + 1);
					showInboxCritiques(person_id, histArtId,'txtPageContent');
					//alert("use HistColin");
				}else{
					//Use History ID
					showInboxCritiques(person_id, historyData,'txtPageContent');
					//alert("use hisotryData");
				}
				
			}
			

			
				if(newLocation.substring(0,13) == "ArtistProfile"){
			    var colPos = newLocation.indexOf(":");
				if(colPos > 0){
					//Use ID from URL (Was Bookmarked)
					var histArtId = newLocation.substring(colPos + 1);
					showArtistProfile(histArtId,0,'txtPageContent');
					//alert("use HistColin");
				}else{
					//Use History ID
					showArtistProfile(historyData,0,'txtPageContent');
					//alert("use hisotryData");
				}
				
			}
			
			
			
			//Re-Get the location
			CurrentLocation = String(window.location.href);
			var myIndexPos = CurrentLocation.indexOf("index.php");
			//alert(CurrentLocation);
			if(myIndexPos > 0){
				var myIndexPageNameCheck = CurrentLocation.substr(myIndexPos);
				//alert(CurrentLocation);
				if(myIndexPageNameCheck == "index.php"){
					//Determine if the Weekly Results already have been Displayed
					if(document.getElementById("txtWeeklyResultsFlag") == null){
					    //alert("showing");
						showWeeklyResultsAll('txtPageContent');
					}
				}
			}
			
			
			
      }
      
      /* Displays messages to the screen. */
      function debug(msg, clear) {
        var output = 
                document.getElementById("output");
        if (clear == true)
          output.innerHTML = "<p>" + msg + "</p>";
        else {
          output.innerHTML += 
                            "<p>" + msg + "</p>";
        }
      }
      
      /* Converts pointy brackets into their
             HTML escape code equivalents so
             we can print out XML. */
         function prettyPrintXml(content) {
            if (content == null)
               return null;
            content = 
                content.replace(/</g, "&lt;");
            content = 
                content.replace(/>/g, "&gt;<br>");
            return content;
         }

 


		function startCallback() {
			// make something useful before submit (onStart)
			return true;
		}
 
		function completeCallback(response) {
			// make something useful after (onComplete)
			document.getElementById('txtAvatarPicture').innerHTML = response;
			document.getElementById('txtAvatarFileName').value = "";
		}


		function completeBlogUploadCallback(response) {
			// make something useful after (onComplete)
			document.getElementById('txtBlogPicture').innerHTML = response;
			
			if($('#txtUploadClicked').val() == 'CLICKED'){   
				myBlog(2);
				agewindow.hide();
			}
			//$('txtblogPicture').html(response);
			//$('txtBlogFileName').val("");
		}
	
//******************************************
//     Search Menu Arrays
var myMenuSearchMaterialID = [];
var myMenuSearchMediumID = [];
var myMenuSearchMediumTypesID = [];
var myMenuSearchMoodID = [];
var myMenuSearchGenreID = [];
//var myMenuSearchCountryID = [];
var myMenuSearchDimensionID = [];
var myMenuSearchMinPrice = '';
var myMenuSearchMaxPrice = '';
var myMenuSearchColorID = [];
var myMenuSearchColorName = [];
var myMenuSearchCityID = '';
var myMenuSearchSchoolID = '';

//Describe Art Arrays
var myEditArtColorID = [];
var myEditArtMaterialID = [];
var myEditArtMoodID = [];
var myEditArtGenreID = [];
var myEditArtMediumID = [];
var myEditArtMediumTypeID = [];

//Delete Art/Gallery Variables
var myDeleteArtID = 0;
var myDeleteArtPreviousID = 0;
var myDeleteArtPreviousPage = 0;
var myDeleteGalleryID = 0;
var myDeleteGroupID = 0;

//Maps
var myMapContinent = [];



//******************************************



//IE Fix for indexOf
if(!Array.indexOf){    Array.prototype.indexOf = function(obj, start){     
		for(var i=(start||0); i<this.length; i++){       
				if(this[i]==obj){         
					return i;          
					}      
				}   
	}
}

//function setbg(color){
//	document.getElementById("styled").style.background=color
//}

//Login Form (Enter Key)
function pressEnter(e,action){
  if(window.event) { // IE
  	keynum = e.keyCode;
  }
  else if(e.which){ // Netscape/Firefox/Opera
  	keynum = e.which;
  }
  if(keynum == 13){
      
	  if( action == "SEARCH"){
		  mySearchArt();
	  }else if(action == "LOGIN"){
		  myLogin();
	  }

  }
}



function MultiPowUpload_onCompleteAbsolute(type, uploadedBytes)
{
	//window.alert(type + " process is complete. Total bytes transmitted " + uploadedBytes);
	if(document.getElementById('dd_gallery') != null){
		gallery_index = document.getElementById("dd_gallery").selectedIndex;
		gallery_id = document.getElementById("dd_gallery").options[gallery_index].value;
		
		showJavaPlowUploadFinished(gallery_id,'txtUploadFinished');
	}else if(document.getElementById('txtGroupID') != null){
		
		group_id = document.getElementById("txtGroupID").value;
		showJavaPlowUploadFinishedGroup(group_id,'txtUploadFinished');
		
	}

}

function fileUploadedRedirectToDescibeArt(art_id, view_page){
	//Wait for output
	
	//var art_id = document.getElementById("txtUploadArtID"); 
	//var view_page = document.getElementById("txtUploadArtViewPage"); 

	if(art_id != null && view_page != null){
		showDescribeWork(art_id ,view_page,'txtPageContent');
	}
	


}

	function permission_gohome() 
	{ 
	window.location = 'editprofile.php'; 
	} 


//***************************************************************************
// Intro Popup
//***************************************************************************
//function hideIntro(){
//	document.getElementById("introPopup").style.visibility = "hidden";
//}

//function showIntro(){
//	document.getElementById("introPopup").style.visibility = "visible";
//}



//***************************************************************************
// Confirm Delete Modal Popup.
//***************************************************************************


function myDeleteArtPrompt(){
	agewindow=dhtmlmodal.open('agebox', 'div', 'modalalertDeleteArtdiv', '', 'width=421px,height=154px,left=350px,top=200px,resize=0,scrolling=0')
}
function myDeleteGalleryPrompt(){
	agewindow=dhtmlmodal.open('agebox', 'div', 'modalalertDeleteGallerydiv', '', 'width=421px,height=154px,left=350px,top=200px,resize=0,scrolling=0')
}
function myDeleteGroupPrompt(){
	agewindow=dhtmlmodal.open('agebox', 'div', 'modalalertDeleteGroupdiv', '', 'width=421px,height=154px,left=350px,top=200px,resize=0,scrolling=0')

}
function myDeleteBlogPrompt(){
	agewindow=dhtmlmodal.open('agebox', 'div', 'modalalertDeleteBlogdiv', '', 'width=421px,height=154px,left=350px,top=200px,resize=0,scrolling=0')
}
function myBlogPrompt(){
    //Insert new Blog Unpublished Record.
	addTempBlog('');
}
function myEventPopup(action,event_id){
	//agewindow=dhtmlmodal.open('agebox', 'div', 'modalalertEventdiv', '', 'width=421px,height=454px,left=350px,top=200px,resize=1,scrolling=0')
	if(action == "show"){
		document.getElementById("EventsWindow").style.visibility = "visible";
	}
	if(action == "hide"){
		document.getElementById("EventsWindow").style.visibility = "hidden";
	}
	
	if(action == "edit"){
		showEventForm(event_id,'txtEventPopup');
	}
	
}

function myEvent(){
	event_id = document.getElementById("txtEventID").value;
	
	if(event_id > 0){
		action = "EDIT";
	}else{
		action = "ADD";
	}
	
	
	title = document.getElementById("txtEventTitle").value;
	start_date = document.getElementById("txt_start_date").value;
	end_date = document.getElementById("txt_end_date").value;
	description = document.getElementById("txtEventDescription").value;
	url = document.getElementById("txtEventUrl").value;
	person_id = document.getElementById("txtEventPersonID").value;

	if(action == "ADD"){
		addEvent(title,start_date, end_date, description, url,person_id,'event-holder')
	}
	if(action == "EDIT"){
		editEvent(event_id,title,start_date, end_date, description, url,person_id,'profile-right');
	}
	myEventPopup('hide');
}

function myDeleteEvent(event_id, person_id){
	deleteEvent(event_id, person_id, 'profile-right');
}





//Function to run when buttons within modal window is clicked on. Directly embedded inside hidden DIV, bypassing "onclose" event:
function process_DeleteArt(whichbutton){
	if (whichbutton=="yes"){
		var art_id = myDeleteArtID;
		var previous_art_id = myDeleteArtPreviousID;
		var previous_page = myDeleteArtPreviousPage;
		if(art_id > 0){
			deleteArt(art_id,previous_art_id,previous_page, 'txtPageContent');
		}
	}
	
	agewindow.hide();
}

function process_DeleteGallery(whichbutton){
	if (whichbutton=="yes"){
	    var gallery_id = myDeleteGalleryID;
		var person_id = document.getElementById("txtUserID").value;
		if (gallery_id > 0 ){
			deleteGallery(person_id, gallery_id, 'txtPageContent');
		}
	}
	agewindow.hide();
}

function process_DeleteGroup(whichbutton){
	if (whichbutton=="yes"){
	    var group_id = myDeleteGroupID;
		if (group_id > 0 ){
			deleteGroup(group_id, 'txtPageContent');
		}
	}
	agewindow.hide();
}

function process_DeleteBlog(whichbutton){
	if (whichbutton=="yes"){
	    var blog_id = myDeleteBlogID;
		if (blog_id > 0 ){
			deleteBlog(blog_id, 'txtBlogsAdmin');
		}
	}
	agewindow.hide();
}

function process_Blog(whichbutton){
	if (whichbutton=="save"){
	    //var blog_id = myDeleteBlogID;
		//if (blog_id > 0 ){
			if($('#txtBlogFileName').val() > ""){ 
				//Picture was added 
				$('#txtUploadClicked').attr('value','CLICKED');	
				$('#avatarUploadButton').trigger('click');
			}else{
				myBlog(2);
				agewindow.hide();
			}

		//}
	}else{
	   agewindow.hide();
	}

}





//***************************************************************************
// Ajax Back Button (New)  Does not work in IE Currently
//***************************************************************************
/*
		var PrevHashLocationName = "";
		
		function CheckForHash(){
			if(document.location.hash){
				var HashLocationName = document.location.hash;
				HashLocationName = HashLocationName.replace("#","");
				
				if(PrevHashLocationName != HashLocationName){
					if(HashLocationName == "MyGalleries"){ myShowGalleries(); PrevHashLocationName = HashLocationName;}
					if(HashLocationName == "EditMyProfile"){ myshowEditArtistProfileForm('txtPageContent');PrevHashLocationName = HashLocationName;}
					if(HashLocationName == "AddWork"){ showJavaPlowUploadForm('txtPageContent');PrevHashLocationName = HashLocationName; }
				}
				//clearTimeout()
				//document.getElementById(HashLocationName).style.display='block';
				//document.getElementById('Intructions').style.display='none';
				//for(var a=0; a<5; a++){
				//	if(HashLocationName != ('Show' +(a+1))){
				//		document.getElementById('Show'+(a+1)).style.display='none';
				//	}
				//}
			}else{
				//document.getElementById('Intructions').style.display='block';
				//for(var a=0; a<5; a++){
				//	document.getElementById('Show'+(a+1)).style.display='none';
				//}
			}
		}

		var HashCheckInterval = setInterval("CheckForHash()", 1000);
		window.onload = CheckForHash;


		function RenameAnchor(anchorid, anchorname){
			document.getElementById(anchorid).name = anchorname; //this renames the anchor
		}
		function RedirectLocation(anchorid, anchorname, HashName){
	
			RenameAnchor(anchorid, anchorname);
			document.location = HashName;
		}
		
		
		function myshowEditArtistProfileForm(location){
			//Wrapper Function for showEditArtisProfileForm
		    person_id = document.getElementById("txtUserID");
			if(person_id != null){
				showEditArtistProfileForm(person_id.value,location);
			}
		}

*/
//***************************************************************************
//  Manage LISTS (New)
//***************************************************************************


function addListItem(table_name) {
    item_desc = document.getElementById("txtAdd" + table_name + "Desc").value;
	if(table_name == "cities"){
		editManageCities('ADD',table_name,0,item_desc,0,0,0,'txtPageContent');
	}else{
		editManageLists('ADD',table_name,0,item_desc,'txtPageContent');
	}
}

function beginEditListItem(table_name,item_id,desc){
     var item_ref = "txt_" + table_name +  "_" + item_id;
     document.getElementById(item_ref).innerHTML = '<input size="20" id="txtChange' + table_name + 'Desc_' + item_id  + '" type="text" value="' + desc + '" />&nbsp;<img onclick="saveItemDesc(\'' + table_name + '\',' +  item_id + ');return false;" alt="Save" title="Save" src="images/disc.png" />';
}

function beginEditListItemColumn(table_name,item_id,column_name, desc){
     var item_ref = "txt_" + table_name +  "_" + column_name + "_" +  item_id;
     document.getElementById(item_ref).innerHTML = '<input size="20" id="txtChange' + table_name + column_name + 'Desc_' + item_id  + '" type="text" value="' + desc + '" />&nbsp;<img onclick="saveItemColumnDesc(\'' + table_name + '\',\'' + column_name + '\',' +  item_id + ');return false;" alt="Save" title="Save" src="images/disc.png" />';
}


function saveItemDesc(table_name, item_id){
   var ChangeItemDesc = document.getElementById('txtChange' + table_name + 'Desc_' + item_id);
   if(ChangeItemDesc != null){
        item_desc = ChangeItemDesc.value;
		if(table_name == "cities"){
			editManageCities('EDIT',table_name, item_id, item_desc,0,0,0,'txtPageContent');
		}else{
			editManageLists('EDIT',table_name, item_id, item_desc,'txtPageContent');
		}
   }
}

function saveItemColumnDesc(table_name, column_name, item_id){
   var ChangeItemDesc = document.getElementById('txtChange' + table_name  + column_name  + 'Desc_' + item_id);
   if(ChangeItemDesc != null){
        item_desc = ChangeItemDesc.value;
		if(table_name == "continents"){
			editContinentFileName(item_id, item_desc,'');
		}
   }
}



function deleteListItem(table_name, item_id) {
	var answer = confirm("Are you Sure You Want to Delete this Item from the " + table_name + " table ?  This will cause this Item to be Unavailable and may result in lost user data.")
    if(answer){
		if(table_name == "cities"){
			editManageCities('DELETE',table_name, item_id,'',0,0,0,'txtPageContent');
		}else{
			editManageLists('DELETE',table_name, item_id,'','txtPageContent');
		}
	}
}

//Medium Types
function addMediumTypeListItem(medium_id) {
    medium_name = document.getElementById("txtAddMediumTypeDesc").value;
    editMediumTypes('ADD',0,medium_id,medium_name,'txt_medium_type_list');
}

function beginEditMediumTypeListItem(medium_id, medium_type_id,desc){
     var item_ref = "txt_medium_type_" + medium_type_id;
     document.getElementById(item_ref).innerHTML = '<input size="30" id="txtChangeMediumTypeDesc_' + medium_type_id  + '" type="text" value="' + desc + '" />&nbsp;<img onclick="saveMediumTypeItemDesc(' + medium_id + ',' + medium_type_id + ');return false;" alt="Save" title="Save" src="images/disc.png" />';
}


function saveMediumTypeItemDesc(medium_id,medium_type_id){
   var ChangeMediumTypeDesc = document.getElementById('txtChangeMediumTypeDesc_' + medium_type_id);
   if(ChangeMediumTypeDesc != null){
        medium_type_name = ChangeMediumTypeDesc.value;
   	editMediumTypes('EDIT',medium_type_id, medium_id, medium_type_name,'txt_medium_type_list');
   }
}


function deleteMediumTypeListItem(medium_id, medium_type_id) {
     editMediumTypes('DELETE',medium_type_id,medium_id,'','txt_medium_type_list');
}

function myManageCitiesCountrySelect(city_id){
	//Get Country_ID
	country_id = myGetGenericDropDown_Id("dd_country");
	
	manageCitiesCountrySelect(city_id, country_id, '');
}

function myManageCountriesContinentSelect(country_id){
	//Get Continent_ID
	continent_id = myGetGenericDropDown_Id("dd_continent");
	
	manageCountriesContinentSelect(country_id, continent_id, '');
}



//************************************************
//Password Recovery
//************************************************

function myForgotPassword(){
   
	var txtEmail = document.getElementById("txtEmailForgot");
	
	if(txtEmail.value > ""){
		
		forgotPassword(txtEmail.value,"txtForgotPasswordResult");
		txtEmail.value = "";
	}

}




//*************************************
//    Mouse Coordinantes
//    (Add this to page: document.onmousemove = getMouseXY;)
//**************************************
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)


// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

function getMouseXY(e) {
  
  var tempX = 0;
  var tempY = 0;
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  if(document.getElementById('MouseX') != null){
	document.Show.MouseX.value = tempX
	document.Show.MouseY.value = tempY
  }
  return true
  
}

function point_it(event){
	pos_x = event.offsetX?(event.offsetX):event.pageX-document.getElementById("imgCurrentMap").offsetLeft;
	pos_y = event.offsetY?(event.offsetY):event.pageY-document.getElementById("imgCurrentMap").offsetTop;
	//document.getElementById("cross").style.left = (pos_x-1) ;
	//document.getElementById("cross").style.top = (pos_y-15) ;
	//document.getElementById("cross").style.visibility = "visible" ;
	//document.pointform.form_x.value = pos_x;
	//document.pointform.form_y.value = pos_y;
	
	//Grab the ID of the City (if its set)
	city = document.getElementById('txtModifyCityCoordinatesCityID');
	continent = document.getElementById('txtContinentID');
	if(city != null){
		city_id = city.value;
		//alert(city_id);
		
		if(continent != null){
			continent_id = continent.value;
		}else{
			continent_id = 0;
		}
		
		modifyCityLocation(city_id, continent_id, pos_x , pos_y, 'map_admin_current_city');
		document.getElementById('imgContinentMap').style.cursor='default';
	}
	
	//alert(pos_x + ' ' + pos_y)
	
	
}


function redrawPalette(){

	var colors = document.getElementById("txt_color_list");
	colors.style.display = 'block';
	if(isIE){addIEGlossy(); } else {addGlossy();};
	
}

function refreshPalette(){

	var colors = document.getElementById("txt_color_list");
	colors.style.display = 'none';
	setTimeout("redrawPalette();",30);
	
}

function myEnableColorPalette(flag){

	if(flag == 'true'){
	    var colorFlag = 1;
	    document.body.style.cursor='crosshair'
	}else{	
	    var colorFlag = 0;
	    document.body.style.cursor='auto'
	}
	
	document.getElementById("txtAddColorsFlag").value = colorFlag;	
	

}

function myGetColor(Image){

  //Get the actual x and y corrdinates of the mouse over the image
  //This is done by comparing the document corrdinates to the image corrdinates.

  //art_id  = document.getElementById("txtArtID").value;	
  var tempX = document.Show.MouseX.value 
  var tempY = document.Show.MouseY.value 

  if (IE) { // grab the x-y pos.s if browser is IE
	ImageXPos = tempX - Image.offsetLeft
  	ImageYPos = tempY - Image.offsetTop
  }else{
  	ImageXPos = tempX - Image.x
  	ImageYPos = tempY - Image.y
 }

   alert(tempX + "/" + tempY + "these are the Mouse Coordinates: " + ImageXPos + " -" + ImageYPos);
  
  
  var map = document.getElementById('imgCurrentMap');
  alert(map.x);
  //Determine if Colors can be added (Colors Tab is Enabled)
  //var colorsFlag = document.getElementById("txtAddColorsFlag").value

  //if(colorsFlag == 1){
  	//getArtColors(art_id,ImageXPos, ImageYPos, "true" , "txt_color_list");
  //}
  

 	
}


//*****************************
//	Group Directory
//*****************************
function group_directory_name_over(group_id){
	var group_directory_name = document.getElementById('group_directory_name_' + group_id);
	if(group_directory_name != null){
		group_directory_name.style.backgroundImage="url(images/group_directory_name_background_blue.png)";
	}
}

function group_directory_name_out(group_id){
	var group_directory_name = document.getElementById('group_directory_name_' + group_id);
	if(group_directory_name != null){
		group_directory_name.style.backgroundImage="url(images/group_directory_name_background_pink.png)";
	}
}



//*****************************
//	Schools
//*****************************
function clearSchoolForm(){
  //Clear all the Fields on the Forum

  SchoolName = document.getElementById("txtSchoolName");
  if(SchoolName != null){

    document.getElementById("txtSchoolName").value = "";
    document.getElementById("txtSchoolInitials").value = "";
    document.getElementById("txtSchoolDescription").value = "";
	document.getElementById("txtCity").value = "";
	
	 document.getElementById("dd_continent").selectedIndex = 0;
	 document.getElementById("dd_country").selectedIndex = 0;
	 document.getElementById("dd_province").selectedIndex = 0;
	 document.getElementById("dd_city").selectedIndex = 0;

   }
}

function myDeleteSchool(school_id){
    var result = confirm("are you sure you want to delete this school")
	if(result){
		deleteSchool(school_id, 'txtSchoolList')
	}
}

function mySchool(action, school_id) {

  var validEntry = true;
  var ErrorMessage = '';

  school_name = document.getElementById("txtSchoolName").value;
  school_initials = document.getElementById("txtSchoolInitials").value;
  school_description = document.getElementById("txtSchoolDescription").innerHTML;
  
  //continent_index = document.getElementById("dd_continent").selectedIndex;
  //continent_id = document.getElementById("dd_continent").options[continent_index].value;
  continent_id = myGetGenericDropDown_Id("dd_continent");
  
  //country_index = document.getElementById("dd_country").selectedIndex;
  //country_id = document.getElementById("dd_country").options[country_index].value;
  country_id = myGetGenericDropDown_Id("dd_country");
	
   //province_index = document.getElementById("dd_province").selectedIndex;
   //province_id = document.getElementById("dd_province").options[province_index].value;
   province_id = myGetGenericDropDown_Id("dd_province");
   
   //city = document.getElementById("txtCity").value;
   city_id = myGetGenericDropDown_Id("dd_city");
   
   if(school_name > ''){}else{
		ErrorMessage += "* School Name Required"  + '\n'
		validEntry = false;
   }
   
   if(continent_id > 0){}else{
		ErrorMessage += "* Continent Required"  + '\n'
		validEntry = false;
   }
   
    if(country_id > 0){}else{
		ErrorMessage += "* Country Required"  + '\n'
		validEntry = false;
   }
   
    if(province_id > 0){}else{
		ErrorMessage += "* Province Required"  + '\n'
		validEntry = false;
   }
   

   if(city_id > ''){}else{
		ErrorMessage += "* City Required" + '\n'
		validEntry = false;
   }
  

 
  if (validEntry == true){
  
    if(action == "ADD"){
      if (school_name > ''){
        editSchools('ADD', 0, school_name, school_initials, school_description,continent_id, country_id, province_id, city_id, 'txtSchoolList')
		clearSchoolForm();
	  }
	  
	}
	
	if(action == "EDIT"){
	   if (school_name > ''){
		 editSchools('EDIT', school_id, school_name, school_initials, school_description,continent_id, country_id, province_id, city_id, 'txtSchoolList')
       }
	}
	
	
  }else{
     alert(ErrorMessage);
  }
  
}



//*****************************
//Wall Messages 
//*****************************
function myAddMessage(to_person_id,from_person_id){

	message = document.getElementById("styled").value;

	if((message > '') && (message != 'Enter your comment here...')){
		addMessage( to_person_id, from_person_id, message, 'txtMessageComments');
		clearWallForm()
	}
}

function clearWallForm(){
  //Clear all the Fields on the Forum
    document.getElementById("styled").value = "";
}



//*****************************
//Critiques
//*****************************
function myAddCritique(art_id,type){

   var critique = '';
   if(!art_id > 0){
		art_id = document.getElementById("txtArtID").value;
   }
	
	person_id = 1;

	if(type == 'VIDEO'){
		critique = document.getElementById("video_styled").value;
		if((critique > '') && (critique != 'Enter your comment here...')){
			editCritiques("ADDVIDEO", 0, art_id, critique, person_id, '', 0, 1, 'critique_comments');
			clearCritiqueForm();
		}
	}else{

		
	
		if(document.getElementById("styled") != null){
			critique = document.getElementById("styled").value;
			
			if((critique > '') && (critique != 'Enter your comment here...')){
				editCritiques("ADD", 0, art_id, critique, person_id, '', '', 1, 'critique_comments');
				clearCritiqueForm()
			}
		}else if(document.getElementById("artist-profile-art-random-critique-textarea") != null){
			critique = document.getElementById("artist-profile-art-random-critique-textarea").value;
			
			if((critique > '') && (critique != 'Enter your comment here...')){
				editCritiques("ADD", 0, art_id, critique, person_id, '', 'SMALL', 1, 'critique_comments');
				clearCritiqueForm()
			}
		}else if(document.getElementById("artist-profile-art-random-critique-textarea-" + art_id) != null){
			critique = document.getElementById("artist-profile-art-random-critique-textarea-" + art_id);
			
			if((critique.value > '') && (critique != 'Enter your comment here...')){
				editCritiques("ADD", 0, art_id, critique.value, person_id, '', 'SMALL', 1, 'critique_comments_' + art_id);
				critique.value = '';
				clearCritiqueForm()
			}
		}	
		
		

	}
}

function clearCritiqueForm(){
  //Clear all the Fields on the Forum

    //document.getElementById("txtName").value = "";
	if(document.getElementById("styled") != null){
		document.getElementById("styled").value = "";
	}
		if(document.getElementById("video_styled") != null){
		document.getElementById("video_styled").value = "";
	}
 
}



//*****************************
//  Status Update
//*****************************
function myAddStatus(status_type,person_id){

    if(person_id > 0){
		var StatusDescription  = document.getElementById("txtStatusDescription");
		if(StatusDescription != null){
			if(StatusDescription.value > ''){
				addStatus(status_type, person_id,StatusDescription.value,'txtPersonStatus');
			}
		}
	}

}




//*****************************
//  Artist Search
//*****************************


function myArtistSearch(search_name,filter_letter_start, filter_letter_end, view_page){

  if(view_page > 1){
  }else{
	view_page = 1;
  }

  if(search_name > ''){
		document.getElementById("txtArtistSearchText").value = search_name;
  }else{
		//Get Search_Name from text box
		search_name = document.getElementById("txtArtistSearchText").value
  }
  
  if(filter_letter_start > "" || filter_letter_end > ""){
  }else{
	  highlightFilterText();
  }
  
  //if(search_name > ''){
	searchArtist(search_name, filter_letter_start, filter_letter_end,  0, 30, view_page, 'txtArtistSearchResults');
	clearLiveSearch();
  //}
  

}

function clearLiveSearch(){
	 var hint_div = document.getElementById('txtArtistSearchHint');
	 if(hint_div != null){
		hint_div.innerHTML="";
		hint_div.style.width="0px";
		hint_div.style.padding="0px";
	 }

}

function highlightFilterText(filterText){

    //var filterObjects = document.getElementsByTagName("filter_by_letter");
	var filterObjectA = document.getElementById("filterA")
	var filterObjectE = document.getElementById("filterE")
	var filterObjectI = document.getElementById("filterI")
	var filterObjectM = document.getElementById("filterM")
	var filterObjectP = document.getElementById("filterP")
	var filterObjectT = document.getElementById("filterT")
	var filterObjectX = document.getElementById("filterX")
	
	filterObjectA.style.color="#000000";
	filterObjectE.style.color="#000000";
	filterObjectI.style.color="#000000";
	filterObjectM.style.color="#000000";
	filterObjectP.style.color="#000000";
	filterObjectT.style.color="#000000";
	filterObjectX.style.color="#000000";
	
	//for(var i=0; i < filterObjects.length; i++){
        //filterObjects[i].style.color="#000000";
		//filterObjects.style.color="#000000";
    // }
    if (typeof(filterText) != 'undefined'){
		filterText.style.color='#FF0099';
	}

}

//******************************************************************
//   				Advertising
//******************************************************************

function myAdvertising(){
var valid_entry = true;
    var fname = document.getElementById("txtFirstName").value;
    var lname = document.getElementById("txtLastName").value;
	var organization =  document.getElementById("txtOrganization").value;
	var email = document.getElementById("txtEmailAdvertising").value;
	var description = document.getElementById("txtDescription").value;
	var captcha = document.getElementById("txtCaptcha").value;
	
    
	var errorMessage = "";
	
	//Check First Name
	if(fname == ""){
		valid_entry = false;
		document.getElementById("txtFirstNameError").innerHTML = " First Name Required";
	}else{
		document.getElementById("txtFirstNameError").innerHTML = "";
	}
	
	//Check Last Name
	if(lname == ""){
		valid_entry = false;
		document.getElementById("txtLastNameError").innerHTML = " Last Name Required";
	}else{
		document.getElementById("txtLastNameError").innerHTML = "";
	}

    //Check Email
	if(email == ""){
		valid_entry = false;
		document.getElementById("txtEmailError").innerHTML = " Email Required";
	}else{
		document.getElementById("txtEmailError").innerHTML = "";
	}
	
	//Check Organization
	if(organization == ""){
		valid_entry = false;
		document.getElementById("txtOrganizationError").innerHTML = " Organization Required";
	}else{
		document.getElementById("txtOrganizationError").innerHTML = "";
	}
	
	//Check Description
	if(description == ""){
		valid_entry = false;
		document.getElementById("txtDescriptionError").innerHTML = " Description Required";
	}else{
		document.getElementById("txtDescriptionError").innerHTML = "";
	}
	

	

	if(valid_entry == true){
	
		//Verrify Captcha was entered properly
		if(verrifyCaptcha(captcha) == 'true'){
			document.getElementById("txtCaptchaError").innerHTML = "";
		}else{
			valid_entry = false;
			document.getElementById("txtCaptchaError").innerHTML = " Text Does not Match";
		}
		
		if(valid_entry == true){
			document.getElementById("advertising_saved").innerHTML = "";
			sendAdvertisingEmail(fname,lname, organization, email, description ,'txtPageContent');
			//document.getElementById("advertising_saved").innerHTML = " Your Information has been Submitted. Thank You.";
		}else{
			document.getElementById("advertising_saved").innerHTML = " Please correct your Form Errors.";
		}

	}else{
		document.getElementById("advertising_saved").innerHTML = " Please correct your Form Errors.";
		//alert("Please correct your Form Errors.")
    }	

}



//******************************************************************
//   				Contact
//******************************************************************

function myContact(){
var valid_entry = true;
    var fname = document.getElementById("txtFirstName").value;
    var lname = document.getElementById("txtLastName").value;
	var school =  document.getElementById("txtSchool").value;
	var email = document.getElementById("txtContactEmail").value;
	var description = document.getElementById("txtDescription").value;
	var captcha = document.getElementById("txtCaptcha").value;
	
	var errorMessage = "";
	
	//Check First Name
	if(fname == ""){
		valid_entry = false;
		document.getElementById("txtFirstNameError").innerHTML = " First Name Required";
	}else{
		document.getElementById("txtFirstNameError").innerHTML = "";
	}
	
	//Check Last Name
	if(lname == ""){
		valid_entry = false;
		document.getElementById("txtLastNameError").innerHTML = " Last Name Required";
	}else{
		document.getElementById("txtLastNameError").innerHTML = "";
	}

    //Check Email
	if(email == ""){
		valid_entry = false;
		document.getElementById("txtEmailError").innerHTML = " Email Required";
	}else{
		document.getElementById("txtEmailError").innerHTML = "";
	}
	
	//Check Schol
	if(school == ""){
		valid_entry = false;
		document.getElementById("txtSchoolError").innerHTML = " School Required";
	}else{
		document.getElementById("txtSchoolError").innerHTML = "";
	}
	
	//Check Issue & Inquiry
	if(description == ""){
		valid_entry = false;
		document.getElementById("txtDescriptionError").innerHTML = " Required";
	}else{
		document.getElementById("txtDescriptionError").innerHTML = "";
	}
	


	if(valid_entry == true){
		//Verrify Captcha was entered properly
		if(verrifyCaptcha(captcha) == 'true'){
			document.getElementById("txtCaptchaError").innerHTML = "";
		}else{
			valid_entry = false;
			document.getElementById("txtCaptchaError").innerHTML = " Text Does not Match";
		}
		
		
		if(valid_entry == true){
			
			document.getElementById("advertising_saved").innerHTML = "";
			sendContactEmail(fname,lname, school, email, description ,'txtPageContent');
			//document.getElementById("advertising_saved").innerHTML = " Your Information has been Submitted. Thank You.";
		}else{
			document.getElementById("advertising_saved").innerHTML = " Please correct your Form Errors.";
		}

	}else{
		document.getElementById("advertising_saved").innerHTML = " Please correct your Form Errors.";
		//alert("Please correct your Form Errors.")
    }	

}

//******************************************************************
//   				Purchase
//******************************************************************

function myPurchase(art_id){
var valid_entry = true;

	var email = document.getElementById("txtPurchaseEmail").value;
	var message = document.getElementById("txtMessage").value;
	var captcha = document.getElementById("txtCaptcha").value;
	
	var errorMessage = "";
	
    //Check Email
	if(email == ""){
		valid_entry = false;
		document.getElementById("txtEmailError").innerHTML = " Required";
	}else{
		document.getElementById("txtEmailError").innerHTML = "";
	}
	
	
	//Check Issue & Inquiry
	if(message == ""){
		valid_entry = false;
		document.getElementById("txtMessageError").innerHTML = " Required";
	}else{
		document.getElementById("txtMessageError").innerHTML = "";
	}
	


	if(valid_entry == true){
	
		//Verrify Captcha was entered properly
		if(verrifyCaptcha(captcha) == 'true'){
			document.getElementById("txtCaptchaError").innerHTML = "";
		}else{
			valid_entry = false;
			document.getElementById("txtCaptchaError").innerHTML = " Text Does not Match";
		}
		
		if(valid_entry == true){
			document.getElementById("advertising_saved").innerHTML = "";
			sendPurchaseEmail(art_id, email, message ,'txtPageContent');
			//document.getElementById("advertising_saved").innerHTML = " Your Information has been Submitted. Thank You.";
		}else{
			document.getElementById("advertising_saved").innerHTML = " Please correct your Form Errors.";
		}

	}else{
		document.getElementById("advertising_saved").innerHTML = " Please correct your Form Errors.";
		//alert("Please correct your Form Errors.")
    }	

}


//******************************************************************
//    					Partners
//******************************************************************

function myAddPartner(){
	var PartnerName = document.getElementById("txtPartnerName").value;
	var PartnerURL = document.getElementById("txtPartnerURL").value;
	
	addPartner(PartnerName,'',PartnerURL,'txtPageContent');
}

function myPartnerPostFlag(partner_id, post_flag){
	editPartnerPostFlag(partner_id,post_flag)
}

function myDeletePartner(partner_id){
	deletePartner(partner_id,'txtPageContent');
}

//******************************************************************
//    					Features
//******************************************************************

function myFeaturePopup(action,feature_id,feature_counter){
	if(action == "show"){
		
		if(feature_counter > 0){
			feature_counter = feature_counter * 80;
			var myTopMargin = String(feature_counter - 120) + 'px';
			document.getElementById("FeaturesWindow").style.marginTop = myTopMargin;
		}
		document.getElementById("FeaturesWindow").style.visibility = "visible";
	}
	if(action == "hide"){
		document.getElementById("FeaturesWindow").style.visibility = "hidden";
	}
	
	if(action == "edit"){
		showFeatureForm(feature_id,'txtFeaturePopup');
	}
	
}

function myFeature(){
	feature_id = document.getElementById("txtFeatureID").value;
	
	if(feature_id > 0){
		action = "EDIT";
	}else{
		action = "ADD";
	}
	
	var featureStartDate = document.getElementById("txtFeatureStartDate").value;
	var featureEndDate = document.getElementById("txtFeatureEndDate").value;
	var featureName = document.getElementById("txtFeatureName").value;
	var featureURL = document.getElementById("txtFeatureURL").value;

	if(action == "ADD"){
		addFeature(featureStartDate, featureEndDate, featureName,featureURL,'txtPageContent');
	}
	if(action == "EDIT"){
		editFeature(feature_id, featureStartDate, featureEndDate, featureName,featureURL,'txtPageContent');
	}
	myFeaturePopup('hide');
}

function myDeleteFeature(feature_id){
	deleteFeature(feature_id,'txtPageContent');
}




//******************************************************************
//    					Blogs
//******************************************************************

function myBlogPopup(action,blog_id,blog_counter){
	if(action == "show"){
		
		if(blog_counter > 0){
			blog_counter = blog_counter * 80;
			var myTopMargin = String(blog_counter - 120) + 'px';
			document.getElementById("blogs-window").style.marginTop = myTopMargin;
		}
		$('#blogs-window').show();
	}
	if(action == "hide"){
		$('#blogs-window').hide();
	}
	
	if(action == "edit"){
		showBlogForm(blog_id,'txtBlogPopup');
	}
	
}

function myBlog(blog_mode){
	blog_id = $("#txtBlogID").val();
	
	if(blog_id > 0){
		action = "EDIT";
	}else{
		action = "ADD";
	}
	
	//Determin Which Radio Button Was Checked.
	//Check Radio Buttons
	//blog_type = "Photo";
	//radio_photo = document.getElementById("radioBlogTypePhoto").checked;
	//radio_video = document.getElementById("radioBlogTypeVideo").checked;
	//radio_text = document.getElementById("radioBlogTypeText").checked;
	
	//if(radio_photo){
	//	blog_type = "Photo";
	//}else if(radio_video){
	//	blog_type = "Video";
	//}else if(radio_text){
	blog_type = "Video";
	//}
	
	//var blogOrderNumber = document.getElementById("txtBlogOrderNumber").value;
	//var blogStartDate = document.getElementById("txtBlogStartDate").value;
	//var blogEndDate = document.getElementById("txtBlogEndDate").value;
	var blogTitle = $("#txtBlogTitle").val();
	var blogText = $("#txtBlogText").val();
	var blogURL = $("#txtBlogURL").val();
	var blogFileName = $("#txtBlogFileName").val();
	if(blogFileName == ""){
		blogFileName = $("#txtPrevBlogFileName").val();
	}
	
	if(blogURL == "Insert URL here (optional)"){
		blogURL = "";
	}
	

	if(action == "ADD"){
	    if(blog_mode == 2){
			addBlog2(blog_type, blogTitle, blogText, blogFileName, blogURL,'txtBlogsAdmin');
		}else{
			addBlog(blog_type, blogTitle, blogText, blogFileName, blogURL,'txtBlogsAdmin');
		}
		
	}
	if(action == "EDIT"){
		editBlog(blog_id, blog_type, blogTitle,blogText, blogFileName ,blogURL,'txtBlogsAdmin');
	}
	myBlogPopup('hide');
}

function myDeleteBlog(blog_id){
	myDeleteBlogID = blog_id;
	
	myDeleteBlogPrompt();

}

function myAddBlogUser(person_id, destination){
	addBlogUser(person_id, destination)
}

function myRemoveBlogUser(person_id, destination){
	removeBlogUser(person_id, destination)
}



//******************************************************************
//    					Blog Features
//******************************************************************

function myChangeBlogFeatureOrder(blog_id,blog_order_number){
	editBlogFeature(blog_id,blog_order_number,'txtPageContent');
}

function myDeleteBlogFeature(blog_id){
	deleteBlogFeature(blog_id,'txtPageContent');
}


//******************************************************************
//    					Blog Subscriptions
//******************************************************************

function myAddBlogSubscription(blog_person_id){
	addBlogSubscription(blog_person_id,'txtPageContent');
}

function myDeleteBlogSubscription(blog_person_id){
	deleteBlogSubscription(blog_person_id,'txtPageContent');
}



//******************************************************************
//   				VIDEO
//******************************************************************

function myFilterVideo(video_id, view_page,school_id){
	country_id = myGetCountry_Id();
	
	
	if(school_id == 0){
	}else{
		school_id = myGetSchool_Id();
	}
	
	showVideoPlayList(video_id, country_id, school_id, view_page, 'video-playlist-container');
}

function myChangeFilterCountry(video_id, view_page, filter_type){
	country_id = myGetCountry_Id();
	
	//set the School_ID Drop down to selected index = 0;
	//changing a country automaticically sets school to zero.
	if(document.getElementById("dd_school") != null){
		document.getElementById("dd_school").selectedIndex = 0;
	}

	//changeCountrySignup(country , '', 'txtSchoolDropDown','');
	showSchoolFilterListDropDownByCountry(country_id,video_id, view_page, filter_type, 'txtSchoolList');
}

//******************************************************************
//   				VIDEO SEARCH
//******************************************************************

function myGetVideo_Id(){
	//Get the School ID
	if(document.getElementById("txtVideo_Id") != null){
		video_id = document.getElementById("txtVideo_Id").value;
	}else{
		video_id = 0;
	}
	return video_id;
}

function myGetSchool_Id(){
	//Get the School ID
	if(document.getElementById("dd_school") != null){
		school_index = document.getElementById("dd_school").selectedIndex;
		school_id = document.getElementById("dd_school").options[school_index].value;
		if(school_id.substring(0,1) == "C"){
			school_id = 0;
		}
	}else{
		school_id = 0;
	}
	return school_id;
}

function myGetCountry_Id(){
	//Get the Country ID
	if(document.getElementById("dd_country") != null){
		country_index = document.getElementById("dd_country").selectedIndex;
		country_id = document.getElementById("dd_country").options[country_index].value;
	}else{
		country_id = 0;
	}
	return country_id;
}

function myGetCity_Id(){
	//Get the City ID
	//Note: the city_id is in the School Drop Down, but it begins with a 'C'
	if(document.getElementById("dd_school") != null){
		city_index = document.getElementById("dd_school").selectedIndex;
		city_id = document.getElementById("dd_school").options[city_index].value;
		if(city_id.substring(0,1) == "C"){
			city_id = city_id.substring(1);
		}else{	
			city_id = 0
		}
	}else{
		city_id = 0;
	}
	return city_id;
}

function myShowSearchVideoForm(){
	video_id = myGetVideo_Id();
	country_id = myGetCountry_Id();
	school_id = myGetSchool_Id();
	view_page = 1;
	
	search_text = document.getElementById("txtVideoSearchText").value
	showSearchVideoForm(search_text, video_id, country_id, school_id, view_page, 'txtPageContent')
}

function myVideoSearch(search_name,view_page){

	var video_id = myGetVideo_Id();
	var country_id = myGetCountry_Id();
	var city_id = myGetCity_Id();
	var school_id = myGetSchool_Id();
	
	//alert("city:" + city_id + " School:" + school_id);
	
	if(view_page > 1){
	}else{
		view_page = 1;
	}
 
	  if(search_name > ''){
			document.getElementById("txtVideoSearchText").value = search_name;
	  }else{
			//Get Search_Name from text box
			search_name = document.getElementById("txtVideoSearchText").value
	  }
	  
	  //if(search_name > ''){
	  searchVideo(search_name, video_id, country_id, city_id, school_id, 0, 15, view_page, 'txtVideoSearchResults');
      clearLiveVideoSearch();
	  //}
  

}

function clearLiveVideoSearch(){
	 var hint_div = document.getElementById('txtVideoSearchHint');
	 if(hint_div != null){
		hint_div.innerHTML="";
		hint_div.style.width="0px";
		hint_div.style.padding="0px";
	 }

}

//******************************************************************
//   				Gallery Shop Search
//******************************************************************
function myGalleryShopSearch(search_name,view_page){

	var video_id = myGetVideo_Id();
	var country_id = myGetCountry_Id();
	var city_id = myGetCity_Id();
	var school_id = myGetSchool_Id();
	var search_name = '';
	
	//alert("city:" + city_id + " School:" + school_id);
	
	if(view_page > 1){
	}else{
		view_page = 1;
	}
 
	 // if(search_name > ''){
	//		document.getElementById("txtVideoSearchText").value = search_name;
	 // }else{
			//Get Search_Name from text box
			//search_name = document.getElementById("txtVideoSearchText").value
	  //}
	  
	  //if(search_name > ''){
	  searchGalleryShop(search_name, country_id, city_id,  0, 15, view_page, 'txtGalleryShopSearch');
      //clearLiveVideoSearch();
	  //}
  

}



//******************************************************************
//   				Singup Form
//******************************************************************
function myGetGenericDropDown_Id(drop_down_id){
	//Get the Drop Down ID
	if(document.getElementById(drop_down_id) != null){
		generic_index = document.getElementById(drop_down_id).selectedIndex;
		generic_id = document.getElementById(drop_down_id).options[generic_index].value;
	}else{
		generic_id = 0;
	}
	return generic_id;
}



function myShowSignupForm(){
    showSignupForm("txtPageContent");
}

function mySchoolPerson(action,person_id){
	//Get the School ID
	school_id = myGetSchool_Id();
	if(school_id > 0 ){
		editSchoolPerson(action,school_id, person_id,"");
	}else{
		editSchoolPerson("DELETE",school_id, person_id,"");
	}
}

function myShowArtistFormFields(){
	showArtistFormFields('txtSignupFormFields');
}

function myShowGalleryFormFields(){
	showGalleryFormFields('txtSignupFormFields');
}


function myPerson(action){

    var valid_entry = true;

	//get the referral_ID (if it was set)
	if(action == "ADD"){
		referral = document.getElementById("txtReferralID")
		if(referral != null){
			referral_id = referral.value;
		}else{
			referral_id = 0;
		}
	}
	
	
	//Check Radio Buttons
	person_type = "Guest";
	//radio_artist = document.getElementById("radioArtist").checked;
	//radio_gallery = document.getElementById("radioGallery").checked;
	
	//if(radio_artist){
		
		radio1_type = document.getElementById("radio-1").checked;
		radio2_type = document.getElementById("radio-2").checked;
		radio3_type = document.getElementById("radio-3").checked;
		radio4_type = document.getElementById("radio-4").checked;
	
		if(radio1_type){
			person_type = "Student";
		}else if(radio2_type){
			person_type = "Faculty";
		}else if(radio3_type){
			person_type = "Alumni";
		}else if(radio4_type){
			person_type = "Other";
		}
	//}else{
	//	person_type = "Gallery";
	//}
	
	//Facebook Stream
	var facebook_stream = -1;
	if(document.getElementById("checkboxFacebookStream") != null){
		facebook_stream = document.getElementById("checkboxFacebookStream").checked;
	}else{
		facebook_stream = 0;
	}
	

    var fname = '';
	var lname = '';
	var phone_number = '';
	var address = '';
	var description = ''
	var organization = ''
	var now_hiring_flag = 0;
	
	//if(person_type == "Gallery"){
	  /*
		fname = document.getElementById("txtGalleryname").value;
		phone_number = document.getElementById("txtPhoneNumber").value;
		address = document.getElementById("txtAddress").value;
		description = document.getElementById("txtDescription").value;
		
		if(action == "EDIT"){
			//Get Now Hiring Flag and Gallery/Tattoo Flag
			var now_hiring_flag = document.getElementById('checkboxNowHiring');
			if(now_hiring_flag != null){
				if(now_hiring_flag.checked == false){
					now_hiring_flag = 0;
				}else{
					 now_hiring_flag = 1;
				}
			}else{
			  now_hiring_flag = 0;
			}
			
			var radio_gallery_type = document.getElementById("radio_gallery_type").checked;
			var radio_tattoo_type = document.getElementById("radio_tattoo_type").checked;
			var radio_other_type = document.getElementById("radio_other_type").checked;
			var gallery_tattoo_flag = 0;
			if(radio_gallery_type){
				gallery_type = 0;
			}else if (radio_tattoo_type){
				gallery_type = 1;
			}else{
				gallery_type = 2;
			}
		}
		
		//alert("Hiring" + now_hiring_flag)
		//alert("Gallery" + gallery_tattoo_flag)
	*/	
	//}else{
	
		gallery_type = 0;
		fname = document.getElementById("txtFirstname").value;
		lname = document.getElementById("txtLastname").value;
		organization =  document.getElementById("txtOrganization").value;
	//}
	
    
	var errorMessage = "";
	

	if(fname == ""){
		valid_entry = false;
		document.getElementById("txtFirstNameError").innerHTML = " First Name Required";
	}else{
		document.getElementById("txtFirstNameError").innerHTML = "";
	}
	
	//if(person_type != "Gallery"){
		if(lname == ""){
			valid_entry = false;
			document.getElementById("txtLastNameError").innerHTML = " Last Name Required";
		}else{
			document.getElementById("txtLastNameError").innerHTML = "";
		}
	//}
	

	//country = document.getElementById("country").value;
	//country = "Canada";
	//country_index = document.getElementById("dd_school").selectedIndex;
  	//country_id = document.getElementById("dd_country").options[country_index].value;
	country_id = myGetGenericDropDown_Id("dd_country");
	if(country_id > 0){
		document.getElementById("txtCountryError").innerHTML = "";
	}else{
		valid_entry = false;
		document.getElementById("txtCountryError").innerHTML = " Country Required";
	}
	
	
	//city =  document.getElementById("txtCity").value;
	
	var website =  document.getElementById("txtWebsite").value;
	

	

	var email = document.getElementById("txtEmailAdd").value;
	//email_check =  document.getElementById("txtEmailCheck").value;
	if(document.getElementById("txtEmailError").innerHTML != " Email in Use. Please enter a new Email Address."){
		//if(email != email_check){
			//valid_entry = false;
			//document.getElementById("txtEmailError").innerHTML = " Email addresses do not match.";
			//alert("Please verrify your email address, they do not match.");
		//}else 
		if(email == ""){
			valid_entry = false;
			document.getElementById("txtEmailError").innerHTML = " Email Required";
		}else{
			document.getElementById("txtEmailError").innerHTML = "";
		}
	}

	
	var password =  document.getElementById("txtPasswordAdd").value;
	//password_check =  document.getElementById("txtPasswordCheck").value;
	//if(password != password_check){
		//valid_entry = false;
		//document.getElementById("txtPasswordError").innerHTML = " Passwords do not match.";
		//alert("Please verrify your passwords, they do not match.");
	//}else 
	if(password == ""){
		valid_entry = false;
		document.getElementById("txtPasswordError").innerHTML = " Password Required";
	}else{
		document.getElementById("txtPasswordError").innerHTML = "";
	}
	
	
	//&& person_type != "Gallery"
	if((action=="ADD" || action == "EDIT") ){
		//Get Gender_ID and Birthday
		var gender_id = myGetGenericDropDown_Id("dd_gender");
		
		if(gender_id > 0){
				document.getElementById("txtGenderError").innerHTML = "";
		}else{
				valid_entry = false;
				document.getElementById("txtGenderError").innerHTML = " Gender Required";
		}
		
		var birth_day = myGetGenericDropDown_Id("dd_day");
		var birth_month = myGetGenericDropDown_Id("dd_month");
		var birth_year = myGetGenericDropDown_Id("dd_year");
		if(birth_day > 0 && birth_month > 0 && birth_year > 0){
				document.getElementById("txtBirthdayError").innerHTML = "";
				birth_date = String(birth_year) + "-" + String(birth_month) + "-" + String(birth_day)
		}else{
				valid_entry = false;
				document.getElementById("txtBirthdayError").innerHTML = " Birthday Required";
		}
	
	
	}else{
		var gender_id = 0;
		var birth_date = '';
		
	}
	
	
	//Get City (if set)
	//radio_city_checked = document.getElementById("radio_city").checked;
	//if(radio_city_checked){
		var city_id = myGetGenericDropDown_Id("dd_city");
		var school_id = myGetGenericDropDown_Id("dd_school");
	//}else{
	//	city_id = 0;
	//}
	if(city_id > 0 || school_id > 0){
		document.getElementById("txtSchoolCityError").innerHTML = "";
	}else{
		valid_entry = false;
		document.getElementById("txtSchoolCityError").innerHTML = " Required";
	}
	
	
	var photo_certify = document.getElementById('checkboxPhotoCertify');
	if(photo_certify != null){
		if(photo_certify.checked == false){
			 photo_certify = 0;
		}else{
			 photo_certify = 1;
		}
	}else{
	  photo_certify = 0;
	}
	
	var check_watermark = document.getElementById('checkboxWatermark');
	if(check_watermark != null){
		if(check_watermark.checked == false){
			 watermark_flag = 0;
		}else{
			 watermark_flag = 1;
		}
	}else{
	  watermark_flag = 0;
	}
	
	var check_critique = document.getElementById('checkboxCritique');
	if(check_critique != null){
		if(check_critique.checked == false){
			 email_critique_flag = 0;
		}else{
			 email_critique_flag = 1;
		}
	}else{
	  email_critique_flag = 0;
	}
	
	if(action=="EDIT"){
	    //Grab Person_ID and Profile for EDit.
		person_id = document.getElementById("txtPerson_id").value;
		profile = document.getElementById('txtProfile').value;
	}
	
	//Check Form Validaion
	var emailError = document.getElementById("txtEmailError").innerHTML
	if(emailError > ""){
		valid_entry = false;
		errorMessage = emailError;
	}
	
	var passwordError = document.getElementById("txtPasswordError").innerHTML
	if(passwordError > ""){
		valid_entry = false;
		errorMessage = passwordError;
	}
	
	
	if(valid_entry == true){
	  document.getElementById("saved").innerHTML = "";
	    if(action=="ADD"){
		
			personSignup(person_type, fname, lname, 0, 0, city_id, organization, website, email, password, gender_id, birth_date,phone_number,address,description, referral_id, "");
			//Note: PersonSingup Calls mySchoolPerson after the Insert
		}else if(action=="EDIT"){
		    editPersonProfile(person_id, person_type, fname, lname, 0, 0, city_id, organization, website, email, password, profile, gender_id, birth_date, photo_certify, watermark_flag, email_critique_flag, phone_number,address,description, now_hiring_flag, gallery_type,facebook_stream,"");
			mySchoolPerson("EDIT",person_id);
					
		}
	}else{
		document.getElementById("saved").innerHTML = "Please correct your Form Errors.";
		//alert("Please correct your Form Errors.")
    }	
}


//******************************************************************
//      Invite a Friend
//******************************************************************
function myInviteAFriend(){
	var InviteFriends = '';
	var InviteSubjet = '';
	var InviteMessage = '';
	
	var txtInviteFriends = document.getElementById("txtInviteFriends")
	if(txtInviteFriends != null){
		InviteFriends = txtInviteFriends.value;
	}
	var txtInviteSubject = document.getElementById("txtInviteSubject")
	if(txtInviteSubject != null){
		InviteSubject = txtInviteSubject.value;
	}
	var txtInviteMessage = document.getElementById("txtInviteMessage")
	if(txtInviteMessage != null){
		InviteMessage = txtInviteMessage.value;
	}
	
	invitePerson(InviteFriends, InviteSubject, InviteMessage, "txtInviteResult")
	
	//Clear the Email Addresses
	txtInviteFriends.value = '';
	
	
}


//******************************************************************
//   				Vote for Art
//******************************************************************

function myVote(artist_id){
	addVote(artist_id,'vote_icon');
}


/*
function myShowFlags(){
	country_index = document.getElementById("dd_country").selectedIndex;
  	country = document.getElementById("dd_country").options[country_index].value;

	province_index = document.getElementById("dd_province").selectedIndex;
  	province = document.getElementById("dd_province").options[province_index].value;
	
	showFlags(country, province ,'txt_country_flag','txt_province_flag','');
}
*/

function myChangeCountry(){
	//country_index = document.getElementById("dd_country").selectedIndex;
  	//country = document.getElementById("dd_country").options[country_index].value;
    country_id = myGetGenericDropDown_Id("dd_country");
	
	//changeCountrySignup(country , '', 'txtSchoolDropDown','');
	
	//Determine Which List is Active
	if(document.getElementById('dd_city') != null){
		showCityListDropDownByCountry(country_id,'txtSchoolList');
	}else{
		showSchoolListDropDownByCountry(country_id,'txtSchoolList');
	}
}

function myChangeSchoolCityDropDown(type){
    country_id = myGetGenericDropDown_Id("dd_country");
	if(type == "SCHOOL"){
			showSchoolListDropDownByCountry(country_id,'txtSchoolList');
	}else if (type == "CITY"){
			showCityListDropDownByCountry(country_id,'txtSchoolList');
	}

}



/*
function myChangeProvince(){
	province_index = document.getElementById("dd_province").selectedIndex;
  	province = document.getElementById("dd_province").options[province_index].value;
	changeProvince(province ,'txt_province_flag','');
}
*/



function clearArtForm(){
  //Clear all the Fields on the Forum

  document.getElementById("txtArtID").value = "";
  FileName = document.getElementById("txtFileName");
  if(FileName != null){

    document.getElementById("txtArtName").value = "";
    document.getElementById("txtFileName").value = "";
    document.getElementById("txtFileType").value = "";
    document.getElementById("txtThumbnailFilename").value = "";
    document.getElementById("txtSizeX").value = "";
    document.getElementById("txtSizeY").value = "";
    document.getElementById("txtSizeZ").value = "";
    document.getElementById("txtPrice").value = "";
    document.getElementById("txtForSale").value = "";
    
    if(document.getElementById("chkForSaleFlag").checked){
      document.getElementById("chkForSaleFlag").click();
    }

    //Clear flags
    document.getElementById("dd_medium").selectedIndex = 0;

   }


}




function myShowMaterialLists(action){
	
	art_id  = document.getElementById("txtArtID").value;
	
	//showArtMaterialAddForm(art_id, "txt_material_add_list")			
	//showArtMaterialDeleteForm(art_id, "txt_material_delete_list")
	showArtMaterialSelectForm(art_id, "txt_material_add_list")
	

}

function myShowKeywordLists(action){
	
	art_id  = document.getElementById("txtArtID").value;
				
	showArtKeywordAddForm(art_id, "txt_keyword_add_list")
	showArtKeywordDeleteForm(art_id, "txt_keyword_delete_list")

}

function myShowMediumTypeLists(action){
	
	art_id  = document.getElementById("txtArtID").value;
				
	medium_index = document.getElementById("dd_medium").selectedIndex;
  	medium_id = document.getElementById("dd_medium").options[medium_index].value;

	//showMediumForm(art_id,"txt_medium_form");
	
	//showArtMediumTypeAddForm(art_id, medium_id, "txt_medium_type_add_list")		
	//showArtMediumTypeDeleteForm(art_id, medium_id,  "txt_medium_type_delete_list")
	showArtMediumTypeSelectForm(art_id, medium_id,  "txt_medium_type_add_list")
	

}

function myAddArtMaterial(material_id){

	art_id = document.getElementById("txtArtID").value;
	editArtMaterial("ADD", art_id, material_id,'')
}

function myDeleteArtMaterial(material_id){

	art_id = document.getElementById("txtArtID").value;
	editArtMaterial("DELETE", art_id, material_id,'')

}

function mySelectArtMaterial(material_id){

	art_id = document.getElementById("txtArtID").value;
	editArtMaterial("SELECT", art_id, material_id,'')

}

function myAddArtKeyword(keyword){

	art_id = document.getElementById("txtArtID").value;
	keyword = document.getElementById("txt_add_keyword").value;
	editArtKeywords("ADD", 0, art_id, keyword,'')
}

function myDeleteArtKeyword(art_keyword_id){

	art_id = document.getElementById("txtArtID").value;
	editArtKeywords("DELETE", art_keyword_id, art_id, '' ,'')

}

function mySelectArtMediumType(medium_type_id){

	art_id = document.getElementById("txtArtID").value;
	keyword = document.getElementById("txt_add_keyword").value;
	editArtMediumType("SELECT", art_id, medium_type_id, '')
}

function myAddArtMediumType(medium_type_id){

	art_id = document.getElementById("txtArtID").value;
	keyword = document.getElementById("txt_add_keyword").value;
	editArtMediumType("ADD", art_id, medium_type_id, '')
}


function myDeleteArt(art_id,previous_art_id,page_number){

    //var answer = confirm("Delete this Artwork ?")
	myDeleteArtID = art_id;
	myDeleteArtPreviousID = previous_art_id
	myDeleteArtPreviousPage = page_number;

	myDeleteArtPrompt();
	//if(art_id > 0 && answer){
	//	deleteArt(art_id,previous_art_id, 'txtPageContent')
		//showDescribeWork(previous_art_id,0,'txtPageContent')
	//}
}



function myDeleteArtMediumType(medium_type_id){

    

	art_id = document.getElementById("txtArtID").value;
	editArtMediumType("DELETE", art_id, medium_type_id ,'')
	

}

function myDeleteColor(art_id, color_id){
	editArtColor("DELETE",art_id,color_id,'txt_color_list');
}

function myClearLoginForm(){

    //Clear all the Fields on the Forum
    document.getElementById("txtEmail").value = "";
    document.getElementById("txtPassword").value = "";

}


function mySlideThumbnail(art_id){

	//This is Called when the user uses the New Slide Viewr
	$("#txtArtID").val(art_id);

	showShowArtBreadCrumb(art_id,  'txtBreadCrumb')
	showCritiques(art_id, 'critique_comments');
	showArtRightDescription(art_id, 'txtArtInfo');
	dhtmlHistory.add('ShowArt:' + art_id, art_id);	   
}




function myArt() {

  var validEntry = true;
  var action = "";
  
  var art_id = document.getElementById("txtArtID").value;

  if (art_id > 0){
     action = 'EDIT';
  }else{
     action = 'ADD';	
  }
  
  var person_id = 1;

  //medium_index = document.getElementById("dd_medium").selectedIndex;
  //medium_id = document.getElementById("dd_medium").options[medium_index].value;
  
  var art_name = document.getElementById("txtArtName").value;
  //art_file_name = document.getElementById("txtArtFileName").value;
  //art_file_type = document.getElementById("txtArtFileType").value;
  //thumbnail_filename = document.getElementById("txtThumbnailFilename").value;
  
  var size_x = document.getElementById("txtSizeX").value;
  var size_y = document.getElementById("txtSizeY").value;
  var size_z = document.getElementById("txtSizeZ").value;
  var price = document.getElementById("txtPrice").value;

  //forsale_flag = document.getElementById("aForSale").checked;
  var forsale_color = document.getElementById("aForSale").style.color;
  if (forsale_color == "rgb(255, 0, 153)"){
	forsale_flag = 1;
  }else{
	forsale_flag = 0;
  }
  
   //Dimensions
	var myDimensionItem1 = document.getElementById("imgEditDimensionID_"  + 1)
	var myDimensionItem2 = document.getElementById("imgEditDimensionID_"  + 2)
	var myDimensionItem3 = document.getElementById("imgEditDimensionID_"  + 3)
	var dimension_id = 0;
	if (myDimensionItem1.className == "active"){dimension_id = 1;}
	if (myDimensionItem2.className == "active"){dimension_id = 2;}
	if (myDimensionItem3.className == "active"){dimension_id = 3;}
  
  //Key Words	
  keywords = document.getElementById("txtKeywords").value;
  
  medium_id = myEditArtMediumID.toString();
  medium_type_id = myEditArtMediumTypeID.toString();
  color_id = myEditArtColorID.toString();
  material_id = myEditArtMaterialID.toString();
  mood_id = myEditArtMoodID.toString();
  genre_id = myEditArtGenreID.toString();
  /*
  if(medium_id > 0){
  }else{
    validEntry = false;
    alert("Medium Required.  Please Select a Medium");
  }
  */

  if (validEntry == true){
      if (art_id > 0){
        //editArt(action, art_id, person_id, medium_id, 'Photo',art_name, art_file_name, art_file_type, thumbnail_filename, size_x, size_y, size_z, price, forsale_flag, '', '')
        editArt(action, art_id, person_id, medium_id, 'Photo',art_name, '', '', '', size_x, size_y, size_z, dimension_id, price, forsale_flag, '', '');
		editKeywords(art_id, keywords);
		editArtColors(art_id,color_id);
		editArtMaterials(art_id,material_id);
		editArtMoods(art_id,mood_id);
		editArtGenres(art_id,genre_id);
		editArtMediumTypes(art_id,medium_type_id);
	  }
  }
}

function myGallery() {

  var validEntry = true;

  person_id = document.getElementById("txtUserID").value;
  gallery_id = document.getElementById("txtGalleryID").value;
  gallery_name = document.getElementById("txtGalleryName").value;
  //gallery_description = document.getElementById("txtGalleryDescription").value;
  

  if (gallery_id > 0){
     action = 'EDIT';
  }else{
     action = 'ADD';	
  }
 
  
  if (validEntry == true){
      if (gallery_name > ''){
        editGalleries(action, gallery_id, person_id, gallery_name, '', 'txtGalleryDropDown')
		//Clear Entry Fields
		document.getElementById("txtGalleryName").value  = "";
		//document.getElementById("txtGalleryDescription").value = "";
      }
  }
}

function myDeleteGallery(gallery_id){
  //Remove a Gallery
  //person_id = document.getElementById("txtUserID").value;
  myDeleteGalleryID = gallery_id;
  myDeleteGalleryPrompt();
  //var answer = confirm("Delete this Gallery ?");

}

function myDeleteGroup(group_id){
  //Remove a Group
  myDeleteGroupID = group_id;
  myDeleteGroupPrompt();
}

function myShowPersonGalleries(){
   person_id = document.getElementById("txtShowGalleryPersonID").value; 
   gallery_id = document.getElementById("txtShowGalleryGalleryID").value;	
   showPersonGalleries(person_id, gallery_id,"txtPageContent");
}

function myShowGalleries(){
   var txtUserID = document.getElementById("txtUserID");
   if(txtUserID != null){
		person_id = document.getElementById("txtUserID").value; 
		showGalleries(person_id, "txtPageContent");
	}
   
}

function myLogout() {
    cmsLogout();
}

function myLogin(imgLogin) {

  var validEntry = true;
  
  //Set the Login Image to Pink for 1 second.
  //imgLogin.src="images/btn_login_pink.jpg";
  //setTimeout('if(document.getElementById("imgLogonButton") != null){document.getElementById("imgLogonButton").src="images/btn_login.jpg"}',400);


  email = document.getElementById("txtEmail").value;
  password = document.getElementById("txtPassword").value;
  
  if(email == 'email'){
	email = '';
  }
  if(password == 'password'){
	password = '';
  }

  if (validEntry == true){
      //if (email > '' && password > ''){
          cmsLogin(email, password, 'txtLoginResult');
      //}
  }
}

function mySearchMenuMediumTypesSelect(medium_type_id, medium_type_name){
    //Test
	var lblMediumTypesSearch = document.getElementById("lblMediumSearch")
	if (lblMediumTypesSearch != null){
		lblMediumTypesSearch.innerHTML =  medium_type_name;
	}
	
	
	//txtMediumIDSearch = document.getElementById("txtMediumTypesIDSearch")
	//if (txtMediumTypesIDSearch != null){
	//	txtMediumTypesIDSearch.value = medium_id;
		var myMediumTypeListItem = document.getElementById("liMediumTypesID_" + medium_type_id)
	    
		if(myMenuSearchMediumTypesID.length > 0){
		   var previousMediumTypeID = myMenuSearchMediumTypesID[0]
		}	
		
		//Multi Select Code:
		//Determin if Medium ID is already in Array.
		/*
		var findIndex = myMenuSearchMediumTypesID.indexOf(medium_type_id,0);
		if(findIndex >= 0) {
			//Already Exists in Index, Remove it.
			myMenuSearchMediumTypesID.splice(findIndex,1);
			if(myMediumTypeListItem != null){
				myMediumTypeListItem.className = '';
			}
		}else{
			//Does not Exsist, Add it only 
			myMenuSearchMediumTypesID.push(medium_type_id);
			if(myMediumTypeListItem != null){
				
			}
		}
		//checkMediumArray();
		*/
		
		//Single Select Code:
		//New Medium Selected, Clear List of Medium Types
		//UnSelect Previous Itemm;
	    if(myMenuSearchMediumID.length > 0){
			   var previousMediumItem = document.getElementById("liMediumID_"  + myMenuSearchMediumID[0])
			   previousMediumItem.className = '';
		}
		if(myMenuSearchMediumTypesID.length > 0){
		   var previousMediumTypeItem = document.getElementById("liMediumTypesID_"  + myMenuSearchMediumTypesID[0])
		    previousMediumTypeItem.className = '';
		}		
		
		myMenuSearchMediumTypesID = [];
		//Does not Exsist, Add it
		myMenuSearchMediumTypesID.push(medium_type_id);
		myMediumTypeListItem.className = 'active';
	
		//checkMediumArray();
		//if(previousMediumTypeID == medium_type_id){
			//Close the Menu
			$("#menu").accordion( 'activate' , false )
		//}
	
		
	//}
		//Run SEarch as they Click Menu Items
		mySearchArt();
	

}

function mySearchMenuMediumSelect(medium_id, medium_name){
    //Test
	var lblMediumSearch = document.getElementById("lblMediumSearch")
	if (lblMediumSearch != null){
		lblMediumSearch.innerHTML = medium_name;
	}
	var txtMediumIDSearch = document.getElementById("txtMediumIDSearch")
	if (txtMediumIDSearch != null){
		txtMediumIDSearch.value = medium_id;
	
	
	   	if(myMenuSearchMediumID.length > 0){
		   var previousMediumID = myMenuSearchMediumID[0]
		}	
	
	    if(medium_name == 'All'){
		
		    if(myMenuSearchMediumID.length > 0){
			   var previousMediumItem = document.getElementById("liMediumID_"  + myMenuSearchMediumID[0])
			   previousMediumItem.className = '';
			}	
		    if(myMenuSearchMediumTypesID.length > 0){
			   var previousMediumTypesItem = document.getElementById("liMediumTypesID_"  + myMenuSearchMediumTypesID[0])
			   previousMediumTypesItem.className = '';
			}	
		   //Reset Array
		   //alert("reset Medium");
		   myMenuSearchMediumID = [];
		   myMenuSearchMediumTypesID = [];
		   
		   document.getElementById("liMediumID_0").className = "active";
		   myMenuSearchMediumID.push(0);
		   
			var lblMediumTypesSearch = document.getElementById("lblMediumTypesSearch")
			if (lblMediumTypesSearch != null){
				lblMediumTypesSearch.innerHTML = "";
			}
		    lblMediumSearch.style.color = "#000000";
			lblMediumSearch.style.fontWeight = "normal";
		}else{
		    lblMediumSearch.style.color = "#FF0099";
			lblMediumSearch.style.fontWeight = "bold";
		
		    if(myMenuSearchMediumID.length > 0){
			   var previousMediumItem = document.getElementById("liMediumID_"  + myMenuSearchMediumID[0])
			   previousMediumItem.className = '';
			}	
		    if(myMenuSearchMediumTypesID.length > 0){
			   var previousMediumTypesItem = document.getElementById("liMediumTypesID_"  + myMenuSearchMediumTypesID[0])
			   previousMediumTypesItem.className = '';
			}	
		
			//New Medium Selected, Clear List of Medium Types
			myMenuSearchMediumID = [];
			myMenuSearchMediumTypesID = [];
			
			var myMediumListItem = document.getElementById("liMediumID_" + medium_id)
			myMediumListItem.className = "active";
			
			
			//Does not Exsist, Add it
			myMenuSearchMediumID.push(medium_id);
	
			//checkMediumArray();
		}
		
		
	}
	
	   if(previousMediumID == medium_id || medium_id == 0){
			//Close the Menu
			$("#menu").accordion( 'activate' , false )
		}
	
		//Run SEarch as they Click Menu Items
		mySearchArt();
	

}

function mySearchMenuMaterialSelect(material_id, material_name){
	var lblMaterialSearch = document.getElementById("lblMaterialSearch")
	if (lblMaterialSearch != null){
		lblMaterialSearch.innerHTML = material_name;
	}
	//var txtMaterialIDSearch = document.getElementById("txtMaterialIDSearch")
	//if (txtMaterialIDSearch != null){
	
		if(myMenuSearchMaterialID.length > 0){
		   var previousMaterialID = myMenuSearchMaterialID[0]
		}	
	
	    if(material_name == 'All'){
		
		    //UnSelect Previous Itemm;
			if(myMenuSearchMaterialID.length > 0){
			   var previousMaterialItem = document.getElementById("liMaterialID_"  + myMenuSearchMaterialID[0])
			   previousMaterialItem.className = '';
			}	
		   //Reset Array
		   //alert("reset Material");
		   myMenuSearchMaterialID = [];
		   document.getElementById("liMaterialID_0").className = "active";
		   myMenuSearchMaterialID.push(0);
		   //showMaterialSearchMenu('txtSearchMenuMaterialList');
		   	lblMaterialSearch.style.color = "#000000";
			lblMaterialSearch.style.fontWeight = "normal";
		
		}else{
			//txtMaterialIDSearch.value = material_id;
			lblMaterialSearch.style.color = "#FF0099";
			lblMaterialSearch.style.fontWeight = "bold";
			
			var myMaterialListItem = document.getElementById("liMaterialID_" + material_id)
		
		
		    //Multi Select Code:
			//Determin if Material ID is already in Array.
			var findIndex = myMenuSearchMaterialID.indexOf(material_id,0);
			if(findIndex >= 0) {
				//Already Exists in Index, Remove it.
				myMenuSearchMaterialID.splice(findIndex,1);
				if(myMaterialListItem != null){
					myMaterialListItem.className = '';
				}	
			}else{
				//Does not Exsist, Add it
				myMenuSearchMaterialID.push(material_id);
				if(myMaterialListItem != null){
					myMaterialListItem.className = 'active';
				}
			}
			
			//Single Select Code:
			//New Medium Selected, Clear List of Medium Types
			//UnSelect Previous Itemm;
			if(myMenuSearchMaterialID.length > 0){
			   var previousMaterialItem = document.getElementById("liMaterialID_"  + myMenuSearchMaterialID[0])
				previousMaterialItem.className = '';
			}		
			
			myMenuSearchMaterialID = [];
			//Does not Exsist, Add it
			myMenuSearchMaterialID.push(material_id);
			myMaterialListItem.className = 'active';
		
		//checkMaterialArray();
		}
	//}
	
		//if(previousMaterialID == material_id){
			//Close the Menu
			$("#menu").accordion( 'activate' , false )
		//}
	
		//Run SEarch as they Click Menu Items
		mySearchArt();
	
}

function mySearchMenuMoodSelect(mood_id, mood_name){
	var lblMoodSearch = document.getElementById("lblMoodSearch")
	if (lblMoodSearch != null){
		lblMoodSearch.innerHTML = mood_name;
	}
	var txtMoodIDSearch = document.getElementById("txtMoodIDSearch")
	if (txtMoodIDSearch != null){
	
			if(myMenuSearchMoodID.length > 0){
			   var previousMoodID = myMenuSearchMoodID[0];
			}	
	
	    if(mood_name == 'All'){
		   //Reset Array
		   //alert("reset mood");
		   	if(myMenuSearchMoodID.length > 0){
			   var previousMoodItem = document.getElementById("liMoodID_"  + myMenuSearchMoodID[0])
			   previousMoodItem.className = '';
			}	
		   myMenuSearchMoodID = [];
		   document.getElementById("liMoodID_0").className = "active";
		   myMenuSearchMoodID.push(0);
		   //showMoodSearchMenu('txtSearchMenuMoodList');
		   lblMoodSearch.style.color = "#000000";
		   lblMoodSearch.style.fontWeight = "normal";
		
		}else{
			txtMoodIDSearch.value = mood_id;
			lblMoodSearch.style.color = "#FF0099";
			lblMoodSearch.style.fontWeight = "bold";
			var myMoodListItem = document.getElementById("liMoodID_" + mood_id)
				
			//Single Select Code:
			//New Medium Selected, Clear List of Medium Types
			//UnSelect Previous Itemm;
			if(myMenuSearchMoodID.length > 0){
			   var previousMoodItem = document.getElementById("liMoodID_"  + myMenuSearchMoodID[0])
				previousMoodItem.className = '';
			}		
			
			myMenuSearchMoodID = [];
			//Does not Exsist, Add it
			myMenuSearchMoodID.push(mood_id);
			myMoodListItem.className = 'active';
		
		//checkmoodArray();
		}
	}
	
	    //if(previousMoodID == mood_id){
			//Close the Menu
			$("#menu").accordion( 'activate' , false )
		//}
	
	
		//Run SEarch as they Click Menu Items
		mySearchArt();
	
}

function mySearchMenuGenreSelect(genre_id, genre_name){
	var lblGenreSearch = document.getElementById("lblGenreSearch")
	if (lblGenreSearch != null){
		lblGenreSearch.innerHTML = genre_name;
	}
	var txtGenreIDSearch = document.getElementById("txtGenreIDSearch")
	if (txtGenreIDSearch != null){
	
		if(myMenuSearchGenreID.length > 0){
			   var previousGenreID =  myMenuSearchGenreID[0];
		}
	
	    if(genre_name == 'All'){
		
			//UnSelect Previous Itemm;
			if(myMenuSearchGenreID.length > 0){
			   var previousGenreItem = document.getElementById("liGenreID_"  + myMenuSearchGenreID[0])
				previousGenreItem.className = '';
			}	
		   //Reset Array
		   //alert("reset genre");
		   myMenuSearchGenreID = [];
		   document.getElementById("liGenreID_0").className = "active";
		   myMenuSearchGenreID.push(0);
		   //showGenreSearchMenu('txtSearchMenuGenreList');
		   	lblGenreSearch.style.color = "#000000";
			lblGenreSearch.style.fontWeight = "normal";
		}else{
			lblGenreSearch.style.color = "#FF0099";
			lblGenreSearch.style.fontWeight = "bold";
			
			txtGenreIDSearch.value = genre_id;
			
			var myGenreListItem = document.getElementById("liGenreID_" + genre_id)
		
	
			//Single Select Code:
			//New Medium Selected, Clear List of Medium Types
			//UnSelect Previous Itemm;
			if(myMenuSearchGenreID.length > 0){
			   var previousGenreItem = document.getElementById("liGenreID_"  + myMenuSearchGenreID[0])
				previousGenreItem.className = '';
			}		
			
			myMenuSearchGenreID = [];
			//Does not Exsist, Add it
			myMenuSearchGenreID.push(genre_id);
			myGenreListItem.className = 'active';
		
		//checkgenreArray();
		}
	}
	
	 
	    //if(previousGenreID == genre_id){
			//Close the Menu
			$("#menu").accordion( 'activate' , false )
		//}
	
		//Run SEarch as they Click Menu Items
		mySearchArt();
		
		
	
}



/*
function mySearchMenuCountrySelect(country_id, country_name){
	var lblCountrySearch = document.getElementById("lblCountrySearch");
	if (lblCountrySearch != null){
		lblCountrySearch.innerHTML = country_name;
	}
	var txtCountryIDSearch = document.getElementById("txtCountryIDSearch");
	if (txtCountryIDSearch != null){
	
	    if(country_name == 'All'){
		   //Reset Array
		   //alert("reset Material");
		   myMenuSearchCountryID = [];
		   showCountrySearchMenu('txtSearchMenuLocationList');
		   
		}else{
			txtCountryIDSearch.value = country_id;
			
			var myCountryListItem = document.getElementById("liCountryID_" + country_id);
		
			//Determin if Country ID is already in Array.
			var findIndex = myMenuSearchCountryID.indexOf(country_id,0);
			if(findIndex >= 0) {
				//Already Exists in Index, Remove it.
				myMenuSearchCountryID.splice(findIndex,1);
				if(myCountryListItem != null){
					myCountryListItem.className = '';
				}	
			}else{
				//Does not Exsist, Add it
				myMenuSearchCountryID.push(country_id);
				if(myCountryListItem != null){
					myCountryListItem.className = 'active';
				}
			}
		
		//checkMaterialArray();
		}
	}
	
}
*/

function mySearchMenuDimensionSelect(dimension_id, dimension_name){
	var lblDimensionSearch = document.getElementById("lblDimensionSearch")
	
	if (lblDimensionSearch != null){
	    if(dimension_name == "All"){
			lblDimensionSearch.innerHTML = dimension_name;
			
		}else{
		    lblDimensionSearch.innerHTML = '<img src="images/icon_' + dimension_name.toLowerCase() + '_sm.gif" />';
			
		}
	}
	var txtDimensionIDSearch = document.getElementById("txtDimensionIDSearch")
	if (txtDimensionIDSearch != null){
	
	    if(myMenuSearchDimensionID.length > 0){
			   var previousDimensionID =  myMenuSearchDimensionID[0];
		}
	
	    if(dimension_name == 'All'){
		    if(myMenuSearchDimensionID.length > 0){
			   var previousDimensionItem = document.getElementById("imgDimensionID_"  + myMenuSearchDimensionID[0])
				previousDimensionItem.className = '';
			}		
		   //Reset Array
		   //alert("reset Material");
		   myMenuSearchDimensionID = []
		   document.getElementById("imgDimensionID_0").className = "active";
		   myMenuSearchDimensionID.push(0);
		   
		   var myDimensionListItem1 = document.getElementById("imgDimensionID_1")
		   var myDimensionListItem2 = document.getElementById("imgDimensionID_2")
		   var myDimensionListItem3 = document.getElementById("imgDimensionID_3")
		   
		   myDimensionListItem1.className = ''; 
		   myDimensionListItem2.className = '';
		   myDimensionListItem3.className = '';
		   
		   //showDimensionSearchMenu('txtSearchMenuMaterialList');
		}else{
			txtDimensionIDSearch.value = dimension_id;
			
			var myDimensionListItem = document.getElementById("imgDimensionID_" + dimension_id)
		
	        //Multi Select Code:	
			//Determin if Dimension ID is already in Array.
			//var findIndex = myMenuSearchDimensionID.indexOf(dimension_id,0);
			//if(findIndex >= 0) {
				//Already Exists in Index, Remove it.
			//	myMenuSearchDimensionID.splice(findIndex,1);
			//	if(myDimensionListItem != null){
			//		myDimensionListItem.className = '';
			//	}	
			//}else{
			//	//Does not Exsist, Add it
			//	myMenuSearchDimensionID.push(dimension_id);
			//	if(myDimensionListItem != null){
			//		myDimensionListItem.className = 'active';
			//	}
			//}
		 
		    //Single Select Code:
			//New Dimension Selected, Clear List of Dimensions
			//UnSelect Previous Itemm;
			if(myMenuSearchDimensionID.length > 0){
			   var previousDimensionItem = document.getElementById("imgDimensionID_"  + myMenuSearchDimensionID[0])
				previousDimensionItem.className = '';
			}		
			
			myMenuSearchDimensionID = [];
			//Does not Exsist, Add it
			myMenuSearchDimensionID.push(dimension_id);
			myDimensionListItem.className = 'active';
		
		
		
		//checkDimensionArray();
		}
	}
		//if(previousDimensionID == dimension_id){
			//Close the Menu
			$("#menu").accordion( 'activate' , false )
		//}
	
		//Run SEarch as they Click Menu Items
		mySearchArt();
	
}


function mySearchMenuPriceSelect(price_name){
	
	
	var txtPriceSearchMin = document.getElementById("txtPriceMin").value
	var txtPriceSearchMax = document.getElementById("txtPriceMax").value
	
	
	var lblPriceSearch = document.getElementById("lblPriceSearch")
	
	/*
	if(price_name == 'All'){
	   //Reset Array
	   //alert("reset Material");
	   
	   	if (lblPriceSearch != null){
		    //lblPriceSearch.innerHTML = price_name;
	    }
	   myMenuSearchMinPrice = 0;
	   myMenuSearchMaxPrice = 0;
	   
	   document.getElementById("txtPriceMin").value = "0";
	   document.getElementById("txtPriceMax").value = "0";
	   
	   //showDimensionSearchMenu('txtSearchMenuMaterialList');
	}else{
	*/
	
	    if (isNaN(txtPriceSearchMin) == false ){
	   	   myMenuSearchMinPrice = txtPriceSearchMin;
		}
		 
		if (isNaN(txtPriceSearchMax) == false){
		   myMenuSearchMaxPrice = txtPriceSearchMax;
		}
		  
		if (lblPriceSearch != null){
		    lblPriceSearch.innerHTML = '$' + myMenuSearchMinPrice.toString() + ' - $' + myMenuSearchMaxPrice.toString()
	    }
		
		//Set the Colors
		if(myMenuSearchMinPrice >= 0 || myMenuSearchMaxPrice > 0){
			lblPriceSearch.style.color = "#FF0099";
			lblPriceSearch.style.fontWeight = "bold";
		}else{
			lblPriceSearch.style.color = "#000000";
			lblPriceSearch.style.fontWeight = "normal";
			lblPriceSearch.innerHTML = "All";
		}

	//checkDimensionArray();
	//}
	
	//Run SEarch as they Click Menu Items
	mySearchArt();
	
	
}


function mySearchMenuColorSelect(list_item, color_id, color_name){
	var lblColorSearch = document.getElementById("lblColorSearch")
	
		if(myMenuSearchColorID.length > 0){
			  var previousColorID =  myMenuSearchColorID[0];
		}

	//var txtColorIDSearch = list_item
	//if (list_item != null){
	
	    if(color_name == 'All'){
		
		 //UnSelect Previous Itemm;
			if(myMenuSearchColorID.length > 0){
			   var previousColorItem = document.getElementById("liColorID_"  + myMenuSearchColorID[0])
				previousColorItem.className = '';
			}
		   //Reset Array
		   //alert("reset Material");
		   myMenuSearchColorID = [];
		   myMenuSearchColorName = [];
		   myMenuSearchColorID.push(0);
		   //showColorSearchMenu('txtSearchMenuColorList');
		   lblColorSearch.innerHTML = "All";
		   //lblColorSearch.style.color = "#000000";
		
		}else{
		   //lblColorSearch.style.color = "#FF0099";

			//txtColorIDSearch.value = color_id;
			
			var myColorListItem = document.getElementById("liColorID_" + color_id)
		
			//Mutli Select Code:
			//Determin if Color ID is already in Array.
			/*
			var findIndex = myMenuSearchColorID.indexOf(color_id,0);
			if(findIndex >= 0) {
				//Already Exists in Index, Remove it.
				myMenuSearchColorID.splice(findIndex,1);
			}else{
				//Does not Exsist, Add it
				myMenuSearchColorID.push(color_id);
			}
			
			//Determin if Color Name is already in Array
			var findIndexName = myMenuSearchColorName.indexOf(color_name,0);
			if(findIndexName >= 0) {
				//Already Exists in Index, Remove it.
				myMenuSearchColorName.splice(findIndexName,1);
				
				//Removing Item from Array Need to Pick another Item from array to Display in Search Box.
				if(myMenuSearchColorName.length > 0){
				     //Display the Last item in the list
					 //lblColorSearch.innerHTML = myMenuSearchColorName.toString();
				}else{
				     //No Items left in Array, default back to All Items.
					 //lblColorSearch.innerHTML = "All";
				}
			}else{
				//Does not Exsist, Add it
				myMenuSearchColorName.push(color_name);
				//lblColorSearch.innerHTML = color_name;
				//lblColorSearch.innerHTML = myMenuSearchColorName.toString();
			}
			*/
			
			
			//Single Select Code:
			//New Dimension Selected, Clear List of Dimensions
			//UnSelect Previous Itemm;
			if(myMenuSearchColorID.length > 0){
			   var previousColorItem = document.getElementById("liColorID_"  + myMenuSearchColorID[0])
				previousColorItem.className = '';
			}		
			
			myMenuSearchColorID = [];
			//Does not Exsist, Add it
			myMenuSearchColorID.push(color_id);
			myColorListItem.className = 'active';
			//lblColorSearch.innerHTML = color_name;
			mycolor_name = color_name.replace(" ","");
			mycolor_name = mycolor_name.toLowerCase();
			lblColorSearch.innerHTML = '<img src="images/color_' + mycolor_name + '.gif" />'
				
			
		//checkMaterialArray();
		}
		
		//alert(previousColorID + ":" + color_id)
		//if(previousColorID == color_id){
			//Close the Menu
			$("#menu").accordion( 'activate' , false )
		//}
		
		//Run SEarch as they Click Menu Items
		mySearchArt();
	//}
	
}

function mySearchMenuContinentSelect(continent_id){

   myMenuSearchContinentID = continent_id;
   myMenuSearchSchoolID = 0;
   showSearchMenuLocation(continent_id,'txtMenuSearchLocation')
   mySearchArt();

}

function mySearchMenuSchoolSelect(dd_school){

  school_index = dd_school.selectedIndex;
  school_id = dd_school.options[school_index].value;

   myMenuSearchSchoolID = school_id;
   mySearchArt();

}

function myEditArtColorSelect(list_item, color_id){

            //convert color_id to string becuase it is load in the array as a string;  
            color_id = color_id.toString();

			//Determin if Color ID is already in Array.
			var findIndex = myEditArtColorID.indexOf(color_id,0);
			if(findIndex >= 0) {
				//Already Exists in Index, Remove it.
				myEditArtColorID.splice(findIndex,1);
				//alert('remove')
				list_item.className = '';
			}else{
				//Does not Exsist, Add it
				//alert('add')
				//Make sure that only 4 can be selected at once.
				if(myEditArtColorID.length > 3){
					//Sorry you have reached the Maximum number of Colors to Select
				}else{
					myEditArtColorID.push(color_id);
					list_item.className = 'active';
				}
				
			}
			
}

function myEditArtMediumSelect(list_item, medium_id){

            //convert medium_id to string becuase it is load in the array as a string;  
            medium_id = medium_id.toString();

			if(myEditArtMediumID.length > 0){
			   var previousMediumItem = document.getElementById("liEditMediumID_"  + myEditArtMediumID[0])
			   if(previousMediumItem != null){
					previousMediumItem.className = '';
			   }
			}	
			myEditArtMediumID = [];
			//Clear the Previous Medium Types as they do no Relate to the new Medium that was selected.
			myEditArtMediumTypeID = [];
			
			myEditArtMediumID.push(medium_id);
			list_item.className = 'active';
			
			
			art_id = document.getElementById("txtArtID").value;
			showArtMediumTypeSelectForm(art_id, medium_id, "txtEditArtMediumTypesList")
			
			//alert(myEditArtMediumID.toString())
}


function myEditArtMediumTypesSelect(list_item, medium_type_id){

            //convert medium_type_id to string becuase it is load in the array as a string;  
            medium_type_id = medium_type_id.toString();

		
			//Determine if Material ID is already in Array.
			var findIndex = myEditArtMediumTypeID.indexOf(medium_type_id,0);
			if(findIndex >= 0) {
				//Already Exists in Index, Remove it.
				myEditArtMediumTypeID.splice(findIndex,1);
				//alert('remove')
				list_item.className = '';
			}else{
				//Does not Exsist, Add it
				//alert('add')
				//Make sure that only 20 can be selected at once.
				if(myEditArtMediumTypeID.length > 20){
					//Sorry you have reached the Maximum number of Colors to Select
				}else{
					myEditArtMediumTypeID.push(medium_type_id);
					list_item.className = 'active';
				}
				
			}
				

		
			//alert(myEditArtMediumID.toString())
}

function myEditArtMaterialSelect(list_item, material_id){

            //convert material_id to string becuase it is load in the array as a string;  
            material_id = material_id.toString();

			//Determine if Material ID is already in Array.
			var findIndex = myEditArtMaterialID.indexOf(material_id,0);
			if(findIndex >= 0) {
				//Already Exists in Index, Remove it.
				myEditArtMaterialID.splice(findIndex,1);
				//alert('remove')
				list_item.className = '';
			}else{
				//Does not Exsist, Add it
				//alert('add')
				//Make sure that only 20 can be selected at once.
				if(myEditArtMaterialID.length > 20){
					//Sorry you have reached the Maximum number of Colors to Select
				}else{
					myEditArtMaterialID.push(material_id);
					list_item.className = 'active';
				}
				
			}
			//alert(myEditArtMaterialID.toString())
}

function myEditArtMoodSelect(list_item, mood_id){

            //convert mood_id to string becuase it is load in the array as a string;  
            mood_id = mood_id.toString();

			//Determine if mood ID is already in Array.
			var findIndex = myEditArtMoodID.indexOf(mood_id,0);
			if(findIndex >= 0) {
				//Already Exists in Index, Remove it.
				myEditArtMoodID.splice(findIndex,1);
				//alert('remove')
				list_item.className = '';
			}else{
				//Does not Exsist, Add it
				//alert('add')
				//Make sure that only 20 can be selected at once.
				if(myEditArtMoodID.length > 20){
					//Sorry you have reached the Maximum number of Moods to Select
				}else{
					myEditArtMoodID.push(mood_id);
					list_item.className = 'active';
				}
				
			}
			//alert(myEditArtMoodID.toString())
}

function myEditArtGenreSelect(list_item, genre_id){

            //convert genre_id to string becuase it is load in the array as a string;  
            genre_id = genre_id.toString();

			//Determine if genre ID is already in Array.
			var findIndex = myEditArtGenreID.indexOf(genre_id,0);
			if(findIndex >= 0) {
				//Already Exists in Index, Remove it.
				myEditArtGenreID.splice(findIndex,1);
				//alert('remove')
				list_item.className = '';
			}else{
				//Does not Exsist, Add it
				//alert('add')
				//Make sure that only 20 can be selected at once.
				if(myEditArtGenreID.length > 20){
					//Sorry you have reached the Maximum number of genres to Select
				}else{
					myEditArtGenreID.push(genre_id);
					list_item.className = 'active';
				}
				
			}
			//alert(myEditArtGenreID.toString())
}


function myEditArtDimensionSelect(list_item, dimension_id){

            //convert genre_id to string becuase it is load in the array as a string;  
            dimension_id = dimension_id.toString();
			
			var myDimensionItem1 = document.getElementById("imgEditDimensionID_"  + 1)
			var myDimensionItem2 = document.getElementById("imgEditDimensionID_"  + 2)
			var myDimensionItem3 = document.getElementById("imgEditDimensionID_"  + 3)
			
			myDimensionItem1.className = "";
			myDimensionItem2.className = "";
			myDimensionItem3.className = "";
			
			list_item.className = "active";


}

function myMapContinentSelect(list_item,continent_id,continent_name){

		//if(myMapContinent.length > 0){
		//   var previousContinentID = document.getElementById("liContinentID_"  + myMapContinent[0])
		//	previousContinentID.className = '';
		//}

		//if(list_item != null){
		//	list_item.className = 'active';
		//}else{
		//	document.getElementById("liContinentID_"  + continent_id).className = 'active';
		//}
		
		//myMapContinent = [];
		//myMapContinent.push(continent_id);
		//alert(continent_id);
		
		showContinentsMap(continent_id,"txtContinentMap");
		//showContinentsMap(3,"txtContinentMap");
		//showSchoolListMap(continent_id,"txtSchoolList");
		
}



function checkMaterialArray(){

//var findIndex = myMenuSearchMaterialID.indexOf(10,0);
//if (findIndex > 0){
   //alert("Found 10");
//   myMenuSearchMaterialID.splice(findIndex,1);
//}else{
   //alert("10 Not Found");
//}

//var MaterialList = "";
 //for (var i=0; i< myMenuSearchMaterialID.length; i++) {
//	MaterialList += myMenuSearchMaterialID[i];
 //}
//	alert(MaterialList);
  alert(myMenuSearchMaterialID.toString())
}

function checkMediumArray(){

var MediumList = "";
 for (var i=0; i< myMenuSearchMediumID.length; i++) {
	MediumList += myMenuSearchMediumID[i];
 }
	alert(MediumList);
}


function myViewArt(art_id){
	//Re-Get the location
		CurrentLocation = String(window.location.href);
		var myIndexPos = CurrentLocation.indexOf("art.php");
		var myProfileIndexPos = CurrentLocation.indexOf("profile_art.php");
		//alert(CurrentLocation);
		if(myIndexPos > 0 && myProfileIndexPos <= 0){
			//var myIndexPageNameCheck = CurrentLocation.substr(myIndexPos);
			//alert(CurrentLocation);
			//if(myIndexPageNameCheck == "art.php"){
				//Determine if the Weekly Results already have been Displayed
			//	if(document.getElementById("txtWeeklyResultsFlag") == null){
					//alert("showing");
					//showWeeklyResultsAll('txtPageContent');
			showArt(art_id,0,'txtPageContent');
			//	}
			//}
		}else{
			//myViewArtID = art_id;
			window.location = "art.php#ShowArt:" + art_id;
		}

}




function mySearchArt(pageNumber){

//Get Search Parameters and Call JS Search


	//medium_index = document.getElementById("dd_medium").selectedIndex;
  	//medium_id = document.getElementById("dd_medium").options[medium_index].value;
    medium_id = myMenuSearchMediumID.toString();
	
	//artName = document.getElementById("txtArtName").value;
	var artName = "";
	
	var keyword = "";
	myKeyword = document.getElementById("txtKeywordSearch")
	if(myKeyword != null){
	    keyword = myKeyword.value;
		if(keyword == "enter keywords"){
		   keyword = "";
		}
	}
	//keyword = "";
	
	//medium_type_index = document.getElementById("dd_medium_type").selectedIndex;
  	//medium_type_id = document.getElementById("dd_medium_type").options[medium_type_index].value;
	medium_type_id = myMenuSearchMediumTypesID.toString();
	
	//country_id = myMenuSearchCountryID.toString();

	//material_index = document.getElementById("dd_material").selectedIndex;
  	//material_id = document.getElementById("dd_material").options[material_index].value;
	material_id = myMenuSearchMaterialID.toString();
	
	mood_id = myMenuSearchMoodID.toString();
	
	genre_id = myMenuSearchGenreID.toString();
	
	dimension_id = myMenuSearchDimensionID.toString();
	
	///color_index = document.getElementById("dd_colors").selectedIndex;
  	//color_id = document.getElementById("dd_colors").options[color_index].value;
	//color_id = myEditArtColorID.toString();
	color_id = myMenuSearchColorID.toString();
	
	//continent_id = myMenuSearchContinentID.toString();
	
	//school_id = myMenuSearchSchoolID.toString();
	city_id = myGetCity_Id();
	school_id = myGetSchool_Id();
	country_id = myGetCountry_Id();
	
	
	var price_min = myMenuSearchMinPrice;
	var price_max = myMenuSearchMaxPrice;
	
	//alert(price_min, price_max)

	if(pageNumber > ''){
	}else{
		pageNumber = 1;
	}
	
	searchArt(medium_id, artName, keyword, medium_type_id, country_id, material_id, mood_id, genre_id, dimension_id, color_id, price_min, price_max, city_id, school_id, '', 32, pageNumber, "txtPageContent");
	
	myBannerAdRefresh();
	
	
}


	function mysubmit()
	{
	
		var submitValid = true;
		//First Check that the Upload Gallery Has been Choosen from the Drop Down.
		gallery_index = document.getElementById("dd_gallery").selectedIndex;
		gallery_id = document.getElementById("dd_gallery").options[gallery_index].value;
	
        //Check that "I certify is Checked"	
		var checkbox = document.getElementById("checkboxPhotoCertify").checked;
		if(checkbox == false){
				document.getElementById("saved").innerHTML = "Please Check the \"I Certify\" checkbox to confirm you have the right to distrubute these pictures.";
				//alert("Please Check the \"I Certify\" checkbox to confirm you have the right to distrubute these pictures.");
				submitValid = false;
		}else{
			//Check that a Gallery was Selected
			if(gallery_id == 0){
				  document.getElementById("saved").innerHTML = "Please Select a Gallery to Upload to.";
				  //alert("Please Select a Gallery to Upload to.");
				  submitValid = false;
			}else{
				 document.getElementById("saved").innerHTML = "";
			}
		}
		
		
	
	    if(submitValid == true){
		     //alert("OK Uploading");
		    /*
			var Java;					
			var FormObj = document.getElementById("myform");				
			var FormValues = '';
			
			Java = document.getElementById("JavaPowUpload");				
			Java.setParam("Upload.HttpUpload.FormName","myform");
			Java.setParam("Upload.HttpUpload.AddFormValuesToPostFields","false");				
			Java.setParam("Upload.HttpUpload.AddFormValuesToHeaders","false");
			Java.setParam("Upload.HttpUpload.AddFormValuesToQueryString","false");
			
			Java.setParam("Upload.HttpUpload.AddFormValuesToPostFields","true");						
			
			Java.clickDownload();
			*/
			upload();
			
			return false;
		}else{
			return false;
		}
	}
	
	
	function myUploadGroupWork()
	{
		var submitValid = true;
		//First Check that the Upload Gallery Has been Choosen from the Drop Down.
		group_id = document.getElementById("txtGroupID").value;
		
        //Check that "I certify is Checked"	
		var checkbox = document.getElementById("checkboxPhotoCertify").checked;
		if(checkbox == false){
				document.getElementById("saved").innerHTML = "Please Check the \"I Certify\" checkbox to confirm you have the right to distrubute these pictures.";
				//alert("Please Check the \"I Certify\" checkbox to confirm you have the right to distrubute these pictures.");
				submitValid = false;
		}else{
		}
		
		
	    if(submitValid == true){

			upload();
			
			return false;
		}else{
			return false;
		}
	}
	

	function JavaPowUpload_onUploadFinish()
	{
 		        //alert("5Download upload complete");

			//person_id  = document.getElementById("txtPersonID").value;
			//gallery_id = document.getElementById("txtGalleryID").value;

			//showPersonGalleries(person_id,gallery_id, "txt_person_gallery_list");


	}
	
	
	function myAvatarUploadCheck(myObj){
	     
		var submitValid = true;
		
		//Check that FileName was selected 
		var avatarFileName = document.getElementById("txtAvatarFileName").value
		if(avatarFileName > ""){
		
				//Verify that check box was checked.  checkboxPhotoCertify
				var checkbox = document.getElementById("checkboxPhotoCertify").checked;
				if(checkbox == false){
					document.getElementById("avatarSaved").innerHTML =  "GPlease Check the \"I Certify\" checkbox to confirm you have the right to distrubute this picture.";
						//alert("Please Check the \"I Certify\" checkbox to confirm you have the right to distrubute this picture.");
						submitValid = false;   
				}else{
				
				    //Verrify the File Size
					//var oas = new ActiveXObject("Scripting.FileSystemObject");
					//var e = oas.getFile(avatarFileName);
					//var f = e.size;
					//alert(f + " bytes");
					//var fd = new File(avatarFileName);
					//alert(fd.size+"\n");

				
				
					document.getElementById("avatarSaved").innerHTML =  "";
					
					myStartAvatarUploadGif();
				}
				
	
		}else{
				
				//alert("Please Select a File to Upload.");
				submitValid = false;
		}
		
	
		 
		 if(submitValid == true){
			return AIM.submit(myObj, {'onStart' : startCallback, 'onComplete' : completeCallback})
		}else{
			return false;
		}
		 
	}
	
	function myBlogUploadCheck(myObj){
	     
		var submitValid = true;
	
		
		//Check that FileName was selected 
		var blogFileName = $("#txtBlogFileName").val();
		if(blogFileName > ""){
					myStartAvatarUploadGif();
			
		}else{
				//alert("Please Select a File to Upload.");
				submitValid = false;
		}
		
	
		 
		 if(submitValid == true){
			return AIM.submit(myObj, {'onStart' : startCallback, 'onComplete' : completeBlogUploadCallback})
		}else{
			return false;
		}
		 
	}	
	
function myStartAvatarUploadGif(){
   
	$('#imgLoading').css("visibility","visible");
}	
 
function myFinishAvatarUploadGif(){
	$('#imgLoading').css("visibility","hidden");
}	
	
	
function serve_add_all(zone){
  //Server Ad
   var myAd = '';
   //Note by Removing the Server Name, This script should now run on all 3 servers.
   //var m3_u = (location.protocol=='https:'?'https://test.pinkmuse.com/openx/www/delivery/ajs.php':'http://test.pinkmuse.com/openx/www/delivery/ajs.php');
   var m3_u = (location.protocol=='https:'?'openx/www/delivery/ajs.php':'openx/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   myAd += "<scr"+"ipt type='text/javascript' src='"+m3_u;
   myAd += "?zoneid=" + zone;
   myAd += '&amp;cb=' + m3_r;
   if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
   myAd += document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : '');
   myAd += "&amp;loc=" + escape(window.location);
   if (document.referrer) myAd += "&amp;referer=" + escape(document.referrer);
   if (document.context) myAd += "&context=" + escape(document.context);
   if (document.mmm_fo) myAd += "&amp;mmm_fo=1";
   myAd += "'><\/scr"+"ipt>";
   
   
   var startpos = myAd.indexOf("src='",0) + 5;
   var endpos = myAd.indexOf("'></scr" + "ipt>",startpos);
   myAd = myAd.substring(startpos, endpos);
   
   //alert(myAd);
   return myAd;
  }
   
   function myBannerAdRefresh(){

	    //Radomly choose a BannerZone to Update:
		var BannerZone = 0;
		var myText = "";
		//BannerZone = Math.floor(Math.random()*10) + 1;
		//if(BannerZone == 1 || BannerZone > 6){
			myText = serve_add_all(1);
			showOpenxAd(myText, "txtOpenxAdLeaderboard");
		//}else if(BannerZone > 1 &&  BannerZone < 6){
		//	myText = serve_add_all(BannerZone);
		//    showOpenxAd( myText, "txtOpenxAdSkyScraper");
		//}
   
   }




