// JavaScript Document

// Simple jQuery
$(document).ready(function(){
$(".flip").click(function(){
    $(".hidden_flip").slideToggle("slow");
  });
});
//////////////////////////////////

//POST AJAX REQUEST...
function makePOSTRequest(url, parameters) {
   
       http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }

      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
		 
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('type').innerHTML = result;  
			//alert('Went Through.');         
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function postArtistType(serverpage, aid) {
   
		var newType =  document.atype_form.atype.value;
      	var poststr = "content=" + newType + "&id=" + aid;
		
					alert("Your portfolio has been updated to: " + newType);
					//alert(" Value: " + poststr +"");
      makePOSTRequest(serverpage, poststr);
   }
   

////////////////////////////////////////////////////////////////
//Sort the Gallery Images in Order Using JQuery
$(document).ready(function(){ 
						   
	$(function() {
		$("#sortable").sortable({ opacity: 0.6, cursor: 'move', update: function() {

		var order = $(this).sortable("serialize") + '&action=updateRecordsListings'; 
			
		$.post("../01include/ajax_scripts/orderImagesDB.php", order, function(theResponse){
				$("#contentRight").html(theResponse);
			}); 															 
		}								  
		});
	});
	
	
	
	$(function() {
		$("#sort").sortable({ opacity: 0.6, cursor: 'move', update: function() {
		
			var order = $(this).sortable("serialize") + '&action=updateRecordsGallery'; 
			
			$.post("../01include/ajax_scripts/orderGalleryDB.php", order, function(theResponse){
				$("#contentRight").html(theResponse);
			}); 															 
		}								  
		});
	});
	
	
	$(function() {
		$("#sortSkills").sortable({ opacity: 0.6, cursor: 'move', update: function() {
		
			var order = $(this).sortable("serialize") + '&action=updateRecordsGallery'; 
			
			$.post("../01include/ajax_scripts/orderResumeSkills.php", order, function(theResponse){
				$("#contentRight").html(theResponse);
			}); 															 
		}								  
		});
	});
	
	//sort all the resume items...listings
	$(function() {
		$("#sortResumeItems").sortable({ opacity: 0.6, cursor: 'move', update: function() {
		
			var order = $(this).sortable("serialize") + '&action=updateResumeItem&table='+rtable+'&tid='+rtableid; 
			
			$.post("../01include/ajax_scripts/orderResumeItems.php", order, function(theResponse){
				$("#contentRight").html(theResponse);
			}); 															 
		}								  
		});
	});
	

});	

///////////////////////////////
//
//AJAX requests
//
//
//AJAX OBJECT...
if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari
		
	xmlhttp=new XMLHttpRequest(); 
	
 } else {// code for IE6, IE5
		
	 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		
}
	  
function publishGallery(serverPage, objID, artist_id, gallery_id, publish) {

	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
		
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			
			obj.innerHTML = xmlhttp.responseText;
			
			//display a message
			if (publish == 'no') {
			
			alert("Your Gallery has been published.");
			
			} else {
			
			alert("Your Gallery has been unpublished.");
			
			}
			
		}
	}	
	
	xmlhttp.open("GET", serverPage + "?pub=" + publish + "&aid=" + artist_id + "&gid=" + gallery_id, true);
	xmlhttp.send();
	
}


function applyTheme(serverPage, objID, artist_id, theme_id, sec_id, title) {

	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
		
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			
			obj.innerHTML = xmlhttp.responseText;
			//display a message
			alert("Your Theme has been updated to " + title + ".");
		}
	}	
	
	xmlhttp.open("GET", serverPage + "?aid=" + artist_id + "&tid=" + theme_id + "&sec_id=" + sec_id, true);
	xmlhttp.send();
	
}


function publishResume(serverPage, objID, artist_id, publish, status) {

	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
		
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			
			obj.innerHTML = xmlhttp.responseText;
			
			//display a message
			alert("Your resume has been " + status + "ed.");
		}
	}	
	
	xmlhttp.open("GET",serverPage +"?aid="+artist_id+"&publish=" + publish, true);
	xmlhttp.send();
	
}



function publishMedia(serverPage, objID, artist_id, mid, mtype, publish, status) {

	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
		
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			
			obj.innerHTML = xmlhttp.responseText;
			
			//display a message
			alert("Your media has been " + status + "ed.");
		}
	}	
	
	xmlhttp.open("GET", serverPage + "?aid=" + artist_id + "&mid=" + mid + "&mtype=" + mtype + "&publish=" + publish, true);
	xmlhttp.send();
	
}



