﻿function right(e) {
if (navigator.appName =='Netscape'&&
(e.which ==3|| e.which ==2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2|| event.button ==3)) {
return false;
}
return true;
}

if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;

document.oncontextmenu=noshowmenu;
function noshowmenu()
{
//return false
}
//PF_Hits('board','id',<?=$rs["id"]?>)	 
function PF_Hits(dbtable,field,key){
		jQuery.ajax({
		type: "post",
		data: 'dbtable='+dbtable+'&field='+field+'&key='+key,
		url: 'PF_hits.php',		
		dataType: "html"
		})
}	 

function PF_escape(S){
	return encodeURIComponent(S)
}


function PF_BannerOnclick(e){
var id="";
  	   if(e==null){
       		e=window.event;         
			id=e.srcElement.aa;
	   }else{//FireFox
	   		id=e.originalTarget.aa;
	   }	
	
	if (id!='')
	PF_Hits('board','id',id);
	
}

function PF_getdata(requestURL,objname,pars) {    

	if (typeof(pars)=="object"){
		        	pars= $(pars).serialize();        	   
	}
	 jQuery.ajax({
		           type: "post",
		           data: pars,
			    url: requestURL,		
			    dataType: "html",			    
			    error: function(resp){
			    	//	alert('Error: url : ' + requestURL+'?'+pars+'\n'+resp.responseText); 	   
			    },
			     beforeSend:function(){	
				//jQuery("#"+objname).html('Loading content, please wait..');
			    },			
				success: function(resp){
			    	if (typeof(objname)=="object"){
			    		$(objname).html(resp);	
			    	}else if ( typeof(objname) == "string" ){	
			    		$("#"+objname).html(resp);
			    	}else if ( typeof(objname) != "undefined" ){
			    		$("#"+objname).html(resp);	
			    	}
			     }
	 });					      
}
function PF_AjaxblockUI(requestURL,pars,title){
	if (requestURL==''){return ;}	
	 jQuery.ajax({
		           type: "post",		        
			    url: requestURL,		
			    dataType: "html",
			    data: pars,
			    error: function(resp){
                                     alert('Error: url : ' + requestURL+'?'+pars+'\n'+resp); 	   
			    },
			     beforeSend:function(){	
				//jQuery("#loading").toggle();
			    },			
			    error : function(XMLHttpRequest, textStatus) {   
			
			     },   
			    success: function(resp){
			    		 $.growlUI(title, resp); 

			     }
	 })
}
/*


var apDivflag;
function PF_divmouseover(v){
	jQuery("#"+v).show();
	if (v!=apDivflag){
		jQuery("#"+apDivflag).hide();
	}
	apDivflag=v;	
}
*/
//同div name 開關
function PF_menudisplay(tableName){
	jQuery('#'+tableName).toggle();	
}

//定位在頁面底端
jQuery(document).ready(function() {  
	PF_DivTop();
});
function PF_DivTop(){
		 if (jQuery('#divtop').length>0){
			$('#divtop').css('top', $(document).scrollTop() + $(window).height() -750);
			$('#divtop').css('left', $(document).scrollLeft() + $(window).width() - 700);
			setTimeout("PF_DivTop()", 500)// 1秒後執行一次xxx()
		}
}

function PF_CarDisplay(pars){

	jQuery.ajax({
		           type: "post",		        
			    url: 'PF_addcar.php',		
			    dataType: "html",
			    data: pars,
			    error: function(resp){
                                     alert('Error: url : ' + requestURL+'?'+pars+'\n'+resp); 	   
			    },
			     beforeSend:function(){	
				jQuery("#car").hide();
			    },			
			    error : function(XMLHttpRequest, textStatus) {   
			
			     },   
			    success: function(resp){
			    		var position = jQuery("#carmenu").position();	
				    	 jQuery("#car").css({"left": position.left-150});	
				    	 jQuery("#car").css({"top": position.top-10});	
				    	 jQuery("#car").css({"z-index":9999});	
				    	 
				    	jQuery("#car").html(resp);
				    	jQuery("#car").addClass("ohmy").slideDown("fast",
				    		function(){
				    			setTimeout("jQuery('#car').hide()", 3000); 
				    			
				    		}
				    	
				    	);

			     }
		})
}

$(window).scroll(function(){
	jQuery("#car").hide();
});

	function PF_addcar(productid){		
		var pars="productid="+productid+"&qty=1";
	    PF_CarDisplay(pars);
	}
