function fixPng() {
  var arVersion = navigator.appVersion.split("MSIE")
  var version = parseFloat(arVersion[1])

  if ((version >= 5.5 && version < 7.0) && (document.body.filters)) {
    for(var i=0; i<document.images.length; i++) {
      var img = document.images[i];
      var imgName = img.src.toUpperCase();
      if (imgName.indexOf(".PNG") > 0) {
        var width = img.width;
        var height = img.height;
        var sizingMethod = (img.className.toLowerCase().indexOf("scale") >= 0)? "scale" : "image"; 
        img.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src.replace('%23', '%2523').replace("'", "%27") + "', sizingMethod='" + sizingMethod + "')";
        img.src = "images/blank.gif";
        img.width = width;
        img.height = height;
        }
      }
    }
  }

(function($){

	$(function(){
		fixPng();


		$('.focusinput').each(function(index,item){
			var self = this;
			var self_text = $(this).attr('value');
			$(this).focus(function(){
				if($(this).val() == self_text ){
					$(self).val('');
				}
			});
			$(this).blur(function(){
				if($(this).val() == self_text || $.trim($(this).val()) == ''){
					$(self).val(self_text);
				}
			});
		});

		// lfs down
		$('#lfs-down').bind('click', function(){
			$('#flink4').animate({
				bottom: '-=133',
				width: '100%'
			}, 500);
		});
		var lfsdown = function(){
			if ( $('#flink4').css('bottom') == '0px'){
				$('#lfs-down').click();
			}
		}
		setTimeout(lfsdown, 3000);

		// lfs up
		$('#lfs-up').bind('mouseover', function(){
			$('#flink4').animate({
				bottom: '+=133',
				width: '100%'
			}, 500);
		});



		// add nav active
		var url = window.location.href;
		var last_index = url.lastIndexOf('/');
		var file_name = url.substr(last_index+1);
		//alert(url.substr(last_index+1));
		if ( file_name == 'love.php'){
			$('#nav1').addClass('active');
		}
		if ( file_name == 'recommend.php'){
			$('#nav2').addClass('active');
		}
		if ( file_name == 'rules.php'){
			$('#nav3').addClass('active');
		}
		if ( file_name == 'list.php'){
			$('#nav4').addClass('active');
		}



		$.ajax({
			url: "/services/rest?method=system.connect",
			success: function(xml){
				var msg =  $(xml).find('name').text();
				var pagename = $('#user_msg').attr('pagename');
				if(msg){
					$('#user_msg').html('欢迎您 '+msg+'<a href="/logout?destination='+pagename+'"> 登出</a>');
				}else{
					//$('#user_msg').html('<a href="/user/register?destination=kate_color/'+pagename+'">注册</a><b>/</b><a href="/user?destination=kate_color/'+ pagename +'">登录</a>');
					$('#user_msg').html('<a href="/user?destination=xmas.php">注册</a><b>/</b><a href="/user?destination=xmas.php">登录</a>');
				}
			}
		});


	});



})(jQuery);

