function popupWin(theURL)
	{
	newWindow = window.open(theURL, 'afddsfd', 'width=440,height=380');
	}

function saveSlideshow()
	{
	if(document.getElementById('txtSongId').value == '' || document.getElementById('txtSongId').value == 0)
		{
		w =  parseInt((screen.width-400)/2);
		h = parseInt((screen.height-307)/2);
		extra = ',top=' + h + ',left=' + w;
		newWindow = window.open('noSound.html', 'noSound', 'width=400,height=307' + extra);
		}
	else
		{
		saveIt();
		}

	}
function resetForm()
	{
	// document.form1.reset();
	}
function clearCaption(x)
	{
	if(x.value == 'Enter Caption Here')
		{
		x.value = '';
		}
	}

function captionButton(state)
	{
	if(state == 1)
		{
		document.getElementById('description').style.display="block";
		document.getElementById('description2').style.display="block";
		}
	else
		{
		document.getElementById('description').style.display="none";
		document.getElementById('description2').style.display="none";
		}
	}

function changeUploadPhotoButton(obj)
	{
	obj.src = 'images/upload/upload_photo_flash.gif';
	document.getElementById('theBubble').innerHTML = 'Now Click "Upload Photo" to Continue... ';
	}


function fixRadio()
	{
	 document.form1.addCaption[0].checked = false;
	document.form1.addCaption[1].checked = true;
	}
function checkImageValue()
	{
	if(document.getElementById('image').value=="" && document.getElementById('urlPhoto').value == '')
		{
		showBox(1,1);
		document.getElementById('Box_1').style.display="none";
		document.getElementById('Box_10').style.display="block";
		document.getElementById('bottomColor').style.backgroundColor="#FFFFFF";
		document.getElementById('cornerColor').style.backgroundColor="#FFFFFF";
		document.getElementById('sideColor').style.backgroundColor="#FFFFFF";
		return false;
		}
	else
		{
		showBox(3,2);
		return false;
		}
	}
function clearCaptions()
	{
	
	document.getElementById('txtCaption').value = '';
	document.getElementById('txtDescription').value = '';
	document.getElementById('placeholder').src = 'images/blank.gif';
	document.getElementById('photoId').value = '';
	}
	
	

