$(document).ready(function() {
							   
							   $.ajaxSetup ({
											cache: false 
											});
							   var ajax_load = '<div align="center"><img src="/images/ajax-loader.gif" alt="loading..." /></div>';
							   var loadUrl = "/ajax_action.php?Content=";
							   
							   
							   $(".fancybox").fancybox();
							   //alert(window.location.hash);
							   var pageHash = this.location.hash;
							   pageHash = pageHash.replace("#","");
							   if(pageHash == 'ciVideo'){
							   $('#ciVideo').trigger('click');
							   }
							   
							   $('#item_type').live("change", function(){
									$('#item_id_row').fadeIn("fast");
									$('#item_id_row').html(ajax_load).load(loadUrl + 'getIDlist_'+$('#item_type option:selected').val(), function() {
  if($('#item_type option:selected').val()=='new' || $('#item_type option:selected').val()=='fav'|| $('#item_type option:selected').val()=='guest'|| $('#item_type option:selected').val()=='mine')
										{
											$('#player_width').trigger('blur');
										}
});
									

								});	
							   

								
								$(".rollOver").hover(
								 function()
								 {
								  this.src = this.src.replace("_off","_over");
								 },
								 function()
								 {
								  this.src = this.src.replace("_over","_off");
								 }
								);
																	  
							   
							   $('#item_id').live("change", function(){
										if($('#item_id').val()>0){
											$('#player_width').trigger('blur');
										} else {		
											if($('#item_id option:selected').val()>0)
											{
												$('#player_width').trigger('blur');
											} else {
												if($('#item_id option:selected').val().indexOf(",")>0){
													$('#player_width').trigger('blur');
												}
											}
										}
							   });
							   
							   
							   $('.update').live("blur", function(){
																 
								  var item_type = $('#item_type option:selected').val();
								  
								  
									var player_width = '600';
									 if(parseInt($('#player_width').val())>=400 && parseInt($('#player_width').val())<=2000){
										 player_width = parseInt($('#player_width').val());
									 } else {
										 $('#player_width').val(player_width)
									 }
									 var player_height = '350';
									 if(parseInt($('#player_height').val())>=250 && parseInt($('#player_height').val())<=1500){
										 player_height = parseInt($('#player_height').val());
									 } else {
										 $('#player_height').val(player_height)
									 }
									 var num_new_images = '100';
									 if(parseInt($('#num_new_images').val())>0){
										 num_new_images = parseInt($('#num_new_images').val());
									 } else {
										 $('#num_new_images').val(num_new_images)
									 }
									 //alert(player_width);
									
									 var item_id = '1';
									// var num_new_images = '100';
									var item_val = $('#item_id').val();
									 if(item_val > 0 || item_val.length > 0 || item_val.indexOf("_") > 0){
								     	item_id = $('#item_id').val();
									 } else {
										 if($('#item_id option:selected').val().indexOf(",")>0){
											item_id = $('#item_id option:selected').val();
										 }
										 else
										 {
											 if(parseInt($('#item_id option:selected').val())>0){
												 item_id = parseInt($('#item_id option:selected').val());	 
											 }
										 }
									}
									// alert('test'+"_"+item_type+"_"+item_id);
									$('#embed_code').val('<object width="'+player_width+'" height="'+player_height+'"><param name="allowfullscreen" value="true" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /><param name="base" value="http://www.celestronimages.com/ci-player/" /><param name="movie" value="http://www.celestronimages.com/ci-player/slideshow.swf?item_type='+item_type+'&item_id='+item_id+'&num_new_images='+num_new_images+'&player_width='+player_width+'&player_height='+player_height+'&autoStartSlideshow=Y" /><embed src="http://www.celestronimages.com/ci-player/slideshow.swf?item_type='+item_type+'&item_id='+item_id+'&num_new_images='+num_new_images+'&player_width='+player_width+'&player_height='+player_height+'&autoStartSlideshow=Y" type="application/x-shockwave-flash" allowfullscreen="true" wmode="transparent" base="http://www.celestronimages.com/ci-player/" allowscriptaccess="always" width="'+player_width+'" height="'+player_height+'"></embed></object>');
									if($('#inPage').val() == 'Y')
									{
										$('#embed_preview').html('<object width="'+ ((player_width>800)?800:player_width) +'" height="'+player_height+'"><param name="allowfullscreen" value="true" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /><param name="base" value="http://www.celestronimages.com/ci-player/" /><param name="movie" value="http://www.celestronimages.com/ci-player/PhotoGallery.swf?item_type='+item_type+'&item_id='+item_id+'&num_new_images='+num_new_images+'&player_width='+ ((player_width>800)?800:player_width) +'&player_height='+player_height+'&autoStartSlideshow=Y" /><embed src="http://www.celestronimages.com/ci-player/PhotoGallery.swf?item_type='+item_type+'&item_id='+item_id+'&num_new_images='+num_new_images+'&player_width='+ ((player_width>800)?800:player_width) +'&player_height='+player_height+'&autoStartSlideshow=Y" type="application/x-shockwave-flash" allowfullscreen="true" wmode="transparent" base="http://www.celestronimages.com/ci-player/" allowscriptaccess="always" width="'+ ((player_width>800)?800:player_width) +'" height="'+player_height+'"></embed></object>');
									}
									else
									{
										$('#embed_preview').html('<object width="'+ ((player_width>600)?600:player_width) +'" height="'+player_height+'"><param name="allowfullscreen" value="true" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /><param name="base" value="http://www.celestronimages.com/ci-player/" /><param name="movie" value="http://www.celestronimages.com/ci-player/PhotoGallery.swf?item_type='+item_type+'&item_id='+item_id+'&num_new_images='+num_new_images+'&player_width='+ ((player_width>600)?600:player_width) +'&player_height='+player_height+'&autoStartSlideshow=Y" /><embed src="http://www.celestronimages.com/ci-player/PhotoGallery.swf?item_type='+item_type+'&item_id='+item_id+'&num_new_images='+num_new_images+'&player_width='+ ((player_width>600)?600:player_width) +'&player_height='+player_height+'&autoStartSlideshow=Y" type="application/x-shockwave-flash" allowfullscreen="true" wmode="transparent" base="http://www.celestronimages.com/ci-player/" allowscriptaccess="always" width="'+ ((player_width>600)?600:player_width) +'" height="'+player_height+'"></embed></object>');
									}
									
								});
							   
							   
							   
						   });
  function embedding() {
	$("#embed_this").trigger('click');
  }

	var captcha_reload_count = 0;
	var captcha_image_url = "{url_captcha_image}";
  function new_captcha_image() {
    if (captcha_image_url.indexOf('?') == -1) {
		  document.getElementById('captcha_image').src= captcha_image_url+'?c='+captcha_reload_count;
		} else {
		  document.getElementById('captcha_image').src= captcha_image_url+'&c='+captcha_reload_count;
		}

    document.getElementById('captcha_input').value="";
    document.getElementById('captcha_input').focus();
    captcha_reload_count++;
  }

	function opendetailwindow() { 
    window.open('','detailwindow','toolbar=no,scrollbars=yes,resizable=no,width=680,height=480');
  }
  
	function updateLatLon() {
		dec_hours = Math.abs(parseFloat(document.image_form.dec_hours.value));
		dec_minutes = Math.abs(parseFloat(document.image_form.dec_minutes.value/60));
		dec_seconds = Math.abs(parseFloat(document.image_form.dec_seconds.value/3600));
		
		ra_hours = Math.abs(parseFloat(document.image_form.ra_hours.value));
		ra_minutes = Math.abs(parseFloat(document.image_form.ra_minutes.value/60));
		ra_seconds = Math.abs(parseFloat(document.image_form.ra_seconds.value/3600));
		
		image_lat = (dec_hours+dec_minutes+dec_seconds);
		if (document.image_form.dec_hours.value<0) {
			image_lat = image_lat*-1;
		}
		document.image_form.image_lat.value = image_lat
		
		
		image_lon = (ra_hours+ra_minutes+ra_seconds);
		image_lon = image_lon*15-180;
		if (document.image_form.ra_hours.value<0) {
			image_lon = image_lon*-1;
		}
		
		document.image_form.image_lon.value = image_lon;
	}

function switchDiv(elementId, bolVisible) {
	if( document.getElementById ) { var theElement = document.getElementById(elementId); } else {
	if( document.all ) { var theElement = document.all[ elementId ]; } else { var theElement = new Object(); } }
	if( !theElement ) { return; }
	if( theElement.style ) { theElement = theElement.style; }
	if( typeof( theElement.display ) == 'undefined' && !( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ) { window.alert( 'Hidden navigation will not work in this browser, for more information please contact support@kayako.com' ); return; }
	if (bolVisible == true) {
		theElement.display = 'block';
	} else {
		theElement.display = 'none';
	}
}

function ShowElement(id) {
	switchDiv(id,true);
}
function HideElement(id) {
	switchDiv(id,false);
}


