// JavaScript Document
var arrMnu = new Array();
var addressPath = "http://vectorthai.com/";
//var addressPath = "http://localhost/vector/";
//var addressPath = "http://vector.pduang.com/";
$(document).ready(function(){
		get_brand_menu();
		getBrand();	
		
		$("#mnu_product").hover(
			function () {
				show_products('show');
			},
			function () {
			}
		);
		$("#mysubmenu").hover(
			function () {
			}, 
			function () {
				$("#sub_product2").fadeOut();
				$("#sub_product").fadeOut();
			}
		);	
		
		$("#mnu_service").hover(
			function () {
				show_service('show');
			},
			function () {
			}
		);
		
		var w = $(document).width();
		var w1;
		var w2 = "";
		w1 = (240 * w)/1024 ;
		w2 = w1 + "px;";
		//alert(w1);
		
		if(w >= 1280){
			$("#tp_ventilation").css({'left' : '365px'});
			$("#tp_soundproof").css({'left' : '365px'});
			$("#tp_fire").css({'left' : '365px'});
			$("#tp_industrial").css({'left' : '365px'});
			$("#tp_others").css({'left' : '365px'});
		}
		
		if(w <= 800){
			$("#tp_ventilation").css({'left' : '215px'});
			$("#tp_soundproof").css({'left' : '215px'});
			$("#tp_fire").css({'left' : '215px'});
			$("#tp_industrial").css({'left' : '215px'});
			$("#tp_others").css({'left' : '215px'});
		}
		
		$("#mnu_ventilation").hover(
			function () {
				$("#tp_soundproof").hide();
				$("#tp_fire").hide();
				$("#tp_industrial").hide();
				$("#tp_others").hide();
				
				$("#tp_ventilation").fadeIn();
				$("#mnu_ventilation").css({'background-color' : '#09C', 'font-weight' : 'bolder'});
			},
			function () {
				$("#mnu_ventilation").css({'background-color' : '#246494', 'font-weight' : 'bolder'});
			}
		);
		
		$("#mnu_soundProff").hover(
			function () {
				$("#tp_ventilation").hide();
				$("#tp_fire").hide();
				$("#tp_industrial").hide();
				$("#tp_others").hide();
				
				$("#tp_soundproof").fadeIn();
				$("#mnu_soundProff").css({'background-color' : '#09C', 'font-weight' : 'bolder'});
			},
			function () {
				$("#mnu_soundProff").css({'background-color' : '#246494', 'font-weight' : 'bolder'});
			}
		);
		
		$("#mnu_fireBarrier").hover(
			function () {
				$("#tp_ventilation").hide();
				$("#tp_soundproof").hide();
				$("#tp_industrial").hide();
				$("#tp_others").hide();
				
				$("#tp_fire").fadeIn();
				$("#mnu_fireBarrier").css({'background-color' : '#09C', 'font-weight' : 'bolder'});
			},
			function () {
				$("#mnu_fireBarrier").css({'background-color' : '#246494', 'font-weight' : 'bolder'});
			}
		);
		
		$("#mnu_industrialFan").hover(
			function () {
				$("#tp_ventilation").hide();
				$("#tp_soundproof").hide();
				$("#tp_fire").hide();
				$("#tp_others").hide();
				
				$("#tp_industrial").fadeIn();
				$("#mnu_industrialFan").css({'background-color' : '#09C', 'font-weight' : 'bolder'});
			},
			function () {
				$("#mnu_industrialFan").css({'background-color' : '#246494', 'font-weight' : 'bolder'});
			}
		);
		
		$("#mnu_others").hover(
			function () {
				$("#tp_ventilation").hide();
				$("#tp_soundproof").hide();
				$("#tp_fire").hide();
				$("#tp_industrial").hide();
				
				$("#tp_others").fadeIn();
				$("#mnu_others").css({'background-color' : '#09C', 'font-weight' : 'bolder'});
			},
			function () {
				$("#mnu_others").css({'background-color' : '#246494', 'font-weight' : 'bolder'});
			}
		);
		
		$("#tp_ventilation").hover(
			function () {
				
			},
			function () {
				$("#tp_ventilation").hide();
				$("#tp_soundproof").hide();
				$("#tp_fire").hide();
				$("#tp_industrial").hide();				
				$("#tp_others").hide();
			}
		);
		
		$("#tp_soundproof").hover(
			function () {
				
			},
			function () {
				$("#tp_ventilation").hide();
				$("#tp_soundproof").hide();
				$("#tp_fire").hide();
				$("#tp_industrial").hide();				
				$("#tp_others").hide();
			}
		);
		
		$("#tp_fire").hover(
			function () {
				
			},
			function () {
				$("#tp_ventilation").hide();
				$("#tp_soundproof").hide();
				$("#tp_fire").hide();
				$("#tp_industrial").hide();				
				$("#tp_others").hide();
			}
		);
		
		$("#tp_industrial").hover(
			function () {
				
			},
			function () {
				$("#tp_ventilation").hide();
				$("#tp_soundproof").hide();
				$("#tp_fire").hide();
				$("#tp_industrial").hide();				
				$("#tp_others").hide();
			}
		);
		
		$("#tp_others").hover(
			function () {
				
			},
			function () {
				$("#tp_ventilation").hide();
				$("#tp_soundproof").hide();
				$("#tp_fire").hide();
				$("#tp_industrial").hide();				
				$("#tp_others").hide();
			}
		);
		
		$('#mnu_ventilation').click(function() {
			var t = String(window.location);
			var p = t.length;
			d = t.substr ( p-4, 1 );
			
			if(d==2){
				window.location= addressPath + "?p=2018" ;
			}else{
				window.location= addressPath + "?p=1018" ;
			}
		});		
		
		$('#mnu_soundProff').click(function() {
			var t = String(window.location);
			var p = t.length;
			d = t.substr ( p-4, 1 );
			
			if(d==2){
				window.location= addressPath + "?p=2019" ;
			}else{
				window.location= addressPath + "?p=1019" ;
			}
		});	
				
		$('#mnu_fireBarrier').click(function() {
			var t = String(window.location);
			var p = t.length;
			d = t.substr ( p-4, 1 );
			
			if(d==2){
				window.location= addressPath + "?p=2020" ;
			}else{
				window.location= addressPath + "?p=1020" ;
			}
		});	
						
		$('#mnu_industrialFan').click(function() {
			var t = String(window.location);
			var p = t.length;
			d = t.substr ( p-4, 1 );
			
			if(d==2){
				window.location= addressPath + "?p=2021" ;
			}else{
				window.location= addressPath + "?p=1021" ;
			}
		});	
								
		$('#mnu_others').click(function() {
			var t = String(window.location);
			var p = t.length;
			d = t.substr ( p-4, 1 );
			
			if(d==2){
				window.location= addressPath + "?p=2022" ;
			}else{
				window.location= addressPath + "?p=1022" ;
			}
		});	
		
		$("#logo").hover(
			function () {
				//$("#conner").hide();
				
			},
			function () {
				$("#conner").fadeIn();
				$("#ruskin_logo").hide();		
			}
		);
		
		$("#conner").hover(
			function () {
				$("#conner").hide();
				$("#ruskin_logo").fadeIn();				
			},
			function () {
				//$("#conner").show();
				$("#ruskin_logo").fadeIn();				
			}
		);
		
		
});
function getBrand(){
		$("#selBrandSearch :Option").remove();
		//var url_ = "../script/home.php";
		var url_ = "script/home.php";
		/*var emp_code = $("#txtEmpCode").val();		*/
    	var param = "action=getBrand" ;
		$.post(url_,param ,function(data){
			var json = eval('('+data+')');
			$("#selBrandSearch").append("<option value='-'>.. Brand ..</option>");
			for (var i = 0; i <json.myResult.length;i++) {
				$("#selBrandSearch").append("<option value='" + json.myResult[i].id + "'>"+ json.myResult[i].name +"</option>");
			}
			//alert (json);
		});
	}
	function get_brand(){
		$("#selBrand :Option").remove();
		//var url_ = "../script/home.php";
		var url_ = "script/home.php";
		/*var emp_code = $("#txtEmpCode").val();		*/
    	var param = "action=getBrand" ;
		$.post(url_,param ,function(data){
			var json = eval('('+data+')');
			$("#selBrand").append("<option value='-'>.. Brand ..</option>");
			for (var i = 0; i <json.myResult.length;i++) {
				$("#selBrand").append("<option value='" + json.myResult[i].id + "'>"+ json.myResult[i].name +"</option>");
			}
			//alert (json);
		});
	}