function submitForm(mode){
	if(document.getElementById('image').value=="" && document.getElementById('urlPhoto').value == '' && document.getElementById('photoId').value==''){
		alert('Please upload an image before continuing');
		return false;
	}
	if(document.getElementById('description').value == 'Enter Caption Here'){
		document.getElementById('description').value = '';
	}
	if(document.getElementById('description2').value != '' && document.getElementById('description2').value != 'Enter Caption Here'){
		document.getElementById('description').value = document.getElementById('description2').value;
	}
	if(document.getElementById('txtDescription').value != ''){
		document.getElementById('description').value = document.getElementById('txtDescription').value;
	}
	if(document.getElementById('txtCaption').value != ''){
		document.getElementById('caption').value = document.getElementById('txtCaption').value;
	}			
	if(document.getElementById('urlPhoto').value != ''){
		document.getElementById('urlPho').value = document.getElementById('urlPhoto').value;			
	}
	loading('Box_9','Box_1');
	document.form1.submit();	
}
function confirmRestart(){
	a = confirm('Are you sure you want to redo your slideshow? \n  All your current progress will be lost');
	return a;
}
function deleteImage(photoId,theslideID){
if(photoId !=  null){
	a=confirm("Are you sure you want to remove this image from your slideshow?");
	if(a==true)
		{
		var fromApp  = document.getElementById('fromApp').value;
		document.location.href="cfms/deleteSelectedImage.cfm?slideid="+theslideID+"&photoId=" + photoId +  "&fromApp=" + fromApp;
		}
	}	
}
function verifyPhoto(theObject){
	// get last four digits
	if(theObject.value.indexOf('.jpg') > - 1 || theObject.value.indexOf('.gif')  > - 1 || theObject.value.indexOf('.png')  > - 1 || theObject.value.indexOf('.bmp')  > - 1 || theObject.value.indexOf('.psd')  > - 1 || theObject.value.indexOf('.JPG') > - 1 || theObject.value.indexOf('.GIF')  > - 1 || theObject.value.indexOf('.PNG')  > - 1 || theObject.value.indexOf('.BMP')  > - 1 || theObject.value.indexOf('.PSD')  > - 1  || theObject.value.indexOf('.JPEG')  > - 1 || theObject.value.indexOf('.jpeg')  > - 1){
	
	}
	else{	
		alert('You may upload images in the following formats only \n  .jpg, .gif, .png, .bmp, .psd');
		document.getElementById('Image_Upload').src = 'images/upload/upload_photo.gif';
		document.form1.reset();
		theObject.focus();
	}
}
function TrimString(sInString) {
	if(sInString == ""){
		return;
	}
	sInString = sInString.replace( /^\s+/g, "" );// strip leading
	return sInString.replace( /\s+$/g, "" );// strip trailing	 
}
function Verify(theForm){
	songId = document.getElementById('songList')[document.getElementById('songList').selectedIndex].value;
	
	if(songId >0){
		document.getElementById('songId').value = TrimString(songId);
	}
	if(document.getElementById('image').value == '' && document.getElementById('photoId').value == ''){
		alert('Please upload an image');
		return false;
	}
	// activate updloading layer	
	document.getElementById('addPhotos').style.display='none';	
	document.getElementById('addCaptions').style.display='none';	
	document.getElementById('addMusic').style.display='none';
	document.getElementById('UploadPhoto').style.display='block';	
	
	return true;
}
function changeSubmit(val){
	if(val == true){
		document.getElementById('td_continue').style.display='block';	
		document.getElementById('td_submit').style.display='none'
		}
	else{
		document.getElementById('td_continue').style.display='none';	
		document.getElementById('td_submit').style.display='block'
		}
}
	function editCaptions(a)
		{
		document.getElementById('photoId').value = a;
		showBox(3,2);
	http_request = requestObject();
	http_request.open('POST', 'cfms/getSelectedImage.cfm', true);
	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http_request.onreadystatechange = function()
			{
			alertContents(http_request);
			
			} // end capture function
		http_request.send('imageid=' + a);
		}
		
	function alertContents(http_request)
		{
	  if (http_request.readyState == 4) 
	  		{
	         if (http_request.status == 200) // success
			 		{
					
					
					var stRequest = http_request.responseText;
					var vars = stRequest.split("^") // stores contents into an array
					document.getElementById('txtCaption').value = TrimString(vars[1]);
					document.getElementById('txtDescription').value = TrimString(vars[2]);
					if(document.getElementById('txtDescription').value == 'undefined')
						{
						document.getElementById('txtDescription').value = '';
						}
					
					document.getElementById('placeholder').src = TrimString(vars[3]);
	            	} 
				else
					{
	                alert('Please upload an image first.');
					document.getElementById('photoId').value = '';
					showBox(1,1);
	           		}
	     	 }
		}	// end ajax request for image info	
// ajax request for top 10 songs by category
function topTen(categoryID){
	document.getElementById('musicSelect').style.display='block';
	http_request = requestObject();
	http_request.open('POST', 'cfms/getSongs.cfm', true);
	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http_request.onreadystatechange = function()
		{
		alertContents2(http_request);
		} // end capture function
	http_request.send('categoryId=' + categoryID);
}	
function alertContents2(http_request){
	if (http_request.readyState == 4){
    	if (http_request.status == 200){
		// success
			var stRequest = http_request.responseText;
			var vars = stRequest.split("^") // stores contents into an array
			var destList = document.getElementById('songList'); // listbox we will populate
			destList.options.length = 0; // should clear listbox
			destList.disabled=false;
			// create 'Please Select' Option
			optionObject = new Option('None','0');
			destList.options[0]=optionObject;

			for(x=0;x<vars.length-1;x++){
				oneElement = vars[x].split("~");
				oneElement[1] = oneElement[1].substr(0,18);
				oneElement[0] = TrimString(oneElement[0]);
				optionObject = new Option(oneElement[1],oneElement[0]);
				destList.options[x]=optionObject;
			}
			setSong();
		} 
		else{
			alert('There was a problem with the request.');
	    }
	}
}	// end ajax request for top 10 songs
function switchLayers(on, off){
	document.getElementById(off).style.display='none';
	document.getElementById(on).style.display='block';
	if(on == 'addPhotos'){
		document.getElementById('caption').value="";
		document.getElementById('description').value="";
		document.getElementById('photoId').value="";
	}
	return false;
}
function musicVerify(){
	a = document.getElementById('image').value;
	if(a != ''){ 
	// submit other form
		b = Verify('abcdef');
		loading('Box_9','Box_1');
		document.getElementById('addPhoto').submit();
		return false;
	}	
}
function prePopTitle(str){
	document.getElementById('caption').value=str.substr(str.lastIndexOf("\\")+1);
}
function showTab(tab){		
	if (tab==1){				
		document.getElementById("Tab1").style.display="Block";
		document.getElementById("Tab2").style.display="none";
		document.getElementById("LinkSet1").style.display="Block";				
		document.getElementById("LinkSet2").style.display="none";	
		document.getElementById("SpacerSet1").style.display="Block";	
		document.getElementById("SpacerSet2").style.display="none";					
		document.getElementById("Box_3").style.display="none";
		document.getElementById("Box_4").style.display="none";
	}
	else{
		document.getElementById("Tab1").style.display="none";
		document.getElementById("Tab2").style.display="Block";
		document.getElementById("LinkSet1").style.display="none";				
		document.getElementById("LinkSet2").style.display="Block";	
		document.getElementById("SpacerSet2").style.display="Block";	
		document.getElementById("SpacerSet1").style.display="none";						
		document.getElementById("Box_1").style.display="none";
		document.getElementById("Box_2").style.display="none";
	}			
}
//***********************************************************
var numBox;
var startFrom;
		
