// JavaScript Document

function Msg(message){
	$("#InfoBarArea").empty().append(message);
	$("#InfoBarArea").fadeIn(100);
	setTimeout( function() { $("#InfoBarArea").fadeOut(1000 * 2); }, 1000*5 );
}

function SetCookie (name, value) {
	var argv=SetCookie.arguments;
	var argc=SetCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	
	document.cookie=name+"="+escape(value)+
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? "" : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "");
}

function Get_Cookie( check_name ) {
	var a_all_cookies = document.cookie.split( ";" );
	var a_temp_cookie = "";
	var cookie_name = "";
	var cookie_value = "";
	var b_cookie_found = false;
	
	for ( i = 0; i < a_all_cookies.length; i++ ){
		a_temp_cookie = a_all_cookies[i].split( "=" );
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, "");
		
		if ( cookie_name == check_name ){
			b_cookie_found = true;
			
			if ( a_temp_cookie.length > 1 ){
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, "") );
			}
			
			return cookie_value;
			break;
		}
		
		a_temp_cookie = null;
		cookie_name = "";
	}
	
	if ( !b_cookie_found ){	return null;}
}

function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function Dialog(name){
	$("*").dialog("destroy");
	$("#"+name).dialog({
		width:750,
		resizable: false,
		draggable: true,
		hide:{effect : "slide",duration: 300 },
		show:{effect : "slide",duration: 300 }
	});
}

function Modal(name){
	$("*").dialog("destroy");
	$("#"+name).dialog({
		width:750,
		resizable: false,
		draggable: false,
		modal:true,
		hide:{effect : "slide",duration: 300 },
		show:{effect : "slide",duration: 300 }
	});
}
