// Define the variable
var baseurl;
var notFoundImage;
var loadingImageSrc;
var TimerIDArray = new Array();
var TimerIDCount = 0;

$(document).ready(function(){
	setTimeout("$('#loading').remove()",2000);
	setTimeout("$('#wrapper').show()",3000);
	notFoundImage = baseurl+"/images/share/imgNotFound.gif";

	/***************************************************
	* Set table label width
	***************************************************/
	$("td:even").css("width","100px");
	
	/***************************************************
	* switch image (fixed for IE hover)
	***************************************************/
	$(".dialogButton button,#loginDialog button,.menu li a,.description a").hover(function(){
		$(this).switchButtonImg01();
	},function(){
		$(this).switchButtonImg02();
	});
	
	
	$("img").hover(function(){
		var bg = $(this).attr("src");
		$(this).attr("src",bg.replace(/1/gi,"2"));
	},function(){
		var bg = $(this).attr("src");
		$(this).attr("src",bg.replace(/2/gi,"1"));
	});
	
	/***************************************************
	* Setup loading image
	***************************************************/
	loadingImageSrc = baseurl+"/images/share/loading.gif";
});

/***************************************************
* Show no image
***************************************************/
$.fn.showNotFoundImage = function(){
	$(this).attr("src",notFoundImage);
	$(this).css({width:"60px",height:"60px"});
};

/***************************************************
* Convert the array to string
***************************************************/	
$.toString = function(data) {
	var str = "";
	
	for(i in data) {
		str += data[i]+",";
	}
	
	return str.replace(/,$/gi,"");
};

/***************************************************
* Switch the button image
***************************************************/	
$.fn.switchButtonImg01 = function() {
	if($(this).children("img").attr("src") == undefined) return false;
	
	var src = $(this).children("img").attr("src").replace(/01/gi,"02");
	$(this).children("img").attr("src",src);
}

$.fn.switchButtonImg02 = function() {
	if($(this).children("img").attr("src") == undefined) return false;
	
	var src = $(this).children("img").attr("src").replace(/02/gi,"01");
	$(this).children("img").attr("src",src);
};