/*function getNEWS(){
		//var url_ = "../script/home.php";
		var url_ = "script/home.php";
    	var param = "action=getNEWS" ;
		$.post(url_,param ,function(data){
			var json = eval('('+data+')');
			for (var i = 0; i <json.NEWS.length;i++) {				
				$("#divNEWS").append("<p class='right' onclick=\"openNEWS('" + json.NEWS[i].id + "')\" > " + "<img src=\"en_images/e_punct_b.gif\" width=\"5\" height=\"5\" border=\"0\" align=\"absmiddle\">  " + json.NEWS[i].ename + "</p>");
			}
			
		});
	}*/

/*<left Mnu>*/
function left_mnu_over(ctrl,tbl){
	$(ctrl).css({'background-color' : '#09C', 'font-weight' : 'bolder'});
	}
function left_mnu_leave(ctrl){ 
	$(ctrl).css({'background-color' : '#246494', 'font-weight' : 'bolder'});
	}
	
function mnufeft_leave(){
/*	$("#tbContent1").fadeIn();
	$("#tbVentilation").hide();
	$("#tbSoundProof").hide();
	$("#tbFireBarrier").hide();
	$("#tbIndustrialFan").hide();
	$("#tbOthers").hide();*/
	mnu_hideAll();
}
function mnu_ventilationClick(){
	mnu_hideAll("tbVentilation");
}
function mnu_soundProffClick(){
	mnu_hideAll("tbSoundProof");
}
function mnu_fireBarrierClick(){
	mnu_hideAll("tbFireBarrier");
}
function mnu_industrialFanClick(){
	mnu_hideAll("tbIndustrialFan");
}
function mnu_othersClick(){
	mnu_hideAll("tbOthers");
}
function mnu_hideAll(tbl){
	$("#tbContent1").hide();
	$("#tbVentilation").hide();
	$("#tbSoundProof").hide();
	$("#tbFireBarrier").hide();
	$("#tbIndustrialFan").hide();
	$("#tbOthers").hide();
	if(tbl){
		$("#"+tbl).fadeIn();
	}else{
		$("#tbContent1").fadeIn();
	}
}
/*</left Mnu>*/
/*<Show Product>*/
function show_products(is_show) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	$("#sub_product").css("z-index","99");
	$("#sub_product2").css("z-index","99");
  	if (myWidth <= 800) {
	  	$("#sub_product").css("left","175px");
	  	$("#sub_product2").css("left","275px");
  	}else if (myWidth > 1000) {
  		var pos = ((myWidth-800) / 2.313131313131313131313131) + 175;
	  	$("#sub_product").css("left",pos);
	  	$("#sub_product2").css("left",pos+100);
  	}else if (myWidth > 950) {
  		var pos = ((myWidth-800) / 2.313131313131313131313131) + 170;
	  	$("#sub_product").css("left",pos);
	  	$("#sub_product2").css("left",pos+100);
 	}else if (myWidth > 850) {
  		var pos = ((myWidth-800) / 2.313131313131313131313131) + 165;
	  	$("#sub_product").css("left",pos);
	  	$("#sub_product2").css("left",pos+100);
  	}else{
	  	$("#sub_product").css("left","175px");
	  	$("#sub_product2").css("left",pos+100);
  	}
  	if (is_show =="show"){
  		$("#sub_product").fadeIn();
	}else{
		$("#sub_product").hide();
	}
  		/*window.alert( 'Width = ' + myWidth );
	  	window.alert( 'Height = ' + myHeight ); */
}

