//public variable
var ARRAY_CHECKED_PRODUCT	= [] ; 
var ARRAY_CHECKED_SUBTYPE	= [] ; 
var GROUP_NAME				= '' ; 
var TYPE_NAME				= '' ; 
var SUBTYPE_NAME			= '' ; 

var FindProducts = Class.create();

FindProducts.prototype = {
	
	//생성자
	initialize: function(sitecode, type, subtype, subtypename, specview){
		this.sitecode		= sitecode;  
		this.type			= type; 
		this.subtype		= subtype; 
		this.subtypename	= subtypename ; //byscreensize경우를 위해
		this.specview		= specview ;	// 

		if(this.subtypename == 'byscreensize') $('lowbTitleAndAttributes').style.display = 'none' ; 

		//top,bottom에 result bar에서 thumbnail, list view 변환 이벤트 등록
		Event.observe('lowbThumbImgTop','click',		this.getReturnURL.bindAsEventListener(this, 1, 'THUMBNAIL') );
		Event.observe('lowbListImgTop','click',			this.getReturnURL.bindAsEventListener(this, 1, 'LIST') );
		Event.observe('lowbThumbImgBottom','click',		this.getReturnURL.bindAsEventListener(this, 1, 'THUMBNAIL') );
		Event.observe('lowbListImgBottom','click',		this.getReturnURL.bindAsEventListener(this, 1, 'LIST') );

	}, //end initialize 

	//Member 변수
	//------------------------- DB data
	typeNameInfo	: null , //type name
	itemesInfo		: null , //items info
	itemesCode		: null , //items codes
	products		: null , //products
	//------------------------- Common
	resultCount		: null , // Products result count
	viewType		: null , // THUMBNAIL:thumbnail view, LIST:list view
	//------------------------- Search
	arrSearchResult	: []  ,  // Search Result DataSet
	arrSelectedKeyAtt : []  ,  // checked Products
	prdKeyAttAll	: '' ,	 //
	prdKeyAttBySearch	: '' ,	 //
	//------------------------- Paging
	listPaging		: null , // paging for listView
	thumbnailPaging : null , // paging for thumbnailView
	//------------------------- AND OR RADIO
	arrAndOr		: [],
	specIndex		: [] ,



	// DWR을 통한 데이터 얻기-------------------------------------------------------------------------START
	getData: function(){

		this.getTypeNameInfo(this);

		if(this.specview == 'Y'){
			this.getItemesInfo(this);
		}
		//this.getItemesCode(this);//getItemesInfo()에서 실행
		if(this.subtypename != 'byscreensize' ) this.getProducts(this); 
	},
	

	getTypeNameInfo: function(obj){
			FindcompareDWR.getTypeNameList(this.sitecode, this.type, this.subtype,  function(data){
					obj.typeNameInfo = data ; 
					if(obj.subtypename != 'byscreensize'){
						//$('lowbTitleAndAttributes').style.display = "" ; 
						$('lowbByScreenSizeMain').style.display = "none" ; 
						obj.showTitle();
					}else{
						//$('lowbTitleAndAttributes').style.display = "none" ; 
						$('lowbByScreenSizeMain').style.display = "" ; 
					}

			});
	 },

	getItemesInfo: function(obj){
			FindcompareDWR.getItemInfoList(this.sitecode, this.type, this.subtype,  function(data){
					obj.itemesInfo = data ; 
					obj.getItemesCode(obj);
					
			});
	 },

	getItemesCode: function(obj){
			FindcompareDWR.getItemCodeList(this.sitecode, this.type, this.subtype,  function(data){
				obj.itemesCode = data ; 
			
				if(obj.subtypename == 'byscreensize') obj.writeByScreenSize();
				else  obj.showAttributes();

				if(obj.subtypename == 'byscreensize' ) obj.getProducts(obj);
			});
	 },

	getProducts: function(obj){
			FindcompareDWR.getProductList(this.sitecode, this.type, this.subtype,  function(data){
					obj.products			= data ; 
					obj.resultCount			= data.length ; 
					obj.arrSearchResult		= data.clone();
					/*-------------------*/
					//제품의 키 속성값 얻기[속도 저하의 원인^^;]
					/*
					if(obj.prdKeyAttAll.length == 0){
						for(var i= 0 ; i < obj.products.length; i++){
							if(obj.products[i].KEY_ATT != null) obj.prdKeyAttAll +=  "|" + obj.products[i].KEY_ATT ; 
						  //if(obj.products[i].KEY_ATT != null) obj.prdKeyAttAll +=  "|" + obj.products[i].KEY_ATT+ '\n' ; 
						}
					}
					*/
					if(obj.subtypename == 'byscreensize' ){
						obj.getSelectedAttItemes();
						obj.getFindProductsByScreen();
					}
					obj.viewType	= 'THUMBNAIL';// THUMBNAIL (default) : LIST
					obj.setPaging();
					obj.getReturnURL(this, 1, null);
			});
	 },
	// DWR을 통한 데이터 얻기-------------------------------------------------------------------------END
	showTitle: function(){
			var _TYPE_NAME		= this.typeNameInfo[0].TYPE_NAME==null?'':this.typeNameInfo[0].TYPE_NAME ;
			var _SUBTYPE_NAME	= this.typeNameInfo[0].SUBTYPE_NAME==null?'':(' - ' + this.typeNameInfo[0].SUBTYPE_NAME) ; 

			if(this.specview == 'Y'){
				$('lowbTitle').innerHTML = '<b>' + MSG_FINDCOMPARE_TITLE + ' : ' + _TYPE_NAME + _SUBTYPE_NAME  + '</b>';
			}else{
				$('lowbTitle').innerHTML = '<b>' + _TYPE_NAME + _SUBTYPE_NAME  + '</b>';
			}//end if
	},

	//needs, spec key att. 정의
	showAttributes: function(){
		//init
		if(this.specview = 'Y' || this.subtypename == 'byscreensize' ){//결과 값이 10개 이상 또는 byscreensize가 아닐 때
			$('lowbImgReset').style.display			= '' ; 
			$('lowbNeedsAtt').innerHTML				= '' ; 
			$('lowbSpecAttArea').innerHTML			= '' ; 
			//$('lowbTitleAndAttributes').className	= 'subtype_lowband' ; 
			var existNeedsAtt = false ; 
			var isUsedNoNeedsAtt = false;
			for(var i = 0 ; i <= 4 && i < this.itemesInfo.length ; i++){
					//alert(this.itemesInfo[i].PRD_KEY_ATT_ITM_TYP_CD);
					//AND OR값 세팅
														
					this.arrAndOr.push(this.itemesInfo[i].PRD_KEY_ATT_ITM_OPRT_TYP_CD);
					
					if(this.itemesInfo[i].PRD_KEY_ATT_ITM_TYP_CD == '01'){
						this.writeNeedsAttribute(i) ;
						existNeedsAtt = true ; 
					}else{
						this.writeSpecAttribute(i);
					}//end if
					
					if(existNeedsAtt == false && isUsedNoNeedsAtt == false) {
						this.writeNoNeedsAttribute() ;
						isUsedNoNeedsAtt = true;
					}

			}//end for

		}else{//결과 값이 10개 이하 또는 byscreensize 일때
			$('lowbNeedsAtt').style.display			= 'none' ; 
			$('lowbSpecAttArea').style.display		= 'none' ; 
		}
	}, 

	//[2007-12-13]체크된 값을 없애고, needAtt의 className은 off로 처리
	resetAttributes: function(){

		var arrNeedsAtts = $('lowbNeedsAttUL').getElementsBySelector('li');
		for(var k = 0 ; k < arrNeedsAtts.length ; k++){
				if(arrNeedsAtts[k].className == 'on'){
					arrNeedsAtts[k].className = 'off'
					break;
				}
			}

		var arrSpecInput = $('lowbSpecAttArea').getElementsBySelector('INPUT');
		for(var k = 0 ; k < arrSpecInput.length ; k++){
			if(arrSpecInput[k].checked == true){
				arrSpecInput[k].checked = false; 
			}
		}
	},

	//엘리먼트 프로퍼티 정의
	setProperties: function (obj, _ID, _CLASS) {
		this.setProperties(obj, _ID, _CLASS, null);
	},
	
	////엘리먼트 프로퍼티 정의
	setProperties: function(obj, _ID, _CLASS, _TYPE) {
		obj.id = _ID ;
		if(_CLASS != null) obj.className = _CLASS ; 
		if(_TYPE != null) obj.type = _TYPE ; 
	},

	//display needs-attributes
	writeNeedsAttribute: function (idx) {
			
			//<strong>태그에 제품 키 속성 항목 명 보이기
			var tagSTRONG = document.createElement('strong');
			var tagP_NEEDS_TITLE = document.createElement('p');
			tagP_NEEDS_TITLE.style.width = '210px'; 
			
			//Needs Attributes일때...
			var text = document.createTextNode(this.itemesInfo[idx].PRD_KEY_ATT_ITM_NAME);
			tagP_NEEDS_TITLE.appendChild(text);
			tagP_NEEDS_TITLE.style.fontSize = "12px" ;
			tagSTRONG.appendChild(tagP_NEEDS_TITLE);
			$('lowbNeedsAtt').appendChild(tagSTRONG) ;  

			
			//Needs속성 리스트 보이기
			var tagUL = document.createElement('ul');
			tagUL.id = 'lowbNeedsAttUL' ; 

			var tmp = this.itemesInfo[idx].PRD_KEY_ATT_ITM_ID ; 

			for(var i = 0 ;  i < this.itemesCode.length ; i++){
				if(tmp ==  this.itemesCode[i].PRD_KEY_ATT_ITM_ID ){
					var _ID = this.itemesCode[i].PRD_KEY_ATT_ITM_ID + ',' + this.itemesCode[i].PRD_KEY_ATT_ITM_CD ; 
					 
					var _CLASS_NAME = 'off' ; 
					var tagLI		= document.createElement('li');
					this.setProperties(tagLI, _ID, _CLASS_NAME);

					var tagA		= document.createElement('a');
					tagA.href		= "javascript:setClassNames(objFindProducts, 'lowbNeedsAttUL', '"+_ID+"', 'on', 'off')";
					var text2		= document.createTextNode(this.itemesCode[i].PRD_KEY_ATT_ITM_CD_NAME) ; 
					tagA.style.fontSize = "11px" ;
					
					tagA.appendChild(text2); 
					tagLI.appendChild(tagA);
					tagUL.appendChild(tagLI);
				}else{
					if(i==0){
						$('lowbNeedsAtt').appendChild(tagUL) ;
						$('lowbNeedsAtt').innerHTML = '' ; 
						this.writeNoNeedsAttribute();
					}
					break ; 
				}//end if
			}//end for

			$('lowbNeedsAtt').appendChild(tagUL) ;
		},


	//display no needs-attributes
	writeNoNeedsAttribute: function() {
		
		//<strong>태그에 제품 키 속성 항목 명 보이기
		var tagSTRONG = document.createElement('strong');
		var tagP_NEEDS_TITLE = document.createElement('p');
		tagP_NEEDS_TITLE.style.width = '210px'; 
		
		var text = document.createTextNode("                ");
		tagP_NEEDS_TITLE.appendChild(text);
		tagSTRONG.appendChild(tagP_NEEDS_TITLE);
		$('lowbNeedsAtt').appendChild(tagSTRONG) ;  
		
		//Needs속성 리스트 보이기
		var tagUL = document.createElement('ul');
		tagUL.id = 'lowbNeedsAttUL' ; 

		for(var i = 0 ;  i < 4 ; i++){
			var _ID = "temp_" + i ; 
					 
			var _CLASS_NAME = 'off' ; 
			var tagLI		= document.createElement('li');
			tagLI.appendChild(document.createTextNode("           ")); 
			this.setProperties(tagLI, _ID, _CLASS_NAME);
			tagUL.appendChild(tagLI);
		}//end for

		$('lowbNeedsAtt').appendChild(tagUL) ;

	},

		//display spec-attributes
		writeSpecAttribute: function (idx) {

			//스펙관련 속성 그룹 div생성
			var tagParentDIV = document.createElement('div') ; 
			this.setProperties(tagParentDIV , 'lowbSpecAtt_'+idx , 'div_select_option' ) ;
			
			//<strong>태그에 제품 키 속성 항목 명 보이기
			var _PREVIOUS	= (idx ==0 || idx == 1)?this.itemesInfo[idx].PRD_KEY_ATT_ITM_NAME : this.itemesInfo[idx-1].PRD_KEY_ATT_ITM_NAME ; 
			var _NOW		= this.itemesInfo[idx].PRD_KEY_ATT_ITM_NAME ; 

			var tagSTRONG	= document.createElement('strong');
			var text		= null;

			//제품 키 속성 항목명 중복 체크
			if( idx > 1 && _PREVIOUS == _NOW){
				text		= document.createElement('BR');
			}else{
				text		= document.createTextNode(this.itemesInfo[idx].PRD_KEY_ATT_ITM_NAME);
			}

			tagSTRONG.style.fontSize = "12px" ;
			tagSTRONG.appendChild(text);
			tagParentDIV.appendChild(tagSTRONG) ;
			
			//스펙관련 속성 리스트 보이기
			var tmp = this.itemesInfo[idx].PRD_KEY_ATT_ITM_ID ; 
			for(var i = 0 ; i < this.itemesCode.length ; i++){
				
				if(tmp ==  this.itemesCode[i].PRD_KEY_ATT_ITM_ID ){
					
					var tagINPUT	= document.createElement('INPUT');
					var tagBR		= document.createElement('BR');
					var text		= document.createTextNode(' '+this.itemesCode[i].PRD_KEY_ATT_ITM_CD_NAME);

					var _ID			= this.itemesCode[i].PRD_KEY_ATT_ITM_ID + ',' + this.itemesCode[i].PRD_KEY_ATT_ITM_CD ; 
					this.setProperties(tagINPUT , _ID   , null, 'checkbox' ) ;
					tagINPUT.onclick = this.clickKeyAttItem.bind(this);
					tagParentDIV.style.fontSize = "11px" ;
					tagParentDIV.appendChild(tagINPUT) ;
					tagParentDIV.appendChild(text);
					tagParentDIV.appendChild(tagBR) ;
					
					 
				}//end if

			}//end for
			this.specIndex++ ;
			$('lowbSpecAttArea').appendChild(tagParentDIV)

		},

		//display the byscreensize for tv
		writeByScreenSize: function(){

			var tagParentUL = document.createElement('ul') ; 
			tagParentUL.id = "ByScreenSizeUL" ; 
			var count = 0 ; 
			//By Screen Size 속성 Tab 보이기
			for(var i = 0 ; i < this.itemesCode.length ; i++){
				
				if(this.itemesCode[i].PRD_KEY_ATT_ITM_ID == '2' ){
					var tagLI = document.createElement('li') ; 

					var strClass = null ; 
					if(count == 0 ){
						strClass = 'on' ; 
						count++ ;
					}else {
						strClass = 'off' ; 
					}

					var text		= document.createTextNode(this.itemesCode[i].PRD_KEY_ATT_ITM_CD_NAME);
					var _ID			= this.itemesCode[i].PRD_KEY_ATT_ITM_ID + ',' + this.itemesCode[i].PRD_KEY_ATT_ITM_CD ; 
				
					this.setProperties(tagLI , _ID , strClass ) ;
				
					var tagA		= document.createElement('a');
					tagA.href		= "javascript:showByScreenSize(objFindProducts, '"+ _ID +"')";
					tagA.appendChild(text);
					tagLI.appendChild(tagA);
					tagParentUL.appendChild(tagLI);
					 
				}//end if

			}//end for
			
			$('lowbByScreenSize').appendChild(tagParentUL)
			

		},

		//display a result bar
		showSearchResultBar: function(){

			//display products result count
			$('lowbResultCountTop').innerHTML		= this.resultCount;
			$('lowbResultCountBottom').innerHTML	= this.resultCount;
			
			//setting  view type images     
			if(this.viewType == 'THUMBNAIL'){
				$('lowbListImgTop').src		= "/" + this.sitecode + "/images/lowband/icon_listview_off.gif"
				$('lowbListImgBottom').src	= "/" + this.sitecode + "/images/lowband/icon_listview_off.gif"

				$('lowbThumbImgTop').src	= "/" + this.sitecode + "/images/lowband/icon_thumnailview_on.gif"	
				$('lowbThumbImgBottom').src = "/" + this.sitecode + "/images/lowband/icon_thumnailview_on.gif"				

			}else{
				$('lowbListImgTop').src		= "/" + this.sitecode + "/images/lowband/icon_listview_on.gif"
				$('lowbListImgBottom').src	= "/" + this.sitecode + "/images/lowband/icon_listview_on.gif"

				$('lowbThumbImgTop').src	= "/" + this.sitecode + "/images/lowband/icon_thumnailview_off.gif"	
				$('lowbThumbImgBottom').src = "/" + this.sitecode + "/images/lowband/icon_thumnailview_off.gif"				
			}//end if


		},

		//show a product's view
		showProductList: function(event, viewType){
			
			$('lowbNoData').style.display = 'none' ;

			if(this.viewType == 'THUMBNAIL'){
					this.writeThumbnailView();
			}else{
					this.writeListView();
			}//end if
		
		},
		
		//display a thumbnail's view
		writeThumbnailView: function(){

			//this.thumbnailPaging.getHTML();
			
			//display ThumbnailView
			$('lowbThumbnailView').innerHTML = '' ; 

			//for(var i = 0 ; i < this.arrSearchResult.length;i++){
			for(var i = this.thumbnailPaging.nFirstRecordOnCurrentPage  ;  i <  this.thumbnailPaging.nLastRecordOnCurrentPage ; i++){

					//thumbnail view관련 제품정보 LI 생성
					var tagParentLI = document.createElement('li') ; 
					//tagParentLI.style.backgroundColor="#CCFFCC"; 
					var _ID = this.arrSearchResult[i].PRD_MDL_CD + '|' + this.arrSearchResult[i].KEY_ATT ; 
					this.setProperties(tagParentLI , _ID , null ) ;

					var arrIaname	= this.getIaName(this.arrSearchResult[i].IANAME);

					//1.imgPRD 
					var tagIMG_DIV = document.createElement('div');
					tagIMG_DIV.className	= 'prod_img'; 
					var tagSM_IMG = document.createElement('img');
					tagIMG_DIV.id = this.arrSearchResult[i].PRD_MDL_CD ;
					tagIMG_DIV.name = arrIaname[2] ;
					var tmpSiteCode = this.sitecode ; 
	
					tagIMG_DIV.onclick=function(){
							goLowbDetail(tmpSiteCode, arrIaname[0],arrIaname[1], this.name, this.id);
					};

					tagSM_IMG.style.width	= '120px';
					tagSM_IMG.style.height	= '120px';
					tagIMG_DIV.style.cursor = 'pointer' ; 
					//tagSM_IMG.src			= '/se/system/consumer/product/2007/02/14/sgh_i607zkacin/mobile-phone_SGH-I607_small.jpg' ;//this.arrSearchResult[i].SM_IMG.split('|')[0] ;
					tagSM_IMG.src			= this.arrSearchResult[i].SM_IMG.split('|')[0] ;
					//tagSM_IMG.alt			= this.arrSearchResult[i].SM_IMG.split('|')[1] ;
					tagSM_IMG.className		= 'img_120';

					tagIMG_DIV.appendChild(tagSM_IMG);
					tagParentLI.appendChild(tagIMG_DIV);
					


					//2.BR
					//tagParentLI.appendChild(document.createElement('BR'));
					//[2007-12-10] d'strict 소스 수정 요청 사항
					var tagDivProductName =  document.createElement('DIV');
					tagDivProductName.className = 'product_namediv';


					//3.checkbox
					var tagINPUT = document.createElement('INPUT');
					_ID = this.arrSearchResult[i].PRD_MDL_CD ; //비교검색용.
			
					this.setProperties(tagINPUT , _ID , null , 'checkbox') ;
					//[2007-12-13] subtype로직 추가
					tagINPUT.name = arrIaname[2] ;

					tagINPUT.onclick=function(){
						var tmp = ARRAY_CHECKED_PRODUCT.clone();
						var tmpSUB = ARRAY_CHECKED_SUBTYPE.clone();

						if(this.checked == false){
							for(var i = 0 ; i < tmp.length ; i++){
								if(this.id == tmp[i]) tmp[i] = null; 
								if(this.name== tmpSUB[i]) tmpSUB[i] = null; 
							}//end for
							ARRAY_CHECKED_PRODUCT.clear();
							ARRAY_CHECKED_PRODUCT = tmp.compact();

							ARRAY_CHECKED_SUBTYPE.clear();
							ARRAY_CHECKED_SUBTYPE = tmp.compact();


						}else{
							if(ARRAY_CHECKED_PRODUCT.length == 3){ 
								//alert('You can select maximum 3');//다국어 처리
								alert(MSG_COMPARE_MAXIMUM);//다국어 처리
								this.checked = false ; 
								return ; 
							}
							ARRAY_CHECKED_PRODUCT.push(this.id);
							ARRAY_CHECKED_SUBTYPE.push(this.name);
						}
						
					};

					tagDivProductName.appendChild(tagINPUT);

					//4.strong : 제품 모델명

					var tagSTRONG = document.createElement('strong');
					tagSTRONG.className = 'product_name' ; 

					var tagAModel	= document.createElement('a');
					tagAModel.href	= "javascript:goLowbDetail('"+this.sitecode+"','"+arrIaname[0]+"','"+arrIaname[1]+"','"+arrIaname[2]+"','"+this.arrSearchResult[i].PRD_MDL_CD+"')";

					var prdMdlName	= this.arrSearchResult[i].PRD_MDL_NAME ;
					//var prdMdlName	= this.arrSearchResult[i].PRD_MDL_NAME.toUpperCase().split(' ')[0] ;
					//prdMdlName		= prdMdlName.replace('\n\r', '');
					
					var text1 = document.createTextNode(" "+ prdMdlName + " ");
					tagAModel.appendChild(text1);
					tagSTRONG.appendChild(tagAModel);
					tagDivProductName.appendChild(tagSTRONG) ;   

					//6.BR
					//tagParentLI.appendChild(document.createElement('BR'));

					//

					switch(this.arrSearchResult[i].HOT_ICON_TYP_CD){
						case 'H'://5.1 hot img : optional
							var tagHOT = document.createElement('img');
								tagHOT.src = '/' + this.sitecode + '/images/common/icon_hot.gif' ;
								//tagHOT.alt = 'hot' ;
								tagDivProductName.appendChild(tagHOT) ;  

							break ; 
						case 'E'://5.2 event img : optional
							var tagHOT = document.createElement('img');
								tagHOT.src = '/' + this.sitecode + '/images/common/icon_event.gif' ;
								//tagHOT.alt = 'event' ;
								tagDivProductName.appendChild(tagHOT) ;  

							break ;
						case 'W'://5.3 new img : optional
							var tagHOT = document.createElement('img');
								tagHOT.src = '/' + this.sitecode + '/images/common/icon_new.gif' ;
								//tagHOT.alt = 'new' ;
								tagDivProductName.appendChild(tagHOT) ;  
							break ;

					}//end switch 
			
					//6.BR
					//tagParentLI.appendChild(document.createElement('BR'));
					tagParentLI.appendChild(tagDivProductName);

					//7.strong:PRD_MKT_NAME(optional)
					/*
					var text2 ;
					if(this.arrSearchResult[i].PRD_MKT_NAME==null){
						//text2	= document.createElement('BR');
					}else{
						var tagSTRONG_PRD_MKT_NAME = document.createElement('strong');
						tagSTRONG_PRD_MKT_NAME.className = 'pet_name' ; 
						//text2	= document.createTextNode(this.arrSearchResult[i].PRD_MKT_NAME.maxLen(15));
						text2	= document.createTextNode(this.arrSearchResult[i].PRD_MKT_NAME);
						tagSTRONG_PRD_MKT_NAME.appendChild(text2);
						tagParentLI.appendChild(tagSTRONG_PRD_MKT_NAME) ;  
					}//end if
					*/

					//8.BR
					//tagParentLI.appendChild(document.createElement('BR'));

					//9.DIV
					var tagDIV = document.createElement('div');
					
					tagDIV.className = 'product_desc';

					//10. strong -> P tag: 제품설명
					//var tagP_PRD_DESC = document.createElement('p');

					var text2 ;
					if(this.arrSearchResult[i].PRD_MKT_NAME==null){
						//text2	= document.createElement('BR');
					}else{
						var tagSTRONG_PRD_MKT_NAME = document.createElement('strong');
						tagSTRONG_PRD_MKT_NAME.className = 'pet_name' ; 
						//text2	= document.createTextNode(this.arrSearchResult[i].PRD_MKT_NAME.maxLen(15));
						text2	= document.createTextNode(this.arrSearchResult[i].PRD_MKT_NAME);
						tagSTRONG_PRD_MKT_NAME.appendChild(text2);
						tagDIV.appendChild(tagSTRONG_PRD_MKT_NAME) ;  
					}//end if
					
					tagDIV.appendChild(document.createElement('BR'));

					var text3 = document.createTextNode(this.arrSearchResult[i].PRD_COPY_TEXT.maxLen(36));
					tagDIV.appendChild(text3);
					//tagP_PRD_DESC.style.overflow="hidden";
					
					//11.BR
					//tagDIV.appendChild(document.createElement('BR'));
				
					//appendChild DIV
					tagParentLI.appendChild(tagDIV) ;  		

					//12. appendChild  LI
					$('lowbThumbnailView').appendChild(tagParentLI);

			}//end for

			$('lowbThumbnailView').style.display	= '' ; 
			$('lowbListView').style.display			= 'none' ; 
			$('lowbPaging').style.display			= '' ; 

			this.showSearchResultBar();

		},
		
		//display a list's view
		writeListView: function(){
			
			$('lowbListView').innerHTML = '' ; 
			//for(var i = 0 ; i < this.arrSearchResult.length;i++){
			for(var i = this.listPaging.nFirstRecordOnCurrentPage  ;  i <  this.listPaging.nLastRecordOnCurrentPage ; i++){

					var tagParentLI = document.createElement('li') ; 
					//tagParentLI.style.backgroundColor="#CCFFCC"; 
					
					var _ID = this.arrSearchResult[i].PRD_MDL_CD + '|' + this.arrSearchResult[i].KEY_ATT ; 
					this.setProperties(tagParentLI , _ID , null ) ;

					var arrIaname		= this.getIaName(this.arrSearchResult[i].IANAME);

					//1.imgPRD 
					var tagIMG_SPAN = document.createElement('span');
					tagIMG_SPAN.className = 'prod_img'; 
					var tagSM_IMG = document.createElement('img');

					tagIMG_SPAN.id = this.arrSearchResult[i].PRD_MDL_CD ;
					tagIMG_SPAN.name= arrIaname[2] ;

					var tmpSiteCode = this.sitecode ; 

					tagIMG_SPAN.onclick=function(){
							goLowbDetail(tmpSiteCode, arrIaname[0],arrIaname[1],this.name, this.id);
					};

					tagSM_IMG.style.width = '120px';
					tagSM_IMG.style.height = '120px';
					tagIMG_SPAN.style.cursor = 'pointer' ; 

					tagSM_IMG.src = this.arrSearchResult[i].SM_IMG.split('|')[0] ;
					//tagSM_IMG.alt = this.arrSearchResult[i].SM_IMG.split('|')[1] ;
					tagSM_IMG.className = 'img_120';
					tagIMG_SPAN.appendChild(tagSM_IMG);
					tagParentLI.appendChild(tagIMG_SPAN);
					
					//[2007-12-10] D'STRICT 요청 추가
					var tagDivListRT =  document.createElement('DIV');
					tagDivListRT.className = 'list_rt';

					var tagDivProductName =  document.createElement('DIV');
					tagDivProductName.className = 'product_namediv';



					//2.checkbox
					var tagINPUT = document.createElement('INPUT');
					_ID = this.arrSearchResult[i].PRD_MDL_CD ; //비교검색용.
					this.setProperties(tagINPUT , _ID , null , 'checkbox') ;
					tagINPUT.name = arrIaname[2] ;

					tagINPUT.onclick=function(){
						var tmp = ARRAY_CHECKED_PRODUCT.clone();
						var tmpSUB = ARRAY_CHECKED_SUBTYPE.clone();

						if(this.checked == false){
							for(var i = 0 ; i < tmp.length ; i++){
								if(this.id == tmp[i]) tmp[i] = null; 
								if(this.name== tmpSUB[i]) tmpSUB[i] = null; 
							}//end for
							ARRAY_CHECKED_PRODUCT.clear();
							ARRAY_CHECKED_PRODUCT = tmp.compact();

							ARRAY_CHECKED_SUBTYPE.clear();
							ARRAY_CHECKED_SUBTYPE = tmp.compact();


						}else{
							if(ARRAY_CHECKED_PRODUCT.length == 3){ 
								//alert('You can select maximum 3');//다국어 처리
								alert(MSG_COMPARE_MAXIMUM);//다국어 처리
								this.checked = false ; 
								return ; 
							}
							ARRAY_CHECKED_PRODUCT.push(this.id);
							ARRAY_CHECKED_SUBTYPE.push(this.name);
						}
						
					};

					tagDivProductName.appendChild(tagINPUT);

					//3.strong : 제품 모델명
					var tagAModel	= document.createElement('a');
					tagAModel.href	= "javascript:goLowbDetail('"+this.sitecode+"','"+arrIaname[0]+"','"+arrIaname[1]+"','"+arrIaname[2]+"','"+this.arrSearchResult[i].PRD_MDL_CD+"')";

					var tagSTRONG = document.createElement('strong');
					tagSTRONG.className = 'product_name' ; 

					//var prdMdlName	= this.arrSearchResult[i].PRD_MDL_NAME.toUpperCase().split(' ')[0] ;
					//prdMdlName		= prdMdlName.replace('\n\r', '');

					var prdMdlName	= this.arrSearchResult[i].PRD_MDL_NAME ;
					var text1 = document.createTextNode(" " + prdMdlName + " " );
					tagAModel.appendChild(text1);
					tagSTRONG.appendChild(tagAModel);
					tagDivProductName.appendChild(tagSTRONG) ;  

					//4.1 hot img : optional
					switch(this.arrSearchResult[i].HOT_ICON_TYP_CD){
						case 'H'://4.1 hot img : optional
							var tagHOT = document.createElement('img');
								tagHOT.src = '/' + this.sitecode + '/images/common/icon_hot.gif' ;
								//tagHOT.alt = 'hot' ;
								tagDivProductName.appendChild(tagHOT) ;  
							break ; 
						case 'E'://4.2 event img : optional
							var tagHOT = document.createElement('img');
								tagHOT.src = '/' + this.sitecode + '/images/common/icon_event.gif' ;
								//tagHOT.alt = 'event' ;
								tagDivProductName.appendChild(tagHOT) ;  
							break ;
						case 'W'://4.3 new img : optional
							var tagHOT = document.createElement('img');
								tagHOT.src = '/' + this.sitecode + '/images/common/icon_new.gif' ;
								//tagHOT.alt = 'new' ;
								tagDivProductName.appendChild(tagHOT) ;  
							break ;

					}//end switch 

					//5.BR
					//tagDivProductName.appendChild(document.createElement('BR'));
					tagDivListRT.appendChild(tagDivProductName);
					
/*
					//6.strong:PRD_MKT_NAME(optional)
					var tagSTRONG_PRD_MKT_NAME = document.createElement('strong');
					tagSTRONG_PRD_MKT_NAME.className = 'pet_name' ; 
					var text2 ;
					if(this.arrSearchResult[i].PRD_MKT_NAME==null){
					}else{
						text2	= document.createTextNode(this.arrSearchResult[i].PRD_MKT_NAME);
						tagSTRONG_PRD_MKT_NAME.appendChild(text2);
						tagParentLI.appendChild(tagSTRONG_PRD_MKT_NAME) ; 
					}//end if
*/

					//7.BR
					//tagParentLI.appendChild(document.createElement('BR'));

					//8.DIV
					var tagDIV = document.createElement('div');
					tagDIV.className = 'product_desc';

					//6.strong:PRD_MKT_NAME(optional)
					var tagSTRONG_PRD_MKT_NAME = document.createElement('strong');
					tagSTRONG_PRD_MKT_NAME.className = 'pet_name' ; 
					var text2 ;
					if(this.arrSearchResult[i].PRD_MKT_NAME==null){
					}else{
						text2	= document.createTextNode(this.arrSearchResult[i].PRD_MKT_NAME);
						tagSTRONG_PRD_MKT_NAME.appendChild(text2);
						tagDIV.appendChild(tagSTRONG_PRD_MKT_NAME) ; 
						//7.BR
						tagDIV.appendChild(document.createElement('BR'));
					}//end if

					//9.strong : PRD_COPY_TEXT
					var tagSTRONG_PRD_COPY_TEXT = document.createElement('strong');
					
					//[2007-11-29] PRD_COPY_TEXT에 html태그값이 들어 올수 있으므로 이에 대한 로직 추가
					//var text3 = document.createTextNode(this.arrSearchResult[i].PRD_COPY_TEXT);
					//tagSTRONG_PRD_COPY_TEXT.appendChild(text3);
					var text3 = this.arrSearchResult[i].PRD_COPY_TEXT.maxLen(64);
					var replacedTEXT = text3.replace('\n' , '<BR>') ;
					tagSTRONG_PRD_COPY_TEXT.innerHTML = replacedTEXT;
					tagDIV.appendChild(tagSTRONG_PRD_COPY_TEXT) ;  

					//10.BR
					tagDIV.appendChild(document.createElement('BR'));
					
					//11. FTRS_TITLE
					var arrTemp = this.arrSearchResult[i].FTRS_TITLE.split('|') ; 
					for(var j = 0 ; j < arrTemp.length ; j++ ){
						arrTemp[j] = arrTemp[j].stripTags() ;
						var strTemp = '-' + arrTemp[j].maxLen(30) ;
						tagDIV.appendChild(document.createTextNode(strTemp));
						tagDIV.appendChild(document.createElement('BR'));
					}//end for j

					//12.more image
					var tagA		= document.createElement('a');
					
					tagA.href		= "javascript:goLowbDetail('"+this.sitecode+"','"+arrIaname[0]+"','"+arrIaname[1]+"','"+arrIaname[2]+"','"+this.arrSearchResult[i].PRD_MDL_CD+"')";
					var tagMORE_IMG = document.createElement('img');
					
					tagMORE_IMG.src = '/'+this.sitecode+'/images/common/txt_more.gif' ;

					tagA.appendChild(tagMORE_IMG);
					tagDIV.appendChild(tagA);
	
					tagDIV.appendChild(document.createElement('BR'));

					//13. features/specifications/gallery
					var tagFEATURES_A		= document.createElement('a');
					tagFEATURES_A.href		= "javascript:goFeatures('"+this.sitecode+"','"+arrIaname[0]+"','"+arrIaname[1]+"','"+arrIaname[2]+"','"+this.arrSearchResult[i].PRD_MDL_CD+"')";
					tagFEATURES_A.appendChild(document.createTextNode("• "+ MSG_FEATURES_TITLE));
					tagDIV.appendChild(tagFEATURES_A);

					tagDIV.appendChild(document.createElement('BR'));

					var tagSPECIFICATIONS_A		= document.createElement('a');
					tagSPECIFICATIONS_A.href	= "javascript:goSpecifications('"+this.sitecode+"','"+arrIaname[0]+"','"+arrIaname[1]+"','"+arrIaname[2]+"','"+this.arrSearchResult[i].PRD_MDL_CD+"')";
					tagSPECIFICATIONS_A.appendChild(document.createTextNode("• " + MSG_SPECIFICATIONS_TITLE));
					tagDIV.appendChild(tagSPECIFICATIONS_A);

					tagDIV.appendChild(document.createElement('BR'));

					if(this.arrSearchResult[i].ARCHV_PRD_FL == 'N' && this.arrSearchResult[i].IMGCNT > 0){
						var tagGALLERY_A		= document.createElement('a');
						tagGALLERY_A.href		= "javascript:goGallery('"+this.sitecode+"','"+arrIaname[0]+"','"+arrIaname[1]+"','"+arrIaname[2]+"','"+this.arrSearchResult[i].PRD_MDL_CD+"')";
						tagGALLERY_A.appendChild(document.createTextNode("• "+ MSG_GALLERY_TITLE));
						tagDIV.appendChild(tagGALLERY_A);
					}

					tagDivListRT.appendChild(tagDIV); 
					tagParentLI.appendChild(tagDivListRT);

					//14.appendChild  LI
					$('lowbListView').appendChild(tagParentLI);
				
			}//end for i

			$('lowbThumbnailView').style.display	= 'none' ; 
			$('lowbListView').style.display			= '' ;
			$('lowbPaging').style.display			= '' ; 

			this.showSearchResultBar();

		}, 
		
		// show a no data's view
		showNoDataView: function(){
			$('lowbThumbnailView').style.display	= 'none' ; 
			$('lowbListView').style.display			= 'none' ; 
			$('lowbPaging').style.display			= 'none' ; 
			$('lowbNoData').style.display			= '' ;	
			this.showSearchResultBar();
			//this.writeHotProductListView();
 
		},

		//page객체 생성 및 속성 정의 
		setPaging: function(){
			//initialize: sitecode, totalRows, currentPage, pageSize, blockSize 
			this.listPaging	 = null ;
			this.thumbnailPaging = null ;
			this.listPaging			=  new Paging(this.sitecode, this.resultCount, 1,  6, 10); 
			this.thumbnailPaging	=  new Paging(this.sitecode, this.resultCount, 1, 10, 10); 
		},
		
		//전체 화면 변경 
		getReturnURL: function( event, page, viewType ){

			if(viewType != null ){
				this.viewType = viewType ; 
			}
		
			if(this.viewType == 'LIST'){
				this.listPaging.getReturnURL(page);
			}else{
				this.thumbnailPaging.getReturnURL(page);
			}

			if(this.arrSearchResult.length > 0){
				this.showProductList(this, this.viewType);
			}else{
				this.showNoDataView();
			}

			if(viewType != null ){
				this.setCompareProducts();
			}
		}, 
		
		//result products와 관련이 없는 속성을 비활성화 시킨다.(현재 사용안함)
		initKeyAttItemes: function(){

			/*-------------------*/
			//initKeyAttItemes
			var arrNeedsAtts = $('lowbNeedsAttUL').getElementsBySelector('li');

			for(var i = 0 ; i < arrNeedsAtts.length ; i++){
					if(this.prdKeyAttAll.indexOf(arrNeedsAtts[i].id) == -1){
							var tagA = $(arrNeedsAtts[i].id).getElementsBySelector('a')[0]; 
							tagA.href='#none';
							tagA.style.cursor = 'default';
					}
			}
			/*-------------------*/
			var arrSpecInput = $('lowbSpecAttArea').getElementsBySelector('INPUT');

			for(var i = 0 ; i < arrSpecInput.length ; i++){
					if(this.prdKeyAttAll.indexOf(arrSpecInput[i].id) == -1){
							 arrSpecInput[i].disabled = true ; 
							 //arrSpecInput[i].style.backgroundImage = "/" + this.sitecode + "/images/lowband/chkdisable.gif" ;
					}
			}
			/*-------------------*/
				

		},

		//선택한 속성정보를 구한다. 
		getSelectedAttItemes: function(){

			this.arrSelectedKeyAtt.clear();

			if(this.subtypename == 'byscreensize' ){
				
				var arrSpecAtts = $('ByScreenSizeUL').getElementsBySelector('li');

				for(var i = 0 ; i < arrSpecAtts.length ; i++){
						if(arrSpecAtts[i].className == 'on'){
							this.arrSelectedKeyAtt.push(arrSpecAtts[i].id);
						}
				}

			}else{
				//initKeyAttItemes
				var arrNeedsAtts = $('lowbNeedsAttUL').getElementsBySelector('li');

				for(var i = 0 ; i < arrNeedsAtts.length ; i++){
						if(arrNeedsAtts[i].className == 'on'){
							this.arrSelectedKeyAtt.push(arrNeedsAtts[i].id);
						}
				}

				var arrSpecInput = $('lowbSpecAttArea').getElementsBySelector('INPUT');

				for(var i = 0 ; i < arrSpecInput.length ; i++){
					if(arrSpecInput[i].checked == true){
						this.arrSelectedKeyAtt.push(arrSpecInput[i].id);
					}
				}
			 }
			
		},

		//선택한 속성정보와 관련된 제품정보를 구한다.
		//getFindProducts: function(){
		getFindProductsByScreen: function(){
			var number = 0 ; 
			this.arrSearchResult.clear();
			//alert('this.products.length:' + this.products.length);
			var arrTemp = this.products.clone() ; 

			//alert(arrTemp.length);
			for(var i = 0 ; i < this.arrSelectedKeyAtt.length ; i++){
				for(var j = 0 ;  j < arrTemp.length ; j++){
					if(arrTemp[j] != null ){
						var tmpKeyAtt = arrTemp[j].KEY_ATT==null?'': arrTemp[j].KEY_ATT ;
						
						if(tmpKeyAtt.indexOf(this.arrSelectedKeyAtt[i]) == -1 ){
							arrTemp[j] = null ; 
						//}else{
						//	alert( arrTemp[j].PRD_MDL_NAME + ':'+ this.arrSelectedKeyAtt[i] + ':' + tmpKeyAtt);
						}//end if
					}
				}//end for j
			}//end for i

			this.arrSearchResult = arrTemp.compact();
			this.resultCount = this.arrSearchResult.length ; 
		},

		/*----------------------------------------------------------------------------------*/
		//[2007-12-13] Flex 로직 적용
		getFindProducts: function (){

				var i=0;//:int;
				var j=0;//:int;
				var k=0;//:int;
				

				this.arrSearchResult.clear();
				
				var arrTemp = this.products.clone() ; 
				intProductTCnt = 0;
				//alert('<arrTemp.length:' + arrTemp.length);
				//alert('<this.arrAndOr.length:' + this.arrAndOr.length);

				for(j=0; j<arrTemp.length; j++){
					var boolProductChk=[];//:Array = [];
					var number = 1 ; 
					for(i=0; i<this.arrAndOr.length; i++){
						//var arrSpec= [];
						this.arrSelectedKeyAtt.clear();
						var strNeedGubun="";//:String;

						//** getSelectedAttItemes()로 대체 시킴 
						if(this.itemesInfo[i].PRD_KEY_ATT_ITM_TYP_CD == '01'){ // Need
							strNeedGubun = "N";
							var arrNeedsAtts = $('lowbNeedsAttUL').getElementsBySelector('li');
							for(var k = 0 ; k < arrNeedsAtts.length ; k++){
									if(arrNeedsAtts[k].className == 'on'){
										this.arrSelectedKeyAtt.push(arrNeedsAtts[k].id);
										break ; 
									}
							}
						}
						else{ // Spec
							strNeedGubun = "S";
							var arrSpecInput = $('lowbSpecAtt_'+ i ).getElementsBySelector('INPUT');

							for(var k = 0 ; k < arrSpecInput.length ; k++){
								if(arrSpecInput[k].checked == true){
									this.arrSelectedKeyAtt.push(arrSpecInput[k].id);
								}
							}

						}
						//var boolPro:Boolean = getProductChk(arrSpec, arrAndOr[i].toString(), (arrPro[j] as findProduct), strNeedGubun);
						var boolPro  = this.getProductChk(this.arrSelectedKeyAtt, this.arrAndOr[i], arrTemp[j], strNeedGubun);
						
						//alert('boolPro:'+boolPro);
						boolProductChk.push(boolPro);
					}//end i

					var boolTempLast = true;

					for(var m=0; m<boolProductChk.length; m++){
						//getProductChk를 돌려서 한번이라도 false가 나오면 제품이 선택되지 않음
						if(boolProductChk[m] == false) boolTempLast = false;
					}

					//제품이 선택 되어 졌을 때 ....
					if(!boolTempLast){
						//alert('boolTempLast!');
						arrTemp[j] = null ; 
						continue; 
					}
					
				}//end for for(j=0; j<arrPro.length; j++){
			
				this.arrSearchResult = arrTemp.compact();
				this.resultCount = this.arrSearchResult.length ; 
				 
		},

		/*----------------------------------------------------------------------------------*/

		//[2007-12-13] Flex 로직 적용
		getProductChk: function(arrSpec, strAndOr, objPro, strNeedGubun){
			//alert(arrSpec.length+'::'+ strAndOr+'::'+ objPro.KEY_ATT+'::'+ strNeedGubun);
			var boolTemp = false;
			var i=0; //:int;
			var j=0; //:int;
			var arrProSpec=[] ;//:Array;
			var arrSpec01=[];//:Array;
			var arrSpec02=[];//:Array;
			var strKeyAtt="";//:String = "";

			strKeyAtt = ("|"+objPro.KEY_ATT+"|");

			if(arrSpec.length == 0)
				return true;

			if(strNeedGubun == "N"){
				for(i=0; i<arrSpec.length; i++){
					if(strKeyAtt.indexOf(arrSpec[i]) > -1)
						return true;
				}
			}
			else{
				if(strAndOr == "OR"){
					for(i=0; i<arrSpec.length; i++){
						if(strKeyAtt.indexOf(arrSpec[i]) > -1)
							return true;
					}
				}
				else{//END 조건일때 
					boolTemp = true;
					var intCnt=0 ;//:int = 0;
					for(i=0; i<arrSpec.length; i++){
						//제품 스펙정보가 없을때 바로 FALSE로 처리한다. 
						if(!objPro.KEY_ATT) return false;
						//AND 조건일때 제품에  속한 스펙을  배열화 처리 시킨다. 
						arrProSpec = objPro.KEY_ATT.split("|");
						for(j=0; j<arrProSpec.length; j++){//제품에 속한 스펙을 배열로  처리하여 LOOP를 돌린다. 
							arrSpec01 = arrProSpec[j].toString().split(",");//
							arrSpec02 = arrSpec[i].toString().split(",");//
					
							if((arrSpec01[0] == arrSpec02[0].toString().replace("|","")) && (arrSpec01[1] == arrSpec02[1].toString().replace("|",""))){
								intCnt = intCnt + 1;
							}
						}
					}
					if(intCnt == arrSpec.length){
						return true;
					}
					else{
						return false;
					}
				}
			}

			return boolTemp;
		},

		/*----------------------------------------------------------------------------------*/
		
		//제품정보를 초기화 한다. 
		resetProducts: function(){
			this.arrSearchResult.clear();
			this.arrSearchResult	= this.products.clone();
			this.resultCount		= this.arrSearchResult.length ; 
			//this.showAttributes();
			this.resetAttributes();
		},

		//click attributes
		clickKeyAttItem: function(type){
			
			ARRAY_CHECKED_PRODUCT.clear() ;
			ARRAY_CHECKED_SUBTYPE.clear() ;

			if(type == 'RESET'){ 
				this.resetProducts();
			}else if(type == 'byscreensize'){
				this.getSelectedAttItemes();
				this.getFindProductsByScreen();
			}else{
				//this.getSelectedAttItemes();
				this.getFindProducts();
			}

			this.setPaging();
			this.getReturnURL(this, 1, null) ;
		},
		
		//get IAMANE(group,type,subtype)
		getIaName: function(_IANAME){
			
			var arrIaname = _IANAME.split("|");
			var arrLink = [];

			for(var i=arrIaname.length-1; i>=0; i--){
				arrLink.push(arrIaname[i].split(";")[1]);
			}
			
			return arrLink ; 
		},

		//set compare products 
		setCompareProducts: function(){
			var elementINPUTS;
			if(this.viewType == 'THUMBNAIL') elementINPUTS = $('lowbThumbnailView').getElementsBySelector('INPUT');
			else elementINPUTS = $('lowbListView').getElementsBySelector('INPUT');

			for(var i = 0 ; i < elementINPUTS.length ; i++){
				for(var j = 0 ; j < ARRAY_CHECKED_PRODUCT.length ; j++){
					if( ARRAY_CHECKED_PRODUCT[j] == elementINPUTS[i].id ) elementINPUTS[i].checked = true ; 
				}//end for j
			}//end for i
		}
		

	
}//end FindProducts class


