function ManageList(listvalue, listelement,action){
	currentlist= document.getElementById(listelement).value;
	

	if (currentlist != ""){
		document.getElementById(listelement).value = "";
		var arraylist = Array;
		arraylist = currentlist.split(",");
		basecount=0;
		addflag = 0;
		newlist = "";
		while (basecount < arraylist.length){
			switch (action){
				case 'remove':
					if (arraylist[basecount]!=listvalue){
						newlist += arraylist[basecount]+",";
					}
					break;
				case 'add':
					newlist += arraylist[basecount]+",";
					if (arraylist[basecount]==listvalue){
						addflag = 1;
					}
					break;
				}
				basecount++;
		}
		
		if (action=='add'){
			if (addflag !=1){
				newlist += listvalue;
			}
		}
		
		charcount = newlist.length;
		
		if (newlist.charAt(charcount-1)==","){
			newlist = newlist.substr(0,charcount-1);
		}
		
		document.getElementById(listelement).value = newlist;
	}else{		
		if (action=='add'){
			document.getElementById(listelement).value = listvalue;
		}
	}
	
}


function ArrayValue(TestArray, TestValue){
	var TestResult = 0;
	var i;
	
	for (i=0; i < TestArray.length; i++) {
		if (TestArray[i] == TestValue) {
			TestResult = 1;
		}
	}
	return TestResult;

}

function keyPressHandler(e) {
      var kC  = (window.event) ?    // MSIE or Firefox?
                 event.keyCode : e.keyCode;
      var Esc = (window.event) ?   
                27 : e.DOM_VK_ESCAPE // MSIE : Firefox
	if(kC==Esc){
		$('SearchResultsTest').hide();
		$('SearchBox').value = '';
	}
}


function SwapTabs(TabName,ButtonName){
	var PageTabs = Array;
	PageTabs = $('PageTabs').value.split(/,/);
	for (i=0; i < PageTabs.length; i++) {
		$(PageTabs[i]+'Data').hide();
		$(PageTabs[i]+'Tab').className ='Unselected'+ButtonName+PageTabs[i]+'ArtistTab';
	}
	
	$(TabName+'Data').show();
	$(TabName+'Tab').className ='Selected'+ButtonName+TabName+'ArtistTab';
	$('ArtistPageContainer').className = 'Selected'+ButtonName+TabName+'Border';
	
	ResizeContainer();
	
}

function BuildCountrySelect(name,location,scripts,classname,match){
	if($('CurrentPage').value == 'users'){
		var url = '../../s3cr3td4t4/country.xml';
	}else{
		var url = 's3cr3td4t4/country.xml';
	}
	var xml = new JKL.ParseXML( url );
	var data = xml.parse(xml);
	
	var SelectBox ='';
	SelectBox ='<select name="'+name+'" id="'+name+'" onchange="'+scripts+'" class="'+classname+'">';
	
	for(var i = 0; i < data.countries.country.length; i++){
		if(data.countries.country[i].code == match){
			SelectBox +='<option value="'+data.countries.country[i].code+'">'+data.countries.country[i].name+'</option>';
		}else{
			SelectBox +='<option value="'+data.countries.country[i].code+'">'+data.countries.country[i].name+'</option>';
		}
	}
	SelectBox +='</select>';
	
	$(location).innerHTML =SelectBox;
}

function BuildStateSelect(name,location,scripts,classname,match){
	if($('CurrentPage').value == 'users'){
		var url = '../../s3cr3td4t4/states.xml';
	}else{
		var url = 's3cr3td4t4/states.xml';
	}
	var xml = new JKL.ParseXML( url );
	var data = xml.parse(xml);
	
	var SelectBox ='';
	SelectBox ='<select name="'+name+'" id="'+name+'" onchange="'+scripts+'" class="'+classname+'">';
	
	for(var i = 0; i < data.states.state.length; i++){
		if(data.states.state[i].code == match){
			SelectBox +='<option value="'+data.states.state[i].code+'" selected>'+data.states.state[i].name+'</option>';
		}else{
			SelectBox +='<option value="'+data.states.state[i].code+'">'+data.states.state[i].name+'</option>';
		}
	}
	SelectBox +='</select>';
	$(location).innerHTML =SelectBox;
}