/*<Show service>*/
function show_service(is_show) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	$("#sub_sevice").css("z-index","159");
	$("#sub_sevice2").css("z-index","159");
  	if (myWidth <= 800) {
	  	$("#sub_sevice").css("left","175px");
	  	$("#sub_sevice2").css("left","275px");
  	}else if (myWidth > 1000) {
  		var pos = ((myWidth-800) / 2.313131313131313131313131) + 175;
	  	$("#sub_sevice").css("left",pos);
	  	$("#sub_sevice2").css("left",pos+150);
  	}else if (myWidth > 950) {
  		var pos = ((myWidth-800) / 2.313131313131313131313131) + 170;
	  	$("#sub_sevice").css("left",pos);
	  	$("#sub_sevice2").css("left",pos+150);
 	}else if (myWidth > 850) {
  		var pos = ((myWidth-800) / 2.313131313131313131313131) + 165;
	  	$("#sub_sevice").css("left",pos);
	  	$("#sub_sevice2").css("left",pos+150);
  	}else{
	  	$("#sub_sevice").css("left","175px");
	  	$("#sub_sevice2").css("left",pos+150);
  	}
  	if (is_show =="show"){
  		$("#sub_service").fadeIn();
	}
  		/*window.alert( 'Width = ' + myWidth );
	  	window.alert( 'Height = ' + myHeight ); */
}

