//--- This part needs to be snipped out into a resource folder

var sliderDialogTitle = "";
        
function createDivDialog(dialogTitle, dialogDivID, dialogWrapperDivID, dialogWidth, dialogTop, iframeheight,url)
{
    var dWrap = document.getElementById(dialogWrapperDivID);
    var hF = document.getElementById(dialogWrapperDivID + 'Frame');
    var isIE = navigator.appName.indexOf("Internet Explorer");

    if(dWrap.style.visibility == 'visible'){
        dWrap.style.visibility = 'hidden';
        dWrap.style.display = 'none';    
        hF.style.visibility = 'hidden';
        hF.style.display = 'none';          
    }
    var dialogContent = document.getElementById(dialogDivID).innerHTML;
    var a = '<div class="dialogBox" style="width:' + dialogWidth + 'px;z-index:101"><table border="0" cellspacing="0" width="' + dialogWidth + '" cellpadding="2"><tr class="dialogTitle" style="background: url(images/dialogbox_titlebackground.gif) repeat-x;" onmousedown=myMouseDown(window.event,"'+dialogWrapperDivID+'")>';
    a += '<td><div style="padding:2px;padding-left:5px;" >' + dialogTitle + '</div></td><td align="right"><a href="javascript:closeDivDialog(\''+ dialogWrapperDivID +'\');"><img src="images/icon_red_x.gif" border="0" hspace="6"></a></td>';
    a += '</tr><tr><td colspan="2"><div style="padding:5px;z-index:200;">' + dialogContent;
    a += '</div></td></tr></table></div>';

    if(isIE != -1) {
    	 dialogWidth = dialogWidth - 15;
    }	 

    if(iframeheight) 
    {
        a += '<div id="' + dialogWrapperDivID + 'shadow" class="dialogBoxShadow" style="width:' + dialogWidth + 'px;height:' + (parseInt(document.getElementById("sIframe").height) + 47) + 'px;"><table border="0" cellspacing="0" width="' + dialogWidth + '" cellpadding="2"><tr class="dialogTitleShadow">';        
        dialogContent = '<img id="shadowPadImg" src="/images/pixel.gif" height="' + document.getElementById("sIframe").height + '" width="' + dialogWidth + '" />';
    }
    else
    {
        a += '<div id="' + dialogWrapperDivID + 'shadow" class="dialogBoxShadow" style="width:' + dialogWidth + 'px;"><table border="0" cellspacing="0" width="' + dialogWidth + '" cellpadding="2"><tr class="dialogTitleShadow">';
    }
    a += '<td><div style="padding:2px;padding-left:5px;">' + dialogTitle + '</div></td><td align="right"><div style="padding:2px;"></div></td>';
    a += '</tr><tr><td colspan="2"><div style="padding:5px;">' + dialogContent;
    a += '</div></td></tr></table></div>';
    a =  a.replace("about:blank",url);
    dWrap.innerHTML = a;

    dWrap.style.left = document.getElementById('mainCanvas').offsetLeft + (document.getElementById('mainCanvas').offsetWidth / 2) - (dialogWidth / 2) + 'px';

    if(isIE != -1)
    {
        dWrap.style.top = document.documentElement.scrollTop + dialogTop + 'px';
        document.getElementById(dialogWrapperDivID + 'shadow').style.top = 1;
        document.getElementById(dialogWrapperDivID + 'shadow').style.left = 1;
    }
    else
    {
        dWrap.style.top = window.pageYOffset + dialogTop + 'px';    
    }
    dWrap.style.display = 'block';
    if(isIE != -1)
    {
        if(dialogDivID == 'sliderDialog') 
        {
            hF.style.height = 50;
            //hF.style.width = dialogWidth + 13;
        }
        else
        {
            hF.style.height = dWrap.offsetHeight - 11;
            //hF.style.width = dialogWidth + 8;
        }
        hF.style.left = dWrap.offsetLeft;
        hF.style.top = dWrap.offsetTop;
        hF.style.visibility = 'visible';
        hF.style.display = 'block';
    }
    dWrap.style.visibility = 'visible';
}

	function closeDivDialog(dialogWrapperDivID)
	{
	    var hF = document.getElementById(dialogWrapperDivID + 'Frame');
	    hF.style.visibility = 'hidden';
	    hF.style.display = 'none'; 
	    document.getElementById(dialogWrapperDivID).style.visibility = 'hidden';
	    document.getElementById(dialogWrapperDivID).style.display = 'none';
	    try
	    {
	      document.getElementById('flower').style.display = ''
	    }catch(ex)
	    {
	    
	    }
	}
	
	function closeDivDialogParent(dialogWrapperDivID)
	{
	    var hF = window.parent.document.getElementById(dialogWrapperDivID + 'Frame');
	    hF.style.visibility = 'hidden';
	    hF.style.display = 'none'; 
	    window.parent.document.getElementById(dialogWrapperDivID).style.visibility = 'hidden';
	    window.parent.document.getElementById(dialogWrapperDivID).style.display = 'none';
	}
    
	function showViewChanger(city,storename)
	{
		var storenamecode = UrlEncode(storename); 
		var url = "/store/searchstore.html?city="+city+"&storename="+storenamecode ; 
	    createDivDialog(sliderDialogTitle,'sliderDialog','dBW2', 405, 200, 287,url);
	}

	
	function openWin(title,url) {
		sliderDialogTitle = title ;	
  			  	var val = 0;
			if(typeof ActiveXObject != "undefined"){
				val = document.body.scrollTop;
			}
	   	
	    createDivDialog(sliderDialogTitle,'sliderDialog','dBW2', 405, val, 287,url);
	}
	function openWin1(title,url) {
		sliderDialogTitle = title ;	
  			  	var val = 0;
			if(typeof ActiveXObject != "undefined"){
				val = document.body.scrollTop;
			}
	   	
	    createDivDialog(sliderDialogTitle,'sliderDialog','dBW2', 400, val, 400,url);
	}
	function openWin2(title,url) {
		sliderDialogTitle = title ;	
  			  	var val = 0;
			if(typeof ActiveXObject != "undefined"){
				val = document.body.scrollTop;
			}
	   	
	    createDivDialog(sliderDialogTitle,'sliderDialog','dBW2', 400, val, 150,url);
	}
	
	function openWinWithCustomer(title,url,dialogwidth,dialogheight) {
		  sliderDialogTitle = title ;	
    	createDivDialog(sliderDialogTitle,'sliderDialog','dBW2',dialogwidth, dialogheight, dialogheight,url);		  	
	}
	
	function openFeedbackWin(title,url,dialogwidth,dialogheight) {
		    sliderDialogTitle = title ;	
	  		var val = 0;
			if(typeof ActiveXObject != "undefined"){
				val = document.body.scrollTop;
			}
			try
			{
			 createDivDialog(sliderDialogTitle,'feedbackDialog','dBW2',dialogwidth, val, dialogheight,url);
			}catch(ex)
			{
			 alert(ex);
			}
			try
			{ 
			    document.getElementById('flower').style.display = 'none';
			
			}catch(ex)
			{
			 
			}
	    	
	    		  	
	}
	
	//fooddeity temp
	function openFeedbackWin2(title,url,dialogwidth,dialogheight) {
		    sliderDialogTitle = title ;	
	  		var val = 0;
			if(typeof ActiveXObject != "undefined"){
				val = document.body.scrollTop;
			}
			try
			{
			 createDivDialog(sliderDialogTitle,'feedbackDialog2','dBW2',dialogwidth, val, dialogheight,url);
			}catch(ex)
			{
			   
			}
			try
			{
			   document.getElementById('flower').style.display = 'none';
			}catch(ex)
			{
			 
			}
				
	    		  	
	}
	
	
	function openAddWin(title,url,dialogwidth,dialogheight) {
	       sliderDialogTitle = title ;		    
		 createDivDialog(sliderDialogTitle,'feedbackDialog','dBW2',dialogwidth, dialogheight, 0,url);
		
	}
	
	function openAppraisementFeedbackWin(title,url,dialogwidth,dialogheight){
	        sliderDialogTitle = title ;       
		  	var val = 0;
			if(typeof ActiveXObject != "undefined"){
				val = document.body.scrollTop;
			}
			try
			{
			   document.getElementById('flower').style.display = 'none';
			}
			catch(ex)
			{
			
			}
	    	createDivDialog(sliderDialogTitle,'dianpinJudgeDialog','dBW2',dialogwidth,val,dialogheight,url);
	    	
	}
	
	function opendianpinWin(title,url,dialogwidth,dialogheight) {
		    sliderDialogTitle = title ;	
	    	createDivDialog(sliderDialogTitle,'dianpinDialog','dBW2',dialogwidth, 0, dialogheight,url);		  	
	}
	
	function openfooddeityWin(title,url,dialogwidth,dialogheight) {
		    sliderDialogTitle = title ;	

		  	var val = 0;
			if(typeof ActiveXObject != "undefined"){
				val = document.body.scrollTop;
			}
	    	createDivDialog(sliderDialogTitle,'fooddeityDialog','dBW2',dialogwidth,val,0,url);		  	
	}

   function openTour(URL,title)
    {
        var leftPos = document.getElementById('mainCanvas').offsetLeft + (document.getElementById('mainCanvas').offsetWidth / 2) - (720 / 2) + 'px';
        tourWindow = window.open(URL, "tinyWindow", 'left=200px,top=200px,width=500px,height=400px,toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0') 
    }
	
	function getCookie(name)
	{
		var dc = document.cookie;
		var prefix = name + "=";
		var begin = dc.indexOf("; " + prefix);
		if (begin == -1)
		{
			begin = dc.indexOf(prefix);
			if (begin != 0) return null;
		}
		else
		{
			begin += 2;
		}
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
		{
			end = dc.length;
		}
		return unescape(dc.substring(begin + prefix.length, end));
	}


    var Obj=null;    

    function myMouseDown(event,obj)    
    {
    	obj = "dBW2" ;
	    Obj=document.getElementById(obj);       
        try {
        Obj.setCapture();
        } catch(e){}
        Obj.l=event.x-Obj.style.pixelLeft;
        Obj.t=event.y-Obj.style.pixelTop;
    }
    
    function myMouseMove()
    {
        if(Obj!=null && event.y-Obj.t > 0 && event.x-Obj.l > 0)
        {
            Obj.style.pixelLeft=event.x-Obj.l;
            Obj.style.pixelTop=event.y-Obj.t;
            var hF = document.getElementById(Obj.id + 'Frame');  
            hF.style.left = Obj.style.pixelLeft;
            hF.style.top = Obj.style.pixelTop;
        }
    }
    
    function myMouseUp()
    {
        if(Obj!=null)
        {           
            Obj.releaseCapture();
            Obj=null;
        }
    }

