function getInternetExplorerVersion()
	// Returns the version of Internet Explorer or a -1
	// (indicating the use of another browser).
	{ 
	  var rv = -1; // Return value assumes failure.
	  if (navigator.appName == 'Microsoft Internet Explorer')
	  {
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
		  rv = parseFloat( RegExp.$1 );
	  }
	  return rv;
	}
	
$.fn.corner.defaults.useNative = false;

$(document).ready( function() {  
		$("#footer-link-holder").click(  
					function(){ 
						//$("div#footerBody").animate({ height: "150px" }); 
						$("div#footerBody").slideToggle('300'); 
						return false;	
						}); 
		
		if(getInternetExplorerVersion() == -1) { 
			$(".mainPhoto").corner("round 10px").parent().css('padding', '8px').corner("round 14px");
			$(".leftPhoto").corner("left").parent().corner("left");
			$(".rightPhoto").corner("right").parent().corner("right");
			$("#loggedHeader").corner("top");
			$(".blogPost").corner("round 10px").parent().corner("round 15px");
			$(".round").corner("round 12px");
			$(".roundBorder").corner("round 12px").parent().corner("round 12px");
			}
		
		$( ".gPic" ).aeImageResize({ height: 180, width: 180 });
		
		$(".wysiwyg").cleditor();
		
		$(".extLinkSmall").fancybox({
				 'width' : '400px',
				 'height' : '15%',
				 'autoScale' : false,
				 'transitionIn' : 'elastic',
				 'transitionOut' : 'elastic',
				 'speedIn' : '1300',
				 'speedOut' : '1300',
				 'type' : 'iframe',
				 'scrolling' : 'no',
				  'onClosed': function() { parent.location.reload(true); } 
    			 });
				 
				 
		$(".extLinkMed").fancybox({
				 'width' : '50%',
				 'height' : '60%',
				 'autoScale' : false,
				 'transitionIn' : 'elastic',
				 'transitionOut' : 'elastic',
				 'speedIn' : '1300',
				 'speedOut' : '1300',
				 'type' : 'iframe',
				 'scrolling' : 'no',
				  'onClosed': function() { parent.location.reload(true); } 
    			 });
				 
		$(".extLinkMedNoRefresh").fancybox({
				 'width' : '50%',
				 'height' : '70%',
				 'autoScale' : false,
				 'transitionIn' : 'elastic',
				 'transitionOut' : 'elastic',
				 'speedIn' : '1300',
				 'speedOut' : '1300',
				 'type' : 'iframe',
				 'scrolling' : 'yes'
    			 });
		
		$(".extLinkLarge").fancybox({
				 'width' : '60%',
				 'height' : '90%',
				 'autoScale' : false,
				 'transitionIn' : 'elastic',
				 'transitionOut' : 'elastic',
				 'speedIn' : '1300',
				 'speedOut' : '1300',
				 'type' : 'iframe',
				 'scrolling' : 'yes',
				  'onClosed': function() { parent.location.reload(true); } 
    			 });
		
		$('#img_upload').uploadify({
				'uploader'  : 'uploadify/uploadify.swf',
				'script'    : 'uploadify/uploadify.php',
				'cancelImg' : 'uploadify/cancel.png',
				'folder'    : 'images/models/',
				'auto'      : true,
				'multi' 	: true
				
			  });
		
		$('.updateLocs').blur( function() {
			 var href = 'includes/ajax/manageLocs.php?action=edit&lid=' + $(this).attr('alt') + "&orderBy-" + $(this).attr('alt') + "=" + $(this).attr('value') + "&order=" + $(this).attr('value');
			 $.get( href, function(msg) {   } );
			 return false; // don't follow the link!
   			});
		
		//$("#test-list").sortable({ 
				// handle : '.handle', 
				// update : function () { 
				//  var order = $('#test-list').sortable('serialize'); 
				//  $("#info").load("includes/jquery/dragdropsort/process-sortable.php?"+order); 
				//} 
		//	  }); 
		
		//$("#model-list").draganddropsort();
		
		$( "#sortable" ).sortable({
								  	//placeholder: "ui-state-highlight"//,
								  	//stop: function() {
										//var result = $( "#result" ).empty();
										//$( ".sortable", this ).each(function() {
										//	var index = $( "#sortable p" ).index( this );
										//var blah = $(".sortable").sortable( "serialize" );
										//	result.append( blah );
										//});
									//}
									
									update: function(event, ui) {
										$(".sortable").sortable('refresh');
										var ordered = $("#sortable").sortable('serialize').toString();
										var result = $( "#result" ).html('');
																				
										//ordered = [];
										//$('#sortable').children('p').each(function(idx, elm) {
										//  ordered.push(elm.id.split('_')[1])
										//});   
										
										//alert(ordered);
										//result.html(ordered);
										
										$.get('includes/ajax/manageModels.php?' + ordered);
										}
								  });
		$( "#sortable" ).disableSelection();
		
		}); 

function confirmDeleteBlog(aid) {
	var a = confirm("Are you sure you want to delete the blog entry?");
	if(a) { window.location = "admin.php?deleteEntry=" + aid; }
	}
	
Shadowbox.init({counterType: "skip"});

function isIE()
      {
         var div = document.createElement('div');
         div.innerHTML = '<!--[if IE]><i></i><![endif]-->';
         return (div.getElementsByTagName('i').length === 1);         
      }

