//alert($);

function openwin( url, winName, width, height){
	xposition=0; yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ))
	{
	xposition = (screen.width - width) / 2;
	yposition = (screen.height - height) / 2;
	}
	theproperty= "width=" + width + "," 
	+ "height=" + height + "," 
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=1,"
	+ "scrollbars=1,"
	+ "status=0," 
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "screenx=" + xposition + "," //仅适用于Netscape
	+ "screeny=" + yposition + "," //仅适用于Netscape
	+ "left=" + xposition + "," //IE
	+ "top=" + yposition; //IE 
	window.open( url,winName,theproperty );
}

$(document).ready(function(){



//	$('a.about').addClass('thickbox').click(function(){
//		openwin($(this).href(),'about pakee',);
//		alert($(this).href());
//		return false;
//	});

	$().ajaxStop(function(){
		$.unblockUI();
	});

///*
	$().ajaxStart(function(){
		$.blockUI('正在發送請求，請稍候...');
	})
//*/	
	
	$('#menu .product').mouseover(function(){
		$(this).addClass('over');
	}).mouseout(function(){
		$(this).removeClass('over');
	});

	$('#search_name').click(function(){
		var frmSearch = document.getElementById('frmSearch');
	//	alert(frmSearch);
		if(frmSearch.sSearchword.value.length < 3){
//			$(this).removeClass("thickbox");
			alert('請填寫至少三個字串!');
			frmSearch.sSearchword.focus();
			return false;
		}
//		$(this).addClass("thickbox");
//		$(this).href('search.asp?KeepThis=true&TB_iframe=true&height=400&width=600');
 //alert();
//		alert(frmSearch.sSearchword.length);
		frmSearch.action = 'search.asp?Searchword=' + frmSearch.sSearchword.value;
//		return false;
	});

	$('input.sSearchword').click(function(){
//		this.select();
	}).keydown(function(){
		if(event.keyCode==13){
			//event.keyCode=9
//			alert('a');
///*
			var frmSearch = document.getElementById('frmSearch');
		if(frmSearch.sSearchword.value.length < 3){
//			$(this).removeClass("thickbox");
			alert('請填寫至少三個字串!');
			return false;
		}
			frmSearch.action = 'search.asp?Searchword=' + frmSearch.sSearchword.value;
//			frmSearch.submit();
//*/
		}
	});

	$('input.sSearchword2').keydown(function(){
	//	alert('a');
	if(event.keyCode==13){
		//event.keyCode=9
///*

		var frmSearch2 = document.getElementById('frmSearch2');
		if(frmSearch2.sSearchword.value.length < 3){
			alert('請填寫至少三個字串!');
			return false;
		}
		frmSearch2.action = 'http://www.alldatasheet.com/view.jsp?Searchword=' + frmSearch2.sSearchword.value;
//		frmSearch2.submit();
//*/
	}
});

	$('#search_name2').click(function(){
		var frmSearch2 = document.getElementById('frmSearch2');

		if(frmSearch2.sSearchword.value.length < 3){
			alert('請填寫至少三個字串!');
			return false;
		}
		frmSearch2.action = 'http://category.alldatasheet.com/index.jsp?Searchword=' + frmSearch2.sSearchword.value;
//		return false;
	});

//
	$('div#get_sample').mouseover(function(){$(this).addClass('over')}).click(function(){
	//alert('a');
	return false;
	});


	$('a#btn_get_quote').click(function(){
		var f = Validator.Validate(f_get_quote,3);
		if(!f){
			alert('請填寫所有必填選項');
			return false;
		}
		//alert(f_get_quote.company.value);
		//,qty:,co:f_get_quote.company.value,email:f_get_quote.email.value
		$.post('/e_mail-cn.asp',{type:1,number:f_get_quote.number.value,manu:f_get_quote.manufacturer.value,qty:f_get_quote.quantity.value,co:f_get_quote.company.value,email:f_get_quote.email.value},function(data){
			alert(data);
			$('#quote_completed').html('您的請求已成功發送!').show('fast');
			f_get_quote.number.value = '';
			f_get_quote.manufacturer.value = '';
			f_get_quote.quantity.value = '';
			f_get_quote.company.value = '';
			f_get_quote.email.value = '';
		});
		return false;
	});

	$('a#btn_sample_request').click(function(){
		var f = Validator.Validate(f_sample_request,3);
		if(!f){
			alert('Please fill the require options!');
			return false;
		}
		//alert(f_get_quote.company.value);
		//,qty:,co:f_get_quote.company.value,email:f_get_quote.email.value
		$.post('/e_mail-cn.asp',{type:2,number:f_sample_request.number.value,manu:f_sample_request.manufacturer.value,qty:f_sample_request.quantity.value,co:f_sample_request.company.value,email:f_sample_request.email.value},function(data){
			alert(data);
			$('#request_completed').html('您的請求已成功發送!').show('fast');
			f_sample_request.number.value = '';
			f_sample_request.manufacturer.value = '';
			f_sample_request.quantity.value = '';
			f_sample_request.company.value = '';
			f_sample_request.email.value = '';
		});
		return false;
	});

	$('a#btn_support').click(function(){
		var f = Validator.Validate(f_support,3);
		if(!f){
			alert('請填寫所有必填選項!');
			return false;
		}
		//alert(f_get_quote.company.value);
		//,qty:,co:f_get_quote.company.value,email:f_get_quote.email.value
		$.post('/e_mail-cn.asp',{type:4,number:f_support.number.value,manu:f_support.manufacturer.value,qty:f_support.quantity.value,co:f_support.company.value,email:f_support.email.value},function(data){
			alert(data);
			$('#support_completed').html('您的請求已成功發送!').show('fast');
			f_support.number.value = '';
			f_support.manufacturer.value = '';
			f_support.quantity.value = '';
			f_support.company.value = '';
			f_support.email.value = '';
		});
		return false;
	});



});
