$(document).ready(function(){	
						   
	$('.leftli').mouseover(function(){
		$(".rightmenu").hide();						  
		$("#subleft_"+$(this).attr("id")).show();	
		$("#subleft_"+$(this).attr("id")).mouseout(function(){$(this).hide();});								
	});
	
	$('.selectall').click(function(){
		if($(this).attr("checked") == true){								   
			$('.selectbox').each(function(){$(this).attr("checked",true);});
		}else{
			$('.selectbox').each(function(){$(this).attr("checked",false);});
		}								   
	});
	
	$('#inquire').click(function(){
		var proids='';
		for(i=0;i<=$('.selectbox').size();i++){
			if($('.selectbox').eq(i).attr("checked") == true){
				if(proids==''){
					proids = $('.selectbox').eq(i).val();
				}else{
					proids = proids+","+$('.selectbox').eq(i).val();
				}
				
			}			
		}
		if(proids!=''){
		var inquire = openwindow('/products/inquire/'+proids+'/feedback.htm',600,600,'no');
		}
	});
	
	$('#inquirenow').click(function(){		
		var inquire = openwindow('/products/inquire/'+$('#selectbox').val()+'/feedback.htm',600,600,'no');
		return false;
	});	
	
	$(".imabox a").fancybox({				
		//'hideOnContentClick': true
		//'zoomSpeedIn':	0,
		//'zoomSpeedOut':	0,
		'overlayShow':	true
	});
	
	$('#photos').galleryView({
			panel_width: 280,
			panel_height: 218,
			frame_width: 60,
			frame_height: 60,
			border:0,
			background_color: 'transparent',
			nav_theme: 'dark'
		});
	
	$('#mycarousel li').click(function(){
		$(".imabox a").hide();
		$("#big_"+$(this).attr("id")).show();
		
	});
	
	$(".certboxleft_img a").fancybox({				
		//'hideOnContentClick': true
		//'zoomSpeedIn':	0,
		//'zoomSpeedOut':	0,
		'overlayShow':	true
	});
	
	$('.gotopage').click(function(){
		if(!isNaN($('#gopage').val())){ 						  
			location.href= $(this).attr("href").replace('gotopage',$('#gopage').val());
		}
		return false;
	});	
	
	
	$('#feedback_submit').click(function(){ 
		if($('#CompanyName').val()==null || $('#CompanyName').val()==""){
			alert("Please enter Company Name!");
			$('#CompanyName').focus();
			return false;
		}
		if($('#ContactName').val()==null || $('#ContactName').val()==""){
			alert("Please enter Contact Name!");
			$('#ContactName').focus();
			return false;
		}
		if($('#Email').val()==null || $('#Email').val()==""){
			alert("Please enter E-Mail!");
			$('#Email').focus();
			return false;
		}else{ 
			if(!/.+@.+\.[a-zA-Z]{2,4}$/.test($('#Email').val())){
				alert("Please enter a valid E-Mail!");
				$('#Email').focus();
				return false;
			}
		}
		if($('#Tel').val()==null || $('#Tel').val()==""){
			alert("Please enter Tel!");
			$('#Tel').focus();
			return false;
		}
		if($('#Fax').val()==null || $('#Fax').val()==""){
			alert("Please enter Fax!");
			$('#Fax').focus();
			return false;
		}
		if($('#Country').val()==null || $('#Country').val()==""){
			alert("Please enter Country!");
			$('#Country').focus();
			return false;
		}
		
		if($('#Message').val()==null || $('#Message').val()==""){
			alert("Please enter Message!");
			$('#Message').focus();
			return false;
		}
		
		
		$.post('/products_inquire_ajax.htm',{'Products': $('#Products').val(),'CompanyName': $('#CompanyName').val(),'ContactName': $('#ContactName').val(),'Title': $('#Title').val(),'Email': $('#Email').val(),'Tel': $('#Tel').val(),'Fax': $('#Fax').val(),'Country': $('#Country').val(),'Address': $('#Address').val(),'BusinessType': $('#BusinessType').val(),'Message': $('#Message').val()},function(data){
				if(data!='false'){
					alert("Thank you to our message. We will reply you within 24 hours.");
					if(data == 'reload'){
						location.reload(true);
					}else if(data == 'close'){					
						self.close()
					}
					return false;
				}else{
					alert("Sorry,Please enter your valid information.");
					return false;
				}
		});	
		
	});
	
});

function document.oncontextmenu(){event.returnValue=false;}//屏蔽鼠标右键
function window.onhelp(){return false} //屏蔽F1帮助
/*function document.onkeydown(){
  if ((window.event.altKey)&&
      ((window.event.keyCode==37)||   //屏蔽 Alt+ 方向键 ←
       (window.event.keyCode==39)))   //屏蔽 Alt+ 方向键 →
  {
     alert("不准你使用ALT+方向键前进或后退网页！");
     event.returnValue=false;
  }
    
  if ((event.keyCode==8)  ||                 //屏蔽退格删除键
      (event.keyCode==116)||                 //屏蔽 F5 刷新键
      (event.ctrlKey && event.keyCode==82)){ //Ctrl + R
     event.keyCode=0;
     event.returnValue=false;
     }
  if (event.keyCode==122){event.keyCode=0;event.returnValue=false;}  //屏蔽F11
  if (event.ctrlKey && event.keyCode==78) event.returnValue=false;   //屏蔽 Ctrl+n
  if (event.shiftKey && event.keyCode==121)event.returnValue=false;  //屏蔽 shift+F10
  if (window.event.srcElement.tagName == "A" && window.event.shiftKey)  
      window.event.returnValue = false;             //屏蔽 shift 加鼠标左键新开一网页
  if ((window.event.altKey)&&(window.event.keyCode==115))             //屏蔽Alt+F4
  {
      window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");
      return false;
  }
}*/


function openwindow(url,width,height,resizable){
	var xposition=0; 
	var yposition=0;
	if(parseInt(navigator.appVersion) >= 4 ){
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height-25) / 2;
	}
	var Win = window.open(url,"openWindow",'width=' + width + ',height=' + height + ',left=' + xposition + ',top=' + yposition + ',toolbar=no,scrollbars='+resizable+',resizable='+resizable);
}

var _c = _h = 0;
$(function(){
    $('#plays > a').click(function(){
        var i = $(this).attr('alt') - 1;
        clearInterval(_h);
        _c = i;
        play();
        change(i);        
    })
    $("#pic img").hover(function(){clearInterval(_h)}, function(){play()});
    play();
})
function play(){  _h = setInterval("auto()", 3600);}
function change(i){
    $('#plays > a').css('background-color','#EFEFEF').eq(i).css('background-color','#CE0609').blur();
    $("#pic img").hide().eq(i).fadeIn('slow');
	return false;
}
function auto(){    
    _c = _c > 3 ? 0 : _c + 1;
    change(_c);
}