function BuildProvinceSelect(name,location,scripts,classname,match){
	if($('CurrentPage').value == 'users'){
		var url = '../../s3cr3td4t4/provinces.xml';
	}else{
		var url = 's3cr3td4t4/provinces.xml';
	}
	var xml = new JKL.ParseXML( url );
	var data = xml.parse(xml);
	
	var SelectBox ='';
	SelectBox ='<select name="'+name+'" id="'+name+'" onchange="'+scripts+'" class="'+classname+'">';
	
	for(var i = 0; i < data.provinces.province.length; i++){
		if(data.provinces.province[i].code == match){
			SelectBox +='<option value="'+data.provinces.province[i].code+'" selected>'+data.provinces.province[i].name+'</option>';
		}else{
			SelectBox +='<option value="'+data.provinces.province[i].code+'">'+data.provinces.province[i].name+'</option>';
		}
	}
	
	SelectBox +='</select>';
	$(location).innerHTML =SelectBox;

}

function BuildRegion(name, location,scripts,classname){
	$(location).innerHTML ='<input type="text" name="'+name+'" id="'+name+'" value="" class="'+classname+'" onkeyup="'+scripts+'">';
}

function ChangeRegion(Region){
	if(Region=='CA'){
		BuildProvinceSelect('Region','RegionContainer','','','')
	}else if(Region=='US'){
		BuildStateSelect('Region','RegionContainer','','','')
	}else{
		BuildRegion('Region','RegionContainer', '','','');
	}
}

function selectmatch(selectObj, txtObj) {
	var letter = txtObj.value;
	for(var i = 0; i < selectObj.length; i++) {
		if($(selectObj).options[i].value == letter){
			$(selectObj).selectedIndex = i;
		}
	} 
}


function ResizeContainer(){
InternetExplorer = 0;
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			ScreenWidth = window.innerWidth;
			ScreenHeight = window.innerHeight;
			ColumnAdj = 0;
			
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			ScreenWidth = document.body.offsetWidth;
			ColumnAdj = 5;
			InternetExplorer = 1;
			
			ScreenHeight = document.body.offsetHeight;
		}
	}
	xMin = window.innerWidth;
	yMin = window.innerHeight;
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		if($('CurrentPage').value != 'artwork'){
			yWithScroll = yWithScroll-36;
		}
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;//-window.innerHeight;
		//~ alert(yWithScroll); 
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
	//~ alert(yWithScroll); 
	}
	if(InternetExplorer == 0){
		//~ if(yMin<yWithScroll){
			//~ $('PageContainer').style.height = parseInt(yWithScroll)+'px';	
		//~ }else{
			//~ $('PageContainer').style.height = parseInt(yMin)+'px';
		//~ }
	}
}

function AddComment(){
	CommentSection = $('CurrentPage').value;
	CommentSectionID = $('SectionID').value;
	CommentName= $('CommentName').value;
	CommentText= $('CommentText').value;
	
	if(CommentText != '' && CommentName != 'Your Name' && CommentName != ''){
		$('CommentName').disabled=true;
		$('CommentText').disabled=true;
		$('CommentButton').disabled=true;
		$('AddCommentsHere').innerHTML = '<div align="center"><img src="images/icons/loading.gif"></div>';
		
		url = 'managecomments.php?Section='+CommentSection
		url += '&SectionID='+CommentSectionID
		url += '&CommentText='+CommentText
		url += '&CommentName='+CommentName
		url += '&action=1';
		
		new Ajax.Request(url, {
			asynchronous:true,
			method: 'get',
			onSuccess: function(transport){	
				$('AddCommentsHere').innerHTML ='Your comment has been submitted.';
			}
		});
	}else{
		$('AddCommentsHere').innerHTML ='You need to complete the form before submitting';
	}
}