//set css's class name
function setClassName(_ID, _CLASS_NAME){ 
	$(_ID).className=_CLASS_NAME; 
} 

//set css's class name & click an attribute
function setClassNames(obj, _PARENT, _ID,  _CLASS_NAME_1, _CLASS_NAME_2){
		
	var child = $(_PARENT).descendants();
	child.each(function(value, index){ if(value.className == _CLASS_NAME_1) value.className = _CLASS_NAME_2 ; return;});
	$(_ID).className=_CLASS_NAME_1; 
	obj.clickKeyAttItem();

}

//link to detail page
function goLowbDetail(sitecode, group, type, subtype, model_cd){
	var strUrl = "/"+sitecode+"/consumer/detail/detail.do?group="+group+"&type="+type+"&subtype="+subtype+"&model_cd="+model_cd;
	location.href=strUrl;
}

//link to features page
function goFeatures(sitecode, group, type, subtype, model_cd){
	var strUrl = "/"+sitecode+"/consumer/detail/features.do?group="+group+"&type="+type+"&subtype="+subtype+"&model_cd="+model_cd;
	location.href=strUrl;
}

//link to specifications page
function goSpecifications(sitecode, group, type, subtype, model_cd){
	var strUrl = "/"+sitecode+"/consumer/detail/spec.do?group="+group+"&type="+type+"&subtype="+subtype+"&model_cd="+model_cd;
	location.href=strUrl;
}