function publishImage(serverPage, objID, artist_id, image_id, publish, status) {

	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
		
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			
			obj.innerHTML = xmlhttp.responseText;
			//display a message
			alert("Your image has been " + status + "ed.");
		}
	}	
	
	xmlhttp.open("GET", serverPage + "?aid=" + artist_id + "&iid=" + image_id + "&publish=" + publish, true);
	xmlhttp.send();
	
}

function applyGalleryType(serverPage, objID, artist_id, gtid, title) {

	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
		
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			
			obj.innerHTML = xmlhttp.responseText;
			
			//display a message
			alert("Your gallery style is now " + title + ".");
			
		}
	}	
	
	xmlhttp.open("GET", serverPage + "?aid=" + artist_id + "&gtid=" + gtid, true);
	xmlhttp.send();
	
}


function applyArtistType(serverPage, objID, artist_type_id, name, artist_id) {

	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
		
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			
			obj.innerHTML = xmlhttp.responseText;
			
			//display a message
			alert("Your Portfolio type is now " + name + ".");
			
		}
	}	
	
	xmlhttp.open("GET", serverPage + "?name=" + name + "&aid=" + artist_id + "&atid=" + artist_type_id, true);
	xmlhttp.send();
	
}

function publishSite(serverPage, objID, artist_id, publish) {

	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
		
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			
			obj.innerHTML = xmlhttp.responseText;
			
			//display a message
			alert("Your Website publish status has been updated.");
			
		}
	}	
	
	xmlhttp.open("GET", serverPage + "?aid=" + artist_id + "&pub=" + publish, true);
	xmlhttp.send();
	
}

function commentAction(serverPage, objID, cid, ctid, id, oid, approve) {

	var obj = document.getElementById(objID);
	xmlhttp.onreadystatechange = function() {
		
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			
			obj.innerHTML = xmlhttp.responseText;
			
			//display a message
			alert("You just updated your comment.");
			
		}
	}	
	
	xmlhttp.open("GET", serverPage + "?cid=" + cid + "&ctid=" + ctid + "&id=" + id + "&oid=" + oid +"&approve=" + approve, true);
	xmlhttp.send();
	
}
//////////////////////////////
///////////////////////////////
function toggleDisplay() {
   var obj = document.getElementById('div');
   if(obj.style.display == 'none') {
      obj.style.display = 'block';
	  document.getElementById('div1').style.display = 'none';
   } else {
      obj.style.display = 'none';
	  document.getElementById('div1').style.display = 'block';
   }
}

function deleteCheck(url) {
	
	var delcheck = confirm('Are you sure you want to delete?');
	
	if (delcheck) {
		
		window.location = url;
		
	} else {
		
		return false;	
	}
}

///////////////////////////////////////////////////////////////




//////////////////////////////////////////////////////////////////////////////
//check the Contact Page form
function checkContactForm() {
	
	var cform = document.contact_form;
	
	if (cform.name.value == '') {
		
		alert('Please enter your Name.');
		return false;
	
	} else if (cform.user_email.value == '') {
		
		alert('Please enter your email address.');
		return false;
	
	} else if (cform.comments.value == '') {
		
		alert('Please enter your comments.');
		return false;
	}
	
	//if the form elemenst are completely filled..submit
	return true;
	
}
//////////////////////////////////////////////////////////////////////

function confirmAddFavorite() {
	
	var msg = confirm("You have chosen to add this portfolio to your favorites.  Click OK to Add this Artist to your favorites or cancel to not add to favorites.  Thank you.");
	
	if (msg) {
		
		return true;	
	} else {
		
		return false;	
	}
		
}

function confirmDelete() {
	
	var msg = confirm("Are you sure you want to DELETE? This action CANNOT be undone. Click OK to continue...");
	
	if (msg) {
		
		return true;	
	} else {
		
		return false;	
	}
}


////////////////////////////////////////////////////////////////////


<!-- PreLoad Wait - Script -->
<!-- This script and more from http://www.rainbow.arch.scriptmania.com 

function loadingPage() { //DOM

//hide the form
if (document.getElementById){
document.getElementById('loading').style.display='block';
document.getElementById('form').style.visibility='hidden';
}else{
if (document.layers){ //NS4
document.loading.display = 'block';
document.form.visibility = 'hidden';
}
else { //IE4
document.all.loading.style.display = 'block';
document.all.form.style.visibility = 'hidden';
}
}
}


//"Accept terms" form submission- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var checkobj

function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}

function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
}