function VoteCommentUp(CommentID){
	url = 'managecomments.php?';
	url += '&CommentID='+CommentID
	url += '&action=2';
	
	new Ajax.Request(url, {
		asynchronous:true,
		method: 'get',
		onSuccess: function(transport){	
			$('CommentVoteButtons').innerHTML ='Thanks for voting';
		}
	});

}
//CommentVoteButtons
function VoteCommentDown(CommentID){
	url = 'managecomments.php?';
	url += '&CommentID='+CommentID
	url += '&action=3';
	
	new Ajax.Request(url, {
		asynchronous:true,
		method: 'get',
		onSuccess: function(transport){	
			$('CommentVoteButtons').innerHTML ='Thanks for voting.';
		}
	});
}


function ShowLostPass(){
	LostPassHTML ='';
	LostPassHTML +='<form name="LostPass" action="manageaccount.php?accountaction=8" method="POST">';
	LostPassHTML +='	Please enter your email address';
	LostPassHTML +='	<input type="text" name="LostPassEmail" id="LostPassEmail" value=""><br>';
	LostPassHTML +='	<input type="submit" value="Request Password Reset"> | <input type="button" value="Cancel" onclick="javascript:HideLostPass()">';
	LostPassHTML +='</form>';
	CenterAlign =  ((document.body.clientWidth/2)-(300) );
	$('LostPassword').style.width = '300px';
	$('LostPassword').style.paddingTop = '25px;';
	$('LostPassword').style.left= CenterAlign+'px';
	$('LostPassword').style.top= '75px';
	
	
	$('LostPassword').style.backgroundColor = 'white';
	$('LostPassword').style.border = '3px solid lightgrey';
	$('LostPassword').style.zIndex= '10003';
	$('LostPassword').innerHTML = LostPassHTML ;
	$('LostPassword').show();
	$('PopUpMask').show();
}

function HideLostPass(){
	$('LostPassword').hide();
	$('PopUpMask').hide();
}

function addslashes(str) {
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\0/g,'\\0');
return str;
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\0/g,'\0');
str=str.replace(/\\\\/g,'\\');
return str;
}


function VersionNoticeCheck(){
	UserBrowser = BrowserDetect.browser
	UserVersion = BrowserDetect.version
	//~ alert(UserBrowser+' '+UserVersion)
	var ShowMessage = 0;
	var VersionMessage = '';
	switch(UserBrowser){
		case 'Firefox':
			if(UserVersion<3){
				ShowMessage = 1;
				VersionMessage = '<div style="width:665px; text-align:left;font-size:24px; font-family:Arial, Helvetica, Sans; font-weight:normal; letter-spacing:-1px; line-height: 36px; color:#303030;">';
				VersionMessage += '<div style="font-size:36px; font-family:Arial, Helvetica, Sans; font-weight:bold; letter-spacing:-1px;">Hello!</div>';
				VersionMessage += '<div>It looks like you\'re using an older version of Firefox. Our site is going ';
				VersionMessage += 'to look kinda messy. We recommend getting the latest version so ';
				VersionMessage += 'everything looks right and behaves itself.</div>';
				VersionMessage += '<br>';
				VersionMessage += '<a href="http://www.mozilla.com/en-US/firefox/upgrade.html?from=getfirefox" class="InlineBase Emphasis" style="margin-right:150px;text-decoration:underline;">Get Firefox 3.5!</a>';
				VersionMessage += '<a href="javascript:void(0);" onclick="javascript:IgnoreVersionNotice();" class="InlineBase  Emphasis" style="text-decoration:underline;">Maybe later </a>';
				VersionMessage += '</div>';
			}
			break;
		case 'Safari':
			break;
		case 'Explorer':
			if(UserVersion<7){
				ShowMessage = 1;
				VersionMessage = '<div style="width:665px; text-align:left;font-size:24px; font-family:Arial, Helvetica, Sans; font-weight:normal; letter-spacing:-1px; line-height: 1.5;">';
				VersionMessage += '<div style="font-size:36px; font-family:Arial, Helvetica, Sans; font-weight:bold; letter-spacing:-1px;">Hello!</div>';
				VersionMessage += '<div>It looks like you\'re using an older version of Internet Explorer. Our site is going ';
				VersionMessage += 'to look kinda messy. We recommend getting the latest version so ';
				VersionMessage += 'everything looks right and behaves itself.</div>';
				VersionMessage += '<br>';
				VersionMessage += '<a href="http://www.microsoft.com/windows/internet-explorer/" class="InlineBase Emphasis" style="margin-right:150px;text-decoration:underline;">Get Internet Explorer 8!</a>';
				VersionMessage += '<a href="javascript:void(0);" onclick="javascript:IgnoreVersionNotice()" class="InlineBase  Emphasis" style="text-decoration:underline;">Maybe later </a>';
				VersionMessage += '</div>';
			}
			break;
		case 'Opera':
			break;
	}
	
	if(ShowMessage == 1){
		CenterAlign =  ((975/2)-(665/2));
		if(UserVersion<7 && UserBrowser=='Explorer'){
			$('FullPopUpMask').style.opacity=1;
			$('FullPopUpMask').innerHTML = '<img src="images/alerts/ie_bkg_image.jpg">';
		}
		$('FullPopUpMask').show();
		$('FullPopUpText').innerHTML = VersionMessage
		$('FullPopUpText').style.left =CenterAlign+'px';
		$('FullPopUpText').style.background ='transparent';
		$('FullPopUpText').show();
		$('PopUpShown').value = 1;
	}
}

