
$(document).ready(function() {
		$('#allProduct').load('/platform2/jsp/mall/controls/tp_menu.html').hide();
		$('#use_Testimonials').load('/platform2/jsp/mall/controls/main_testimonials.html');
		//$('#use_Testimonials').load('/platform2/servlet/Command.do?part=admin.user.UserManager&cmd=adminProductReMainList&nextPage=admin/user/reviewMain');
		//TopBannerRotate();
		//logoReplace();
		$('#allview').click(function() {
	
			//alert(document.getElementById("allview").src.indexOf("/tp_title.gif"));
			if(document.getElementById("allview").src.indexOf("/tp_title.gif") > 0){
				//$('#allProduct').show(500);
				
				$('#allProduct').slideDown();
				
				document.getElementById("allview").src = "/platform2/images/KR/mall/renewal/common/tp_title_on.gif";
				MainControl("down");
			}
				
			else{
				//$('#allProduct').hide(500).fadeOut();
				$('#allProduct').slideUp();
				document.getElementById("allview").src = "/platform2/images/KR/mall/renewal/common/tp_title.gif";
				MainControl("up");
			}
		});
	});
	
	function MainControl(updown)
	{
		if(document.getElementById("mainSliderLeft") != null && typeof document.getElementById("mainSliderLeft") != "undefined")
		{
			if(updown == "up")
				fnLayerOffset(-300);
			else
				fnLayerOffset(300);
		}
	}

	function fnLayerOffset(positionnum)
	{

	var h = jsFindoffsetTop(document.getElementById("mainSliderLeft"));
	var h2 = jsFindoffsetTop(document.getElementById("subSliderLeftNavi"));
	var h3 = jsFindoffsetTop(document.getElementById("divOrder"));
	var h4 = jsFindoffsetTop(document.getElementById("gallery_thump"));
	document.getElementById("mainSliderLeft").style.top = h + positionnum + "px";
	document.getElementById("mainSliderRight").style.top = h + positionnum + "px";
	document.getElementById("subSliderLeftNavi").style.top = h2 + positionnum + "px";
	document.getElementById("subsliderRightNavi").style.top = h2 + positionnum + "px";
	document.getElementById("divOrder").style.top = h3 + positionnum + "px";
	document.getElementById("gallery_thump").style.top = h4 + positionnum + "px";
	
	}


	function logoReplace()
	{
		var today = new Date();
			var year  = today.getYear();
			var month = today.getMonth() + 1;
			if(month.length < 2)
			{
				month = "0" + month;
			}
			var date  = today.getDate();
			if(date.length < 2)
			{
				date = "0" + date;
			}
			var nowday = year + "-" + month + "-" + date;
			var intHours = today.getHours();
			var intMinutes = today.getMinutes();
			var week = today.getDay();

			if((nowday == "2009-08-23" || nowday == "2009-8-23") && (location.href.toLowerCase() == "http://www.snaps.co.kr/" || location.href.toLowerCase() == "http://www.snaps.co.kr/default.aspx"))
			{
				if(intHours > 8 && intHours < 19)
				{
					document.getElementById("top_logo").src = "/images/sn_ci.gif";
				}
				else
				{
					document.getElementById("top_logo").src = "/platform2/KR/mall/images/renewal/common/sn_ci.gif";
				}
			}
			else
			{
				document.getElementById("top_logo").src = "/platform2/KR/mall/images/renewal/common/sn_ci.gif";
			}
	}

	/*
	function TopBannerRotate()
	{
		var roate_num = Math.floor(Math.random() * 7) ;
		var alink     = new Array("/platform2/jsp/mall/event/EditEvent.jsp", 
                                          "/platform2/servlet/Command.do?part=nanum.GoodNeighbros&cmd=getgoodNeighbors&nextPage=nanum/goodNeighbors", 
                                          "/platform2/servlet/Command.do?part=blank&cmd=blank&nextPage=mall/customerSupport/snapsMoneyBackInfo",
                                          "/platform2/servlet/Command.do?part=mall.board.userBoard&cmd=getBoardList&nextPage=mall/customerSupport/customerTipList&boardId=030013",
                                          "/platform2/jsp/sub.jsp?categorycode=0570010002", 
                                          "/platform2/jsp/mall/event/Frame_Summer.jsp",
                                          "/platform2/jsp/mall/event/mom_membership.jsp");
		var alimgurl  = new Array("top_event02.gif",
                "top_event04.gif",
                "top_event09.gif",
                "top_event06.gif",
                "top_event11.gif",
                "top_event13.gif",
                "top_event_31.gif"
                );
		document.getElementById("topbannerArea").innerHTML = "<a href='http://www.snaps.co.kr"+alink[roate_num]+"'><img src='/platform2/images/KR/mall/renewal/topbanner/"+alimgurl[roate_num]+"' /></a>";
		
		TopBannerRotate2();
	}
	*/
	
	
	function TopBannerRotate2()
	{
		var roate_num = Math.floor(Math.random() * 1) ;
		//var alink		= new Array("/platform2/jsp/mall/event/smartphoto_font.jsp");
		var alink		= new Array("/platform2/servlet/Command.do?part=mall.event.EventGallery&cmd=getGalleryEventList&nextPage=mall/event/201106/animalLoveList&gpCode=1002");
		//var alimgurl	= new Array("top_event21.gif");
		var alimgurl	= new Array("top_event01.gif");
		document.getElementById("topbannerArea2").innerHTML = "<a href='http://www.snaps.co.kr"+alink[roate_num]+"'><img src='/platform2/images/KR/mall/renewal/topbanner/"+alimgurl[roate_num]+"' /></a>";
	}
	
	
	$(function() {
		$("#accordion").accordion({
			header: "h3"
		});
	});
	
	function openCart()
	{
		open_OCX_Cart('http://www.snaps.co.kr/platform2/jsp/mall/smartphoto/SmartPhoto2.5.jsp?ProductCode=008001&Tdata=&popup=cart','SmartPhoto','width=1008,height=676');
	}

	function openSmartPhoto()
	{
		open_OCX_Cart('http://www.snaps.co.kr/platform2/jsp/mall/smartphoto/SmartPhoto2.5.jsp?ProductCode=&Tdata=','SmartPhoto','width=1008,height=676');
	}

	function openSmartPhoto2()
	{
		open_OCX_Cart2('http://www.snaps.co.kr/platform2/jsp/mall/smartphoto/SmartPhoto2.5.jsp?ProductCode=&Tdata=','SmartPhoto2','width=1008,height=676');
	}

	var popup = "";
	function open_OCX_Cart(theURL,winName,features) { //v2.0
		if(!popup.closed && popup)
		{
			alert("스마트포토가 이미 실행중입니다");
			popup.focus();
			return;
		}
		else
		{
			if($.browser.msie)
			{
				popup = window.open(theURL.replace("smartPhoto.jsp","SmartPhoto2.5.jsp").replace("SmartPhoto2.0.jsp","SmartPhoto2.5.jsp"),winName,"width="+(screen.width-10)+",height="+(screen.height-80)+",resizable=yes,left=0,top=0'");
				popup.focus();
			}
			else{
				parent.snaps_show('/platform2/jsp/mall/brower.jsp','iframe', 505, 545, true);
			}
		}
	}

	var popup2 = "";
	function open_OCX_Cart2(theURL,winName,features) { //v2.0
		if(!popup2.closed && popup2)
		{
			alert("스마트포토가 이미 실행중입니다");
			popup2.focus();
			return;
		}
		else
		{
			if($.browser.msie)
			{
				popup = window.open(theURL.replace("smartPhoto.jsp","SmartPhoto2.5.jsp").replace("SmartPhoto2.0.jsp","SmartPhoto2.5.jsp"),winName,"width="+(screen.width-10)+",height="+(screen.height-80)+",resizable=yes,left=0,top=0'");
				popup.focus();
			}
			else{
				parent.snaps_show('/platform2/jsp/mall/brower.jsp','iframe', 505, 545, true);
			}
		}
	}
	
	function open_OCX(theURL,winName,features) { //v2.0
		if(!popup.closed && popup)
		{
			alert("스마트포토가 이미 실행중입니다");
			popup.focus();
			return;
		}
		else
		{
			if($.browser.msie)
			{
				popup = window.open(theURL.replace("smartPhoto.jsp","SmartPhoto2.5.jsp").replace("SmartPhoto2.0.jsp","SmartPhoto2.5.jsp"),winName,"width="+(screen.width-10)+",height="+(screen.height-80)+",resizable=yes,left=0,top=0'");
				popup.focus();
			}
			else{
				parent.snaps_show('/platform2/jsp/mall/brower.jsp','iframe', 505, 545, true);
			}
		}
	}


	function OpenPopupPublicSub(opeurl, height, width, scroll)
	{
		window.open(opeurl,'openwindow', 'toolbar=no, status=no, location=no, directories=no, menubat=no, scrollbars=' + scroll + ', resizable=no, left=' + (screen.width - width) / 2 + ',top=' + (screen.height - height) / 2 + ', width='+width+', height='+height);
	}
	
	
	function myCallBackPublic(msg, gourl)
	{
		if(msg == "false")
		{
			alert("로그인이 필요합니다. 로그인페이지로 이동합니다.");
			//B_Contents.OpenBottomLayerPublic();
			location.href = "http://www.snaps.co.kr/platform2/servlet/Command.do?part=blank&cmd=blank&nextPage=mall/user/login&url=" + gourl;
			return false;
		}
		else
		{
			location.href = gourl;
		}
	}
					
	function LoginChkPublic(gourl)
	{
		try
		{
			$.get('/platform2/servlet/Command.do?part=mall.user.UserManager&cmd=loginChkPorc&nextPage=ajax', {'gourl': gourl}, function(data){
				myCallBackPublic(data, gourl);
			});
		}
		catch(e)
		{
			alert("실패!");
		}
	}
	
	
	function myCallBackPublicCart(msg, gourl)
	{
		if(msg == "false")
		{
			alert("로그인이 필요합니다. 로그인페이지로 이동합니다.");
			location.href = "http://www.snaps.co.kr/platform2/servlet/Command.do?part=blank&cmd=blank&nextPage=mall/user/login&url=" + gourl;
			return false;
		}
		else
		{
			location.href = gourl;
		}
	}
					
	function LoginChkPublicCart(gourl)
	{
		try
		{
			$.get('/platform2/servlet/Command.do?part=mall.user.UserManager&cmd=loginChkPorcCart&nextPage=ajax', {'gourl': gourl}, function(data){
				myCallBackPublicCart(data, gourl);
			});
		}
		catch(e)
		{
			alert("실패!");
		}
	}
	
	
	function myCallBackPublicConfirm(msg, gourl)
	{
		if(msg == "false")
		{
			if(confirm("로그인이 필요합니다. 로그인페이지로 이동하시겠습니까?"))
				location.href = "http://www.snaps.co.kr/platform2/servlet/Command.do?part=blank&cmd=blank&nextPage=mall/user/login&url=" + gourl;
			return false;
		}
		else
		{
			location.href = gourl;
		}
	}
					
	function LoginChkPublicConfirm(gourl)
	{
		try
		{
			$.get('/platform2/servlet/Command.do?part=mall.user.UserManager&cmd=loginChkPorc&nextPage=ajax', {'gourl': gourl}, function(data){
				myCallBackPublicConfirm(data, gourl);
			});
		}
		catch(e)
		{
			alert("실패!");
		}
	}
	
	function goLogin()
	{
		if ( document._loginForm == null )
		{
			parent.location.href = "http://www.snaps.co.kr/platform2/servlet/Command.do?part=blank&cmd=blank&nextPage=mall/user/login";
		}
		else
		{
			parent.document._loginForm.submit();
		}
	}

	var layerHiding = true;
	function MySnapsLayer(layerid, view)
	{
		var obj=document.getElementById(layerid);
			
		if(view == "none")
		{
			layerHiding = true;
			//setTimeout(function(){obj.style.display  = "none";}, 1000);
			setTimeout(function(){if(layerHiding)obj.style.display = "none";layerHiding=false}, 100);
		}
		else
		{
			layerHiding = false;
			obj.style.display=view;
		}
	}

	function isInstalledActiveX()  
	{
		var installed=false;
		var AxObject = "";
		var xObj= null;
		//이미 스마트포토2.0깔려있다면...
		AxObject = "DCSetup.DCSetupCtl.1";
		try
		{
			if(window.ActiveXObject){
				xObj=new ActiveXObject(AxObject);
				if(xObj)
				{
					installed=true;
				}
				else
				{
					AxObject = "DCFront2.DCFront2Ctl.1";
					xObj= null;
					try
					{
						xObj=new ActiveXObject(AxObject);
						if(xObj)
							installed=true;
						else
							installed=false; 
						
					}catch(e){
						installed=false;
					}
				}
			}
			else{
				installed=false; 
			}
		}catch(e){
			installed=false;
		}
			
		return installed;
	}
	
	function getCookie( name )
	{
		var nameOfCookie = name + "=";
		var x = 0;
		while ( x <= document.cookie.length )
		{
			var y = (x+nameOfCookie.length);
			if ( document.cookie.substring( x, y ) == nameOfCookie )
			{
				if( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
					endOfCookie = document.cookie.length;
				return unescape( document.cookie.substring( y, endOfCookie ) );
			}
			x = document.cookie.indexOf( " ", x ) + 1;
			if ( x == 0 )
				break;
		}
		return "";
	}

	
	function getStringSplit(urlstring, valuename, startChar, endChar)
    {
        var rtnval = "";
        var nowAddress = urlstring;
        var parameters = (nowAddress.slice(nowAddress.indexOf(startChar)+1,nowAddress.length)).split(endChar);
        
        for(var i = 0 ; i < parameters.length ; i++){
            var varName = parameters[i].split("=")[0];
            if(varName.toUpperCase() == valuename.toUpperCase())
            {
                rtnval = parameters[i].split("=")[1];
                break;
            }
        }
        return rtnval;
    }




// 스마트포토 라이트 실행
	function openSPLite(prjcode) {
		var theURL = '/platform2/jsp/mall/smartphoto/SmartPhotoLite.jsp?projCode='+prjcode;
		var winName = 'SmartPhoto';
		if(!popup.closed && popup)
		{
			alert("스마트포토라이트가 이미 실행중입니다");
			popup.focus();
			return;
		}
		else
		{
			//SmartPhoto Lite
			popup = window.open(theURL,winName,"width="+(screen.width-10)+",height="+(screen.height-80)+",resizable=yes,left=0,top=0'");
			popup.focus();
		}
	}
	
	// 스마트포토 편집대행 실행
	function openSPEA(sclssCode) {
		var theURL = '/platform2/jsp/mall/smartphoto/SmartPhotoEA.jsp?sclssCode='+sclssCode;
		var winName = 'SmartPhoto';
		if(!popup.closed && popup)
		{
			alert("스마트포토가 이미 실행중입니다");
			popup.focus();
			return;
		}
		else
		{
			var ww = screen.width - 1024;
			var hh = screen.height - 768;
			var xx = 0;
			var yy = 0;
			
			if ( ww > 0 )
				xx = ww / 2;
			if ( hh > 0 )
				yy = hh / 2;

			//SmartPhoto EditAgency
			//popup = window.open(theURL,winName,"width=1024,height=768,resizable=yes,left=" + xx + ",top=" + yy + "'");
			popup = window.open(theURL,winName,"width="+(screen.width-10)+",height="+(screen.height-80)+",resizable=yes,left=0,top=0");
			popup.focus();
		}
	}