//link to gellery page
function goGallery(sitecode, group, type, subtype, model_cd){
	var strUrl = "/"+sitecode+"/consumer/detail/gallery.do?group="+group+"&type="+type+"&subtype="+subtype+"&model_cd="+model_cd;
	location.href=strUrl;
}

//link to compare products page
function goCompareProducts(sitecode){

	var strUrl = ""; 
	if(SUBTYPE_NAME.length == 0 ){
		strUrl = "/"+sitecode+"/consumer/type/compare.do?group="+GROUP_NAME+"&type="+TYPE_NAME+"&subtype="+SUBTYPE_NAME ;
		var arrArgSubTypeNames = ['&suba=','&subb=','&subc='];

		if(ARRAY_CHECKED_PRODUCT.length > 1 && ARRAY_CHECKED_PRODUCT.length <= 3){
			for(var i = 0 ; i < ARRAY_CHECKED_PRODUCT.length ; i++){
			strUrl+= ( arrArgSubTypeNames[i] + ARRAY_CHECKED_SUBTYPE[i] ) ;
			}
		}//end if

	}else{
		strUrl = "/"+sitecode+"/consumer/type/compare.do?group="+GROUP_NAME+"&type="+TYPE_NAME+"&subtype="+SUBTYPE_NAME ;
	}
	
	var arrArgNames = ['&prda=','&prdb=','&prdc='];
	
	if(ARRAY_CHECKED_PRODUCT.length > 1 && ARRAY_CHECKED_PRODUCT.length <= 3){
		for(var i = 0 ; i < ARRAY_CHECKED_PRODUCT.length ; i++){
			strUrl+= ( arrArgNames[i] + ARRAY_CHECKED_PRODUCT[i] ) ;
		}
		location.href=strUrl;
	}else{
		//alert('You have to select at least 2 products');//다국어 필요
		alert(MSG_COMPARE_MINIMUM);//다국어 필요
	}
}