function IgnoreVersionNotice(){

	url = 'managepopup.php?popupaction=3';
		
	new Ajax.Request(url, {
		asynchronous:true,
		method: 'get',
		onSuccess: function(transport){	
			$('FullPopUpMask').hide();
			$('PopUpText').hide();
		}
	});
}


function ShowQuickStartVideo(){
	
	

	//~ PopupText ='<iframe style="border:0px;height:650px; width:750px;" src="videos/videoplayer/GSVideoPlayer.html?v=quickstart&t=Quick_Start_Video&debug=true"></iframe>';
	//~ PopupText += '<div style="text-align:right; margin-top:15px;" class="MainHeading"><a href="javascript:void(0);" onclick="javascript:HideQuickStartVideo();">Close this Window</a></div>';


	//~ CenterAlign =  ((975/2)-(750/2));
	//~ $('PopUpMask').show();
	//~ $('PopUpText').innerHTML = PopupText
	//~ $('PopUpText').style.width = '750px';
	//~ $('PopUpText').style.left =CenterAlign+'px';
	//~ $('PopUpText').show();
	//~ $('PopUpShown').value = 1;
	
	
	PopupText ='<span id="container1"></span>';
	PopupText += '<div style="text-align:right; margin-top:15px;" class="MainHeading"><a href="javascript:void(0);" onclick="javascript:HideQuickStartVideo();">Close this Window</a></div>';


	CenterAlign =  ((975/2)-(600/2));
	$('PopUpMask').show();
	$('PopUpText').innerHTML = PopupText
	$('PopUpText').style.width = '600px';
	$('PopUpText').style.left =CenterAlign+'px';
	$('PopUpText').show();
	$('PopUpShown').value = 1;
	
	var s1 = new SWFObject("images/player/player.swf","ply","608","460","9");
	s1.addParam("allowfullscreen","false");
	s1.addParam("allowscriptaccess","always");
	s1.addParam("wmode","opaque");
	s1.addParam("flashvars","image=&file=../../images/videos/quickstart.flv&quality=true&plugins=googlytics-1&autostart=true&backcolor=FFFFFF");
	s1.addVariable('autostart','true');
	s1.addVariable('screencolor','FFFFFF');
	s1.addVariable('backcolor','FFFFFF');
	s1.addVariable('frontcolor','FFFFFF');
	s1.write("container1");
}

function HideQuickStartVideo(){
	$('PopUpText').innerHTML ='';
	$('PopUpText').style.width='300px';
	$('PopUpText').hide();
	$('PopUpMask').hide();
}