// JavaScript Document
//Mypod Pod page init

$(document).ready(function() {
	
	// Cat Ajax
	/* $('.cati').ajaxContent({
	  loaderType:'img',   
          loadingMsg:'/images/ajax-barloader.gif',
		  //beforeSend:function(obj,target){
          //          stp_plyr();
          // },
		  //debug: true,
	  target:'#podcontainer'
          });
*/
var ajax_load = "<img src='/images/ajax-barloader.gif' alt='loading...' />"; 
var return_value = "false"; 
$('a.cati').click(function() {
	var href = $(this).attr('href');
	//$("#podcontainer").html(ajax_load).load(href, function(response, status, xhr) {
	$("#podcontainer").load(href,'', function(response, status, xhr) {
	  if ( response.length == 0 ){
	    return_value = "true";
	  }
	//alert( response.length +'~' + return_value);
	  if (status == "error") {
			var msg = "Sorry but there was an error: ";
			
		   alert(msg + xhr.status + " " + xhr.statusText);
	  }
	   //alert(xhr.status + "~" + xhr.statusText +"~" + response+ "~" + status + response.length);
    });
	if ( return_value === "false" ){
	    return false;
	} 
	/* TryAgain,,to test
	 else { $("#podcontainer").load(href,'', function(response, status, xhr) {
			if ( response.length == 0 ){ return_value = "true"; } });
			if ( return_value === "false" ){return false;}	
	}
	*/
});
    	// open window
	$('a.newwin').click(function() {
    var href = $(this).attr('href');
    window.open(href, 'AD',
    'height=600,width=600,scrollbars=yes,toolbar=no');
    return false;

  });
  
	// password
	$('#password-clear').show();
    $('#Password').hide();

    $('#password-clear').focus(function() {
		$('#password-clear').hide();
		$('#Password').show();
		$('#Password').focus();
	}); 

    if ( ($.browser.msie && $.browser.version <= 6) )
    {
		 $("ul.dropdown li").dropdown(); /* For dropdown css */
		 $('#backgroundPopup').show();
	     $("#prereg").dialog({ modal: true, hide: 'close', height: 440, width: 800 });
	} else {
		if(  $('#prereg').is(":visible") ){
			$('#login').hide();
		} else {
			$('#login').show();
		}
	}

	// end onload	   
});

// Dropdown Function if less than ie6
$.fn.dropdown = function() {

	$(this).hover(function(){
		$(this).addClass("hover");
		$('> .dir',this).addClass("open");
		$('ul:first',this).css('visibility', 'visible');
	},function(){
		$(this).removeClass("hover");
		$('.open',this).removeClass("open");
		$('ul:first',this).css('visibility', 'hidden');
	});

}