//click tabs for a byscreensize
function showByScreenSize(obj, _ID){

	var arrByScreenSize = $('ByScreenSizeUL').getElementsBySelector('li') ; 
	for(var i = 0 ; i < arrByScreenSize.length ; i++){
		if(arrByScreenSize[i].id == _ID) arrByScreenSize[i].className  =  'on' ;
		else arrByScreenSize[i].className  =  'off' ;
	}

	obj.clickKeyAttItem('byscreensize');
}


// * string String::maxLen(int len)
String.prototype.maxLen = function(len) {
		 var str = this;
		 var l = 0;
		 for (var i=0; i<str.length; i++) {
				 l += (str.charCodeAt(i) > 128) ? 2 : 1;
				 if (l > len) return str.substring(0,i) + "...";
		 }
		 return str;
  }


var DisplayController = Class.create();

DisplayController.prototype = {

	initialize: function(findProducts){
			this.findProducts = findProducts ; 
			this.findProducts.getData();
	} //end initialize 

}


var Paging = Class.create();

Paging.prototype = {

	initialize: function( sitecode, totalRows, currentPage, pageSize, blockSize ){

		this.sitecode		= sitecode ;	//국가코드
		//this.sURL			= url ;			//페이징을 쓰고있는 현제 페이지명
		this.nTotalRows		= totalRows ;	//총 레코드수
		this.nCurrentPage	= currentPage ; //현재 페이지
		this.nPageSize		= pageSize ;	//페이지당 레코드 갯수
		this.nBlockSize		= blockSize ;	//각 페이지당 보여줄 페이지 블록의 개수 (예:  < 1 2 3 4 5 >  에서의 숫자부분의 갯수)
		this.nStartPage		= 1 ;			//현재 블럭에서 최초로 표시되는 페이지

		this.needPrevBlockAction = true ;	//이전 블럭 링크가 필요한 지의 여부
		this.needNextBlockAction = true ;	// 다음 블럭 링크가 필요한 지의 여부
		//this.calculate();
		
	},

	nTotalPages		: 0 ,	//총페이지 수
	nTotalBlocks	: 0 ,	//총블럭 수
	nCurrentBlock	: 0 ,	//현재 블럭

	nFirstRecordOnCurrentPage	: 0 ,	//현재 페이지 첫번째
	nLastRecordOnCurrentPage	: 0 ,	//현재 페이지 마지막번째

	//생성자의 입력값으로부터 필요한 값들을 계산해낸다.
	calculate: function(){

        this.nTotalPages			= parseInt((this.nTotalRows - 1) / this.nPageSize) + 1;
        this.nTotalBlocks			= parseInt((this.nTotalPages - 1) / this.nBlockSize) + 1;
        this.nCurrentBlock			= parseInt((this.nCurrentPage - 1) / this.nBlockSize) + 1;

        this.needPrevBlockAction	= (this.nCurrentBlock > 1);
        this.needNextBlockAction	= (this.nCurrentBlock < this.nTotalBlocks);
        this.nStartPage				= (this.nCurrentBlock - 1) * this.nBlockSize + 1;

		
		this.nLastRecordOnCurrentPage  =  (this.nCurrentPage * this.nPageSize ) ;
		if(this.nLastRecordOnCurrentPage > this.nTotalRows ) this.nLastRecordOnCurrentPage  =  this.nTotalRows ;

		this.nFirstRecordOnCurrentPage  =  (this.nCurrentPage - 1 ) * this.nPageSize  ;

		//alert('this.nFirstRecordOnCurrentPage:'+this.nFirstRecordOnCurrentPage);
		//alert('this.nLastRecordOnCurrentPage:'+this.nLastRecordOnCurrentPage);

	}, 

	// 페이지가 변경될때의 새로운 URL을 반환한다.
	getReturnURL: function(page){
		this.nCurrentPage = page ; 
		this.calculate();
		this.getHTML();
	},
	
	getHTML: function(){
		
		$('lowbPaging').innerHTML = '';

		var buff = "";
		if (this.needPrevBlockAction) {
           buff += "<a href='javascript:objFindProducts.getReturnURL(this, " + (this.nStartPage - this.nBlockSize) + ",objFindProducts.viewType)' ><img src='/"+this.sitecode+"/images/public/btn_leftarrow1.gif' border='0' class='paging_prev'></a>\n" ;
        }
        else {
           buff +="<img src='/"+this.sitecode+"/images/public/btn_leftarrow1.gif' border='0'  class='paging_prev'>\n";
        }
		

        for (var i=0; i < this.nBlockSize; i++) {
            var sHtml = "";
            var n = i + this.nStartPage;

            if (n <= this.nTotalPages) {

                if (n == this.nCurrentPage) {
                    sHtml = "<strong>"+n+"</strong>\n";
                }else{
                    sHtml = "<a href='javascript:objFindProducts.getReturnURL(this, "+n+", objFindProducts.viewType)' >" + n + "</a>\n";
                }

				if( n <= this.nTotalPages -1 ) sHtml += "<span>|</span>\n" ;
				
				buff += sHtml ;
            }
            else break;
        }

		if (this.needNextBlockAction) {
           buff += "<a href='javascript:objFindProducts.getReturnURL(this, " + (this.nStartPage + this.nBlockSize) + ", objFindProducts.viewType)' ><img src='/"+this.sitecode+"/images/public/btn_rightarrow1.gif' border='0'  class='paging_prev'></a>\n" ;
        }
        else {
		   buff +="<img src='/"+this.sitecode+"/images/public/btn_rightarrow1.gif' border='0'  class='paging_next'>\n";
        }

		$('lowbPaging').innerHTML = buff ; 

	}

}