function loading(x,y){
	document.getElementById(x).style.display="block";
	document.getElementById('Box_1').style.display="none";
	document.getElementById('Box_2').style.display="none";
	document.getElementById('Box_3').style.display="none";
	document.getElementById('Box_4').style.display="none";	
}
		
function showBox(myID, fromTab){	

if(myID ==1 && fromTab ==1)
	{
	;
	document.getElementById('bottomColor').style.backgroundColor="#FFE7C6";
	document.getElementById('cornerColor').style.backgroundColor="#FFE7C6";
	document.getElementById('sideColor').style.backgroundColor="#FFE7C6";
	}

else
	{
	document.getElementById('bottomColor').style.backgroundColor="#FFFFFF";
	document.getElementById('cornerColor').style.backgroundColor="#FFFFFF";
	document.getElementById('sideColor').style.backgroundColor="#FFFFFF";
	}


document.getElementById('Box_10').style.display = 'none';
	showTab(fromTab);			
	if (fromTab==1){
		startFrom=1;
		numBox=2;
	}
	else{
		startFrom=3;
		numBox=4;
	}			
	for (i=startFrom; i<=numBox; i++){				
		if (i==myID){					
			document.getElementById("Box_" + i).style.display="block";
			document.getElementById("spacer_" + i).style.backgroundColor="#FFFFFF";
			document.getElementById("ButtonBG" + i).style.backgroundColor="#FFFFFF";
			document["corner01_" + i].src="imgs/ShareSlideBox/orange_button_corner01.gif";
			document["corner02_" + i].src="imgs/ShareSlideBox/orange_button_corner02.gif";
			document["side_" + i].src="imgs/ShareSlideBox/orange_button_side.gif";
			document["botBG_" + i].src="imgs/ShareSlideBox/orange_button_bot.gif";
			document["topBG_" + i].src="imgs/ShareSlideBox/orange_button_top.gif";						
		}	
		else {							
			document.getElementById("Box_" + i).style.display="none";
			document.getElementById("spacer_" + i).style.backgroundColor="#F79321";
			document.getElementById("ButtonBG" + i).style.backgroundColor="#D6D6D6";
			document["corner01_" + i].src="imgs/ShareSlideBox/grey_button_corner01.gif";
			document["corner02_" + i].src="imgs/ShareSlideBox/grey_button_corner02.gif";
			document["side_" + i].src="imgs/ShareSlideBox/grey_button_side.gif";
			document["botBG_" + i].src="imgs/ShareSlideBox/grey_button_bot.gif";
			document["topBG_" + i].src="imgs/ShareSlideBox/grey_button_top.gif";					
		}
	}
}

function saveIt()
 	{
	var fromApp  = document.getElementById('fromApp').value;
	document.location.href="saveit.html?slideID=" + slideId + "&fromApp=" + fromApp;
	}

function newOrder(a)
	{
	if(slideId >0)
		{
		var fromApp = document.getElementById('fromApp').value;
		document.getElementById('MainContentBox').src="slider.html?upload=1&order=" + a + "&slideID=" + slideId + "&fromApp=" + fromApp;;
		}
	}


function requestObject()
	{
	try
		{
		http_request = new XMLHttpRequest(); /* e.g. Firefox */
		}
	catch(e)
		 {
		try 
			{
			http_request = new ActiveXObject("MSXML2.XMLHTTP.3.0");
			} 
			catch (e)
				{
				try 
					{
					http_request = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
					} 
					catch (e)
						{
						try
							{
							http_request = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
							} 
							catch (E)
								{
								http_request = false;
								}
							}
						}
					}
	return http_request;	
	}