/*function get_service_menu(){
	var strTmp ;		
		var url_ = "script/indexQ.php";
    	var param = "action=get_mnuService" ;
		$.post(url_,param ,function(data){
			var json = eval('('+data+')');
			strTmp +="<div style='position:absolute; width:130px; left: 299px; display:none; top: 166px; height: 99px;' id='sub_service'><table width='100%' border='0' cellspacing='0' cellpadding='0'>  <tr>    <td  style='background-color:#EAEAEA; border: #208FFF 1px groove;' valign='top'>    	<table width='130px' border='0' cellspacing='0' cellpadding='0' class='font' >";
			 arrMnu = new Array();
			for (var i = 0; i <json.myResult.length;i++) {
				arrMnu[i] = "mnu_right" + json.myResult[i].id;
				strTmp += "<tr><td style='border-bottom:solid 1px;margin-top:5px;' class='sub_menu' ><a href='javascript:void(0);'  class='sub_menu'> " + json.myResult[i].ename + " </a></td><td style='border-bottom:solid'><img src='images/right.GIF' width='5' height='9' id='mnu_right" + json.myResult[i].id + "' style='display:none'></td></tr>";				
			}
			strTmp +="	</table></td></tr></table></div>";
			//alert(strTmp);
			$("#sub_service").replaceWith(strTmp);
		});	
}*/

function get_brand_menu(){
	var strTmp="" ;		
		var url_ = "script/product.php";
    	var param = "action=getBrand" ;
		$.post(url_,param ,function(data){
			var json = eval('('+data+')');
			strTmp +="<div style='position:absolute; width:130px; left: 269px; display:none; top: 166px; height: 99px;' id='sub_product'><table width='100%' border='0' cellspacing='0' cellpadding='0'>  <tr>    <td  style='background-color:#EAEAEA; border: #208FFF 1px solid;' valign='top'>    	<table width='130px' border='0' cellspacing='0' cellpadding='0' class='font' >";
			 arrMnu = new Array();
			for (var i = 0; i <json.myResult.length;i++) {
				arrMnu[i] = "mnu_right" + json.myResult[i].id;
				strTmp += "<tr><td style='border-bottom:solid 1px;margin-top:5px;' class='sub_menu' ><a href='javascript:void(0);' onMouseOver=\"over_product('" + json.myResult[i].id + "');\" class='sub_menu'> " + json.myResult[i].ename + " </a></td><td style='border-bottom:solid'><img src='images/right.GIF' width='5' height='9' id='mnu_right" + json.myResult[i].id + "' style='display:none'></td></tr>";				
			}
			strTmp +="	</table></td></tr></table></div>";
			$("#sub_product").replaceWith(strTmp);
		});	
}

function over_product(items){
	$("#sub_product2").hide();
	for (var i = 0; i <arrMnu.length;i++) {
			$("#" + arrMnu[i]).hide();
			var tmp = "mnu_right" + items;
			var tmp_ = 166;
			if (arrMnu[i] == tmp){
				get_model_menu(items);
				tmp_ += i*25;
				$("#sub_product2").css("top",tmp_ + "px");
			}
	}
	$("#mnu_right" + items).fadeIn();	
}
function get_model_menu(ids){	
		$("#sub_product2").fadeIn();
		//var url_ = "../script/product.php";
		var url_ = "script/product.php";
    	var param = "action=getData2" ;
		param += "&brand=" + ids;
		param += "&name=";
		param += "&id=";
		$.post(url_,param ,function(data){
				var json = eval('('+data+')');
				strTmp = "";
				strTmp = "<table width='140px' border='0' class='font' id='mnu_sub_product'>";
					if (json.myResult[0].status ==1){
						for (var i = 0; i <json.myResult.length;i++) {
							strTmp += "<tr>";
							strTmp += "<td style='border-bottom:solid 1px' class='sub_menu2'><a href='javascript:void(0);' class='sub_menu2' onClick ='model_detail(" + "'" + json.myResult[i].id + "'" + ")'>" + json.myResult[i].name + "</a></td>";							
							strTmp += "</tr>";
						}						
					}else{						
						alert("ไม่พบข้อมูลที่ค้นหา");
					}
					strTmp +="</table>";
					$("#mnu_sub_product").replaceWith(strTmp);			
		});
}
/*</Show Product>*/

