var playStr = "";
function createXmlHttpRequest()
{
	var $http_request = null;
	if(window.XMLHttpRequest) { 
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject) { 
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
			http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) { 
		return false;
	}
	return http_request;
}

function showCategory(){
	if(document.getElementById("categories").style.display == "none"){
		document.getElementById("categories").style.display="block";
	}else{
		document.getElementById("categories").style.display="none";
	}
}


function loadProductInfo(id){
	showDetail();
	var url = "show_product.php?id=" + id;
	url += "&temp="+Math.random();
	var xmlHttp = createXmlHttpRequest();
	xmlHttp.onreadystatechange = function(){
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {
				document.getElementById("msgDetail").innerHTML = xmlHttp.responseText;
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}
function loadGalleryInfo(id){
	showDetail();
	var url = "show_gallery.php?id=" + id;
	url += "&temp="+Math.random();
	var xmlHttp = createXmlHttpRequest();
	xmlHttp.onreadystatechange = function(){
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {
				document.getElementById("msgDetail").innerHTML = xmlHttp.responseText;
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}
function loadPhotosInfo(id, start){
	document.getElementById("start").value = start;
	var play = document.getElementById("play").value;
	var url = "show_photos.php?id=" + id + "&start=" + start+"&play=" + play;
	url += "&temp="+Math.random();
	var xmlHttp = createXmlHttpRequest();
	xmlHttp.onreadystatechange = function(){
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {
				document.getElementById("msgDetail").innerHTML = xmlHttp.responseText;
				if(document.getElementById("play").value == "play"){
					var total = document.getElementById("total").value;
					if(start>(total-2)){
						var newstart = 0;
					}else{
						var newstart = start + 1;
					}
					playStr = setTimeout("loadPhotosInfo(" + id + "," + newstart + ")",3000);
				}else{
					clearTimeout(playStr);
				}
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}
function showNewsInfo(id, start){
	document.getElementById("start").value = start;
	var play = document.getElementById("play").value;
	var url = "show_news.php?id=" + id + "&start=" + start+"&play=" + play;
	url += "&temp="+Math.random();
	var xmlHttp = createXmlHttpRequest();
	xmlHttp.onreadystatechange = function(){
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {
				document.getElementById("msgDetail").innerHTML = xmlHttp.responseText;
				if(document.getElementById("play").value == "play"){
					var total = document.getElementById("total").value;
					if(start>(total-2)){
						var newstart = 0;
					}else{
						var newstart = start + 1;
					}
					playStr = setTimeout("showNewsInfo(" + id + "," + newstart + ")",3000);
				}else{
					clearTimeout(playStr);
				}
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}

function gotoNewsPage(id, start){
	document.getElementById("play").value = "stop";
	showNewsInfo(id, start);
}
function playNewsPhotosInfo(id, start){
	showDetail();
	clearTimeout(playStr);
	document.getElementById("play").value = "play";
	showNewsInfo(id, start);
}


function gotoPage(id, start){
	document.getElementById("play").value = "stop";
	loadPhotosInfo(id, start);
}
function playPhotosInfo(id, start){
	showDetail();
	clearTimeout(playStr);
	document.getElementById("play").value = "play";
	loadPhotosInfo(id, start);
}


function showDetail() { 
	//±³¾°
	var bgObj=document.getElementById("bgDiv");
	bgObj.style.width = (document.body.offsetWidth -22) + "px";
	bgObj.style.height = (screen.height + 1000) + "px";
	bgObj.style.display = "block";

	//¶¨Òå´°¿Ú
	var msgObj=document.getElementById("msgDiv");
	msgObj.style.marginTop = -5 +  document.documentElement.scrollTop + document.body.scrollTop + "px";
}

function closeDetail(){
	document.getElementById("msgDetail").innerHTML = "";
	document.getElementById("bgDiv").style.display = "none";
}
function closeNailImages(){
	clearTimeout(playStr);
	document.getElementById("msgDetail").innerHTML = "";
	document.getElementById("bgDiv").style.display = "none";
	document.getElementById("play").value = "stop";
}
function playVideo(id){
	showDetail();
	var url = "show_video.php?id=" + id;
	url += "&temp="+Math.random();
	var xmlHttp = createXmlHttpRequest();
	xmlHttp.onreadystatechange = function(){
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {
				document.getElementById("msgDetail").innerHTML = xmlHttp.responseText;
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}
function   checkMail(strText)  
  {  
    var   strReg="";                  
    var   r;  
    strReg=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/i;                                              
    r=strText.search(strReg);  
    if(r==-1)  
    return false;
    else  
	return true;
  }   

