﻿var xmlHttp;
var div_name
function createXMLHttpRequest() {

	if (window.ActiveXObject) {

		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

	}

	else if (window.XMLHttpRequest) {

		xmlHttp = new XMLHttpRequest();

	}

}


    function get_tag(url,l_name) {
		div_name = l_name;
		eval("document.all."+div_name+".innerHTML='loading ...'");
		
		createXMLHttpRequest();

        if (!xmlHttp) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        xmlHttp.onreadystatechange = output_code;
        xmlHttp.open('GET', url, true);
        xmlHttp.send(null);

    }



    function get_emule_list(url,l_name) {

		if(document.all.emule_list_is_loaded.value=="")
		{	

			div_name = l_name;
			//eval("document.all."+div_name+".innerHTML=\"<img src='images/loading_icon.gif' align='absmiddle'> Loading ...\"");
			
			createXMLHttpRequest();

			if (!xmlHttp) {
				alert('Giving up :( Cannot create an XMLHTTP instance');
				return false;
			}

			xmlHttp.onreadystatechange = output_code;
			xmlHttp.open('GET', url, false);
			xmlHttp.send(null);
			document.all.emule_list_is_loaded.value="yes";
			}

    }


    function join_check_id() {

	div_name = "check_id_msg";
	url="check_id.php?id="+document.join_form.id.value;
	//eval("document.all."+div_name+".innerHTML=\"<img src='images/loading_icon.gif' align='absmiddle'> Loading ...\"");
	
	createXMLHttpRequest();

	if (!xmlHttp) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}

	xmlHttp.onreadystatechange = output_code;
	xmlHttp.open('GET', url, true);
	xmlHttp.send(null);

	//document.all.emule_list_is_loaded.value="yes";

    }

    function check_nick_name() {

	div_name = "check_nickNname_msg";
	url="check_id.php?mode=nick_name&id="+encodeURI(document.join_form.nick_name.value);
	//eval("document.all."+div_name+".innerHTML=\"<img src='images/loading_icon.gif' align='absmiddle'> Loading ...\"");
	
	createXMLHttpRequest();

	if (!xmlHttp) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}

	xmlHttp.onreadystatechange = output_code;
	xmlHttp.open('GET', url, true);
	xmlHttp.send(null);

	//document.all.emule_list_is_loaded.value="yes";

    }

    function output_code() {

        if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200) {
					eval("document.all."+div_name+".innerHTML=xmlHttp.responseText;");
            } else {
					
                alert('There was a problem with the request.');
				
            }
        }

    }

    function output_code_2() {

        if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200) {
					eval(div_name+".innerHTML=xmlHttp.responseText;");
            } else {
					
                alert('There was a problem with the request.');
				
            }
        }

    }

    

function load_comment(programe_no,page,win)
{
	div_name = "comment_content_area";
	url="get_comment.php?programe_no="+programe_no+"&page="+page;
	//eval("document.all."+div_name+".innerHTML=\"<img src='images/loading_icon.gif' align='absmiddle'> Loading ...\"");
	
	createXMLHttpRequest();

	if (!xmlHttp) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	
	if(win=="parent")
	xmlHttp.onreadystatechange = output_code_2;
	else
	xmlHttp.onreadystatechange = output_code;

	xmlHttp.open('GET', url, false);
	xmlHttp.send(null);

	//document.all.emule_list_is_loaded.value="yes";
	
}

function load_bbs_comment(board_id,no,page,win)
{
	div_name = "comment_content_area";
	url="get_bbs_comment.php?board_id="+board_id+"&no="+no+"&page="+page;
	//eval("document.all."+div_name+".innerHTML=\"<img src='images/loading_icon.gif' align='absmiddle'> Loading ...\"");
	
	createXMLHttpRequest();

	if (!xmlHttp) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	
	if(win=="parent")
	xmlHttp.onreadystatechange = output_code_2;
	else
	xmlHttp.onreadystatechange = output_code;

	xmlHttp.open('GET', url, false);
	xmlHttp.send(null);

	//document.all.emule_list_is_loaded.value="yes";
	
}

function load_mypro(win)
{
	div_name = "mypro_area";
	url="get_mypro.php";
	//eval("document.all."+div_name+".innerHTML=\"<img src='images/loading_icon.gif' align='absmiddle'> Loading ...\"");
	
	createXMLHttpRequest();

	if (!xmlHttp) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	
	if(win=="parent")
	xmlHttp.onreadystatechange = output_code_2;
	else
	xmlHttp.onreadystatechange = output_code;

	xmlHttp.open('GET', url, false);
	xmlHttp.send(null);

	//document.all.emule_list_is_loaded.value="yes";
	
}

function load_view_pro(win)
{
	div_name = "my_view_pro_area";
	url="my_view_pro.php";
	//eval("document.all."+div_name+".innerHTML=\"<img src='images/loading_icon.gif' align='absmiddle'> Loading ...\"");
	
	createXMLHttpRequest();

	if (!xmlHttp) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	
	if(win=="parent")
	xmlHttp.onreadystatechange = output_code_2;
	else
	xmlHttp.onreadystatechange = output_code;

	xmlHttp.open('GET', url, false);
	xmlHttp.send(null);

	//document.all.emule_list_is_loaded.value="yes";
	
}

function load_video_list(programe_no)
{
	div_name = "video_list_area";
	url="get_video_list.php?no="+programe_no;
	//eval("document.all."+div_name+".innerHTML=\"<img src='images/loading_icon.gif' align='absmiddle'> Loading ...\"");
	
	createXMLHttpRequest();

	if (!xmlHttp) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	
	
	xmlHttp.onreadystatechange = output_code_2;
	
	xmlHttp.open('GET', url, false);
	xmlHttp.send(null);

	//document.all.emule_list_is_loaded.value="yes";
	
}


/*
function online()
{
	today=new Date(); 

	//alert("ok");
	div_name = "online_area";
	url="online.php?time="+today.getSeconds();
	createXMLHttpRequest();
	
	if (!xmlHttp) {
		alert('사이트 접속에 문제가 있습니다!');
		return false;
	}
		
	//xmlHttp.onreadystatechange = output_code;
	
	xmlHttp.open('GET', url, false);
	xmlHttp.send(null);

}

*/
function online()
{
	today=new Date(); 
	url="online.php?time="+today.getSeconds();
	$.get(url,function (str){});
}

function get_rating(pro_no)
{
	var str="";
	url="get_rating.php?no="+pro_no;
	$.get(url,function (str){
	
	parent.document.getElementById("rating_area").innerHTML=str;
	});
	 

}