/*<function for Product>*/
function get_all_brand(id){
		var img_path = "admin/img_load/brand/";
		var img_path2 = "admin/img_load/product/";
		var myId = "";
		myId = id;		
		var url_ = "script/product_all_brand.php";
    	var param = "action=product_all_brand" ;
		param += "&id=" + id;
		$.post(url_,param ,function(data){
			var json = eval('('+data+')');
			tmp = eval('('+data+')');
			if (myId == ""){
				strTmp = "";
				strTmp = "<table id = 'tbAllBrand' border='0' cellspacing='0' cellpadding='0' width='90%' align='center'><tr valign='top'><td align='center'>";
					if (json.myResult[0].status ==1){
						var tmp_id = "";
						for (var i = 0; i <json.myResult.length;i++) {
							if (tmp_id == img_path + json.myResult[i].b_id) {
								strTmp +="<p><b><a href='?p=1006&id=" + json.myResult[i].p_id + "'>" + json.myResult[i].p_ename + "</a></b></p>";
							}else{
								if ( i > 0){strTmp += "</td></tr></table>";}
								tmp_id = img_path + json.myResult[i].b_id;
								strTmp += "<table border='1' cellspacing='0' cellpadding='0' width='100%' background='' align='center'><tr valign='top'><td align='center' width = '40%'>" ;
								strTmp +="<p><b><a href='?p=1005&id=" + json.myResult[i].b_id + "'>" + json.myResult[i].b_ename + "</a></b></p>";
								strTmp +="<a href='?p=1005&id=" + json.myResult[i].b_id + "'><img src='" + img_path + json.myResult[i].b_img + "' width='137' height='146' alt='' border='0'></a><br><br>";
								strTmp +="<p>" + json.myResult[i].b_edesc + "</p></td>";
								strTmp +="<td>";
								
								strTmp +="<p><b><a href='?p=1006&id=" + json.myResult[i].p_id + "'>" + json.myResult[i].p_ename + "</a></b></p>";
							}
						}
					}else{						
						alert("ไม่พบข้อมูลที่ค้นหา");
					}
					strTmp +="</td></tr></table>";
					$("#tbAllBrand").replaceWith(strTmp);
			}else{//Choose only 1 brand				
				strTmp = "";
				strTmp = "<table id = 'tbAllBrand' border='0' cellspacing='0' cellpadding='0' width='90%' align='center'><tr valign='top'><td align='center'>";
					if (json.myResult[0].status ==1){
						for (var i = 0; i <json.myResult.length;i++) {
							if (i > 0){							
									strTmp += "<tr valign='top'><td align='center' width = '30%'>" ;
									strTmp +="<p><b><a href='?p=1006&id=" + json.myResult[i].p_id + "'>" + json.myResult[i].p_ename + "</a></b></p>";
									strTmp +="<a href='?p=1006&id=" + json.myResult[i].p_id + "'><img src='" + img_path2 + json.myResult[i].p_img + "' width='60' height='75' alt='' border='0'></a></td><br>";
									strTmp +="<td>";
									strTmp +="<p>" + json.myResult[i].p_edesc + "</p>";
									strTmp += "</td></tr>";
							}else{								
									get_page_path(json.myResult[i].b_ename);
									strTmp += "<table border='0' cellspacing='0' cellpadding='0' width='100%' background='' align='center'><tr valign='top'><td align='center' width = '30%' rowspan ='2'>" ;
									strTmp +="<p><b><a href='?p=1005&id=" + json.myResult[i].b_id + "'>" + json.myResult[i].b_ename + "</a></b></p>";
									strTmp +="<a href='?p=1005&id=" + json.myResult[i].b_id + "'><img src='" + img_path + json.myResult[i].b_img + "' width='120' height='130' alt='' border='0'></a></td>";
									strTmp +="<td>";
									strTmp +="<p>" + json.myResult[i].b_edesc + "</p>";
									strTmp += "</td></tr>";
									strTmp += "<tr><td>";
									strTmp +="<p><b>Link</b> : <a href ='http://" + json.myResult[i].b_link + "' target ='_blank'>" + json.myResult[i].b_link + "</a></p>";									
									strTmp += "</td></tr></table>";
									
									
									strTmp += "<table border='1' cellspacing='0' cellpadding='0' width='100%' background='' align='center'><tr valign='top'><td align='center' width = '30%'>" ;
									strTmp +="<p><b><a href='?p=1006&id=" + json.myResult[i].p_id + "'>" + json.myResult[i].p_ename + "</a></b></p>";
									strTmp +="<a href='?p=1006&id=" + json.myResult[i].p_id + "'><img src='" + img_path2 + json.myResult[i].p_img + "' width='60' height='75' alt='' border='0'></a></td><br>";
									strTmp +="<td>";
									strTmp +="<p>" + json.myResult[i].p_edesc + "</p>";
									strTmp += "</td></tr>";
							}					
						}
							strTmp +="</table>";	
					}else{						
						alert("ไม่พบข้อมูลที่ค้นหา");
					}
				strTmp +="</td></tr></table>";
				$("#tbAllBrand").replaceWith(strTmp);
			}//Choose only 1 brand	
		});
}
function get_page_path(b_name){
	var strTmp = "<p id='page_path'> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;> <a href ='?p=1004'> Product </a> > " + b_name + " </p>";
	$("#page_path").replaceWith(strTmp);
}
function get_page_path2(b_id,b_name,p_name){
	var strTmp = "<p id='page_path'> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;> <a href ='?p=1004'>  Product </a> > <a href ='?p=1005&id=" + b_id + "'>" + b_name + "</a> > " + p_name + "</p>";
	$("#page_path").replaceWith(strTmp);
}
function search_product_ (){
	var brand_ = $("#selBrandSearch").val();
	var product_ = $("#txt_left_product").val();
	if (brand_ == "-" && product_ == ""){
		window.location= addressPath + "?p=1004" ;
	}else if (brand_ != "" && product_ == ""){
		window.location= addressPath + "?p=1005&id=" + brand_ ;		
	}else{
		window.location= addressPath + "?p=1023&id=" + brand_ + "&txtSearch=" + product_ ;		
	}
}

function search_product_TH(){
	var brand_ = $("#selBrandSearch").val();
	var product_ = $("#txt_left_product").val();
	if (brand_ == "-" && product_ == ""){
		window.location= addressPath + "?p=2004" ;
	}else if (brand_ != "" && product_ == ""){
		window.location= addressPath + "?p=2005&id=" + brand_ ;		
	}else{
		window.location= addressPath + "?p=2023&id=" + brand_ + "&txtSearch=" + product_ ;		
	}
}




function get_a_product(id){
		var img_path = "admin/img_load/product/";
		var img_path2 = "admin/img_load/model/";
		var myId = "";
		myId = id;		
		var url_ = "script/product_all_brand.php";
    	var param = "action=get_a_product" ;
		param += "&id=" + id;
		$.post(url_,param ,function(data){
			var json = eval('('+data+')');
			tmp = eval('('+data+')');					
				strTmp = "";
				strTmp = "<table id = 'tbAllBrand' border='0' cellspacing='0' cellpadding='0' width='90%' align='center'><tr valign='top'><td align='center'>";
					if (json.myResult[0].status ==1){
						for (var i = 0; i <json.myResult.length;i++) {
							if (i > 0){							
									strTmp += "<tr valign='top'><td align='center' width = '30%'>" ;
									strTmp +="<p><b><a href='?p=1007&id=" + json.myResult[i].m_id + "'>" + json.myResult[i].m_name + "</a></b></p>";
									strTmp +="<a href='?p=1007&id=" + json.myResult[i].m_id + "'><img src='" + img_path2 + json.myResult[i].m_img + "' width='60' height='75' alt='' border='0'></a></td><br>";
									strTmp +="<td>";
									strTmp +="<p>" + json.myResult[i].m_edesc + "</p>";
									strTmp += "</td></tr>";
							}else{								
									get_page_path2(json.myResult[i].b_id, json.myResult[i].b_ename, json.myResult[i].p_ename,"model");
									strTmp += "<table border='0' cellspacing='0' cellpadding='0' width='100%' background='' align='center'><tr valign='top'><td align='center' width = '30%' rowspan ='2'>" ;
									strTmp +="<p><b><a href='?p=1006&id=" + json.myResult[i].p_id + "'>" + json.myResult[i].p_ename + "</a></b></p>";
									strTmp +="<a href='?p=1006&id=" + json.myResult[i].p_id + "'><img src='" + img_path + json.myResult[i].p_img + "' width='120' height='130' alt='' border='0'></a></td>";
									strTmp +="<td>";
									strTmp +="<p>" + json.myResult[i].p_edesc + "</p>";
									strTmp += "</td></tr>";
									strTmp += "<tr><td>";
									strTmp +="<p><b>Link</b> : <a href ='http://" + json.myResult[i].p_link + "' target ='_blank'>" + json.myResult[i].p_link + "</a></p>";									
									strTmp += "</td></tr></table>";
									
									
									strTmp += "<table border='1' cellspacing='0' cellpadding='0' width='100%' background='' align='center'><tr valign='top'><td align='center' width = '30%'>" ;
									strTmp +="<p><b><a href='?p=1007&id=" + json.myResult[i].m_id + "'>" + json.myResult[i].m_name + "</a></b></p>";
									strTmp +="<a href='?p=1007&id=" + json.myResult[i].m_id + "'><img src='" + img_path2 + json.myResult[i].m_img + "' width='60' height='75' alt='' border='0'></a></td><br>";
									strTmp +="<td>";
									strTmp +="<p>" + json.myResult[i].m_edesc + "</p>";
									strTmp += "</td></tr>";
							}					
						}
							strTmp +="</table>";	
					}else{						
						alert("ไม่พบข้อมูลที่ค้นหา");
					}
				strTmp +="</td></tr></table>";
				$("#tbAllBrand").replaceWith(strTmp);
		});
}
function get_a_service(id){
		var url_ = "script/service.php";
    	var param = "action=getData" ;
		param += "&name=";
		param += "&id=" + id;
		$.post(url_,param ,function(data){
			var json = eval('('+data+')');
			tmp = eval('('+data+')');
			if (id == ""){
				
			}else{
				clear_form();
				$("#txt_id").val(json.myResult[0].id);
				$("#txt_name").val(json.myResult[0].name);
				$("#txt_ename").val(json.myResult[0].ename);
				$("#txt_desc").val(json.myResult[0].desc);
				$("#txt_edesc").val(json.myResult[0].edesc);
				$("#txt_modify").val(json.myResult[0].modify);
				src = "img_load/service/" + json.myResult[0].image1;
				strTmp = "<img width='45px' height='45px' align='right' id='img_example1' src ='" + src + "'>";
				$("#img_example1").replaceWith(strTmp);
				src = "img_load/service/" + json.myResult[0].image2;
				strTmp = "<img width='45px' height='45px' align='right' id='img_example2' src ='" + src + "'>";
				$("#img_example2").replaceWith(strTmp);
				src = "img_load/service/" + json.myResult[0].image3;
				strTmp = "<img width='45px' height='45px' align='right' id='img_example3' src ='" + src + "'>";
				$("#img_example3").replaceWith(strTmp);
				src = "img_load/service/" + json.myResult[0].image4;
				strTmp = "<img width='45px' height='45px' align='right' id='img_example4' src ='" + src + "'>";
				$("#img_example4").replaceWith(strTmp);
				if (json.myResult[0].hot == 1){
					$("#chk_hot").attr("checked","checked");
				}			
				/*if (json.myResult[0].state == 0){
					$("#chk_status").attr("checked","checked");
				}*/
			}
		});
}
//*</function for Product>*/
/*<links>*/
function get_all_link(){
		var url_ = "script/links.php";
    	var param = "action=getData" ;
		param += "&id=";
		param += "&name=";
		param += "&link=";
		$.post(url_,param ,function(data){
			var json = eval('('+data+')');
			tmp = eval('('+data+')');	
				strTmp = "<table id='link_list' border='0' cellspacing='0' cellpadding='0' width='90%' background='' align='center' class='font'>";
					if (json.myResult[0].status ==1){
						var tmp_id = "";
						for (var i = 0; i <json.myResult.length;i++) {
							strTmp += "<tr valign='top'><td><p><a href = '" + json.myResult[i].links + "'>" + json.myResult[i].name + " </a></p></td>";
							strTmp += "<td><p><a href = '" + json.myResult[i].links + "'>" + json.myResult[i].links + "</a></p></td></tr>";
						}
					}else{						
						alert("ไม่พบข้อมูลที่ค้นหา");
					}
					strTmp +="</table>";
					$("#link_list").replaceWith(strTmp);			
		});
}
/*</links>*/
