var thumbnailView="";
var detailViewHtml="";
var curSort = "";
var modal = 0;

function init(){
	var sortHtml = "";
    var chkLen = document.getElementsByName("chkQuick").length;                
    for(var i = 0; i < chkLen ; i++){
        document.getElementsByName("chkQuick")[i].disabled = true;
    }
    if(compGbn == "compare"){
        funCompareResult();
    }else if(compGbn == "latest"){
		sortHtml = "<a href=\"javascript:funPhoneSort('popular')\" title=\"Popular\"><img src=\""+URL_ROOT+"images/products/txt_pdlist_7_off.gif\" alt=\"Popular\" /></a>\n";
		sortHtml += "<a href=\"javascript:funPhoneSort('latest')\" title=\"latest\"><img src=\""+URL_ROOT+"images/products/txt_pdlist_8_on.gif\" alt=\"Latest\" /></a>\n";
		
		document.getElementById("sort").innerHTML = sortHtml;
		curSort = "latest"; 
		funPhoneSort('latest');
    }else{
        sortHtml += "<a href=\"javascript:funPhoneSort('popular')\" title=\"Popular\"><img src=\""+URL_ROOT+"images/products/txt_pdlist_7_on.gif\" alt=\"Popular\" /></a>\n";
		sortHtml += "<a href=\"javascript:funPhoneSort('latest')\" title=\"latest\"><img src=\""+URL_ROOT+"images/products/txt_pdlist_8_off.gif\" alt=\"Latest\" /></a>\n";
		
		document.getElementById("sort").innerHTML = sortHtml;
		curSort = "latest"; 
        funPhoneSort('latest');
    }
	
	var select_model_list = document.getElementById("select_model_list");
	if (select_model_list)
	{
		document.body.onclick = function() { select_model_list.style.display = "none"; }
	}
	
	topInit();
}
 
function viewIconChange(iconGbn){    
    var inhtml = "";
    
    document.getElementById("viewGbn").value=iconGbn;
    
    if(iconGbn == "I"){
        inhtml += "<img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort3_on.gif\" class=\"ico\" alt=\"Image View\" title=\"Image View\" />";
        inhtml += "<a href=\"javascript:viewIconChange('T');\" title=\"Thumbnail View\"><img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort1_off.gif\" class=\"ico\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"Thumnail View\" title=\"Thumnail View\" /><\/a>";
        inhtml += "<a href=\"javascript:viewIconChange('D');\" title=\"Text View\"><img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort2_off.gif\" class=\"ico\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"Text View\" title=\"Text View\" /><\/a>";
                
        document.getElementById("imageView").style.display="";
        document.getElementById("thumbnailView").style.display="none";
        document.getElementById("detailView").style.display="none";
    }else if(iconGbn == "D" && quick_count == 0){
        inhtml += "<a href=\"javascript:viewIconChange('I');\" title=\"Image View\"><img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort3_off.gif\" class=\"ico\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"Image View\" title=\"Image View\" /><\/a>";
        inhtml += "<a href=\"javascript:viewIconChange('T');\" title=\"Thumbnail View\"><img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort1_off.gif\" class=\"ico\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"Thumnail View\" title=\"Thumnail View\" /><\/a>";
        inhtml += "<img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort2_on.gif\" alt=\"Text View\" title=\"Text View\" />";
        
        document.getElementById("imageView").style.display="none";
        document.getElementById("thumbnailView").style.display="none";
        document.getElementById("detailView").style.display="";
        
    }else if(iconGbn == "T"){            
        inhtml += "<a href=\"javascript:viewIconChange('I');\" title=\"Image View\"><img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort3_off.gif\" class=\"ico\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"Image View\" title=\"Image View\" /><\/a>";
        inhtml += "<img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort1_on.gif\" class=\"ico\" alt=\"Images View\" title=\"Thumbnail View\" />";
        inhtml += "<a href=\"javascript:viewIconChange('D');\" title=\"Text View\"><img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort2_off.gif\" class=\"ico\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"Text View\" title=\"Text View\" /><\/a>";
        
        if(thumbnailView == ""){
            var phoneModelLength = phoneData.length;          

			thumbnailView += "<div class=\"pd_list_sec\">\n";
			thumbnailView += "    <ul>\n";
            for(var i=0; i< phoneModelLength; i++){
				
                thumbnailView += "        <li>\n";
                thumbnailView += "            <div class=\"pd_img_sec\">\n";             
				
				var phoneUrl = phoneData[i].phoneName.toLowerCase();
                phoneUrl = phoneUrl.replace(/\s/g, "-").replace(/samsung-|samsung|sgh-|sch-|gt-/g, "");
				phoneUrl = "samsung-" + phoneUrl;
				
                if(phoneData[i].smallImage.substring(0,4) != 'http'){
					thumbnailView += "                <a title=\""+phoneData[i].phoneName+"\" href=\""+URL_ROOT+"mobile-phones/"+phoneUrl+"\"><img src=\""+URL_ROOT+phoneData[i].smallImage+"\" class=\"pd_img\" alt=\""+phoneData[i].phoneName+"\" title=\""+phoneData[i].phoneName+"\" /></a>\n";					
                }else{
					thumbnailView += "                <a title=\""+phoneData[i].phoneName+"\" href=\""+URL_ROOT+"mobile-phones/"+phoneUrl+"\"><img src=\""+phoneData[i].smallImage+"\" class=\"pd_img\" alt=\""+phoneData[i].phoneName+"\" title=\""+phoneData[i].phoneName+"\" /></a>\n";						
				}         
        		
				thumbnailView += "            </div>\n";
				
                if(phoneData[i].newgbn == "new"){
	                thumbnailView += "            <p class=\"pd_name\"><img src=\""+URL_ROOT+"images/common/btn/ico_new_pd.gif\" class=\"ico_mr8\" alt=\"New\" title=\"New\" /><a title=\""+phoneData[i].phoneName+"\" href=\""+URL_ROOT+"mobile-phones/"+phoneUrl+"\">"+phoneData[i].phoneName+"</a><\/p>\n";
                }else{                
                    thumbnailView += "            <p class=\"pd_name\"><a title=\""+phoneData[i].phoneName+"\" href=\""+URL_ROOT+"mobile-phones/"+phoneUrl+"\">"+phoneData[i].phoneName+"</a><\/p>\n";
                }
				
				thumbnailView += "            <p class=\"control\">\n";
				thumbnailView += "                <span id=\""+phoneData[i].phoneModel+"_t\"><a title=\"COMPARE\" href=\"javascript:setCookie('"+phoneData[i].phoneModel+"','"+phoneData[i].mini_name+"','"+phoneData[i].smallImage+"');\" class=\"compare\"><img src=\""+URL_ROOT+"images/common/btn/bt_compare_type2_off.gif\" id=\""+phoneData[i].phoneModel+"_timg\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"compare\" title=\"compare\" /></a><\/span>";
				thumbnailView += "                <a title=\"IN BRIEF\" onclick=\"javascript:quickview_view(event,'quickview',"+(i+1)+",'"+phoneData[i].phoneModel+"');\" href=\"#quick_view\" class=\"inbrief\"><img src=\""+URL_ROOT+"images/common/btn/bt_inbrief_type2_off.gif\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"in brief\" title=\"in brief\" /></a>\n";
				thumbnailView += "            </p>\n";
				thumbnailView += "        </li>\n";

			} //end for
			
			thumbnailView += "    </ul>\n";
			thumbnailView += "</div>\n";

            if( phoneModelLength == 0 ){
				thumbnailView = "<div class=\"popular_pd\"><div class=\"acc_message\"><img src=\""+URL_ROOT+"images/products/p_acc_1.gif\" border=\"0\" alt=\"Sorry,no product found\" /></div></div>\n";
			}

            document.getElementById("thumbnailView").innerHTML = thumbnailView;
        } //end if
                
        document.getElementById("imageView").style.display="none";
        document.getElementById("thumbnailView").style.display="";
        document.getElementById("detailView").style.display="none";
    }else if(iconGbn == "D"){
        
        inhtml += "<a href=\"javascript:viewIconChange('I');\" title=\"Thumbnail View\"><img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort1_off.gif\" class=\"ico\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"Thumbnail View\" title=\"Thumnail View\" /><\/a>";
        inhtml += "<a href=\"javascript:viewIconChange('T');\" title=\"Images View\"><img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort2_off.gif\" class=\"ico\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"Images View\" title=\"Images View\" /><\/a>";
        inhtml += "<img src=\""+URL_ROOT+"images/common/btn/ico_pdlist_sort3_on.gif\" class=\"ico\" alt=\"Text View\" title=\"Text View\" />";

        if( detailViewHtml == "" ){        
        
            var phoneModelLength = phoneData.length;
			
            detailViewHtml += "<ul class=\"pd_txtlist\">\n";
			
            for(var i=0; i< phoneModelLength; i++){
				
				if( i == 0 ){
					detailViewHtml += "    <li class=\"first\">\n";
				}else{
					detailViewHtml += "    <li>\n";
				}
				
				var phoneUrl = phoneData[i].phoneName.toLowerCase();
                phoneUrl = phoneUrl.replace(/\s/g, "-").replace(/samsung-|samsung|sgh-|sch-|gt-/g, "");
				phoneUrl = "samsung-" + phoneUrl;
				
                detailViewHtml += "        <div class=\"thumb_img\">\n";
				detailViewHtml += "            <div class=\"pd_img_sec\">\n";
				
				if(phoneData[i].smallImage.substring(0,4) != 'http'){
                    detailViewHtml += "                <a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneData[i].phoneName+"\"><img src=\""+URL_ROOT+phoneData[i].smallImage+"\" width=\"120\" height=\"120\" class=\"pd_img\" title=\""+phoneData[i].phoneName+"\" alt=\""+phoneData[i].phoneName+"\" /></a>\n";                        
                }
                if(phoneData[i].smallImage.substring(0,4) == 'http'){
                    detailViewHtml += "                <a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneData[i].phoneName+"\"><img src=\""+phoneData[i].smallImage+"\" width=\"120\" height=\"120\" class=\"pd_img\" title=\""+phoneData[i].phoneName+"\" alt=\""+phoneData[i].phoneName+"\" /></a>\n";                        
                }
				
				detailViewHtml += "            </div>\n";
				
				if(phoneData[i].newgbn == "new"){
					detailViewHtml += "        <p class=\"pd_name\"><img src=\""+URL_ROOT+"images/common/btn/ico_new_pd.gif\" class=\"ico_mr8\" alt=\"New\" title=\"New\" /><a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneData[i].phoneName+"\">"+phoneData[i].phoneName+"</a></p>\n";
				}else{
					detailViewHtml += "        <p class=\"pd_name\"><a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneData[i].phoneName+"\">"+phoneData[i].phoneName+"</a></p>\n";
				}
					
				detailViewHtml += "        <p class=\"control\">\n";
				detailViewHtml += "            <span id=\""+phoneData[i].phoneModel+"_d\"><a title=\"COMPARE\" href=\"javascript:setCookie('"+phoneData[i].phoneModel+"','"+phoneData[i].mini_name+"','"+phoneData[i].smallImage+"');\" class=\"compare\"><img src=\""+URL_ROOT+"images/common/btn/bt_compare_type2_off.gif\" id=\""+phoneData[i].phoneModel+"_dimg\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"compare\" title=\"compare\" /></a><\/span>";
				detailViewHtml += "            <a title=\"IN BRIEF\" onclick=\"javascript:quickview_view(event,'quickview',"+(i+1)+",'"+phoneData[i].phoneModel+"');\" href=\"#quick_view\" class=\"inbrief\"><img src=\""+URL_ROOT+"images/common/btn/bt_inbrief_type2_off.gif\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"in brief\" title=\"in brief\" /></a>\n";
				detailViewHtml += "        </p>\n";
				detailViewHtml += "        </div>\n";
				detailViewHtml += "        <dl class=\"spec\">\n";
				detailViewHtml += "            <dt>Specification</dt>\n";
				
				for(var k=1; k<11; k++){
					if(eval("phoneData["+i+"].quickSpecImage"+k) != " "){
						if((eval("phoneData["+i+"].quickSpecImage"+k)).substring(0,4) == 'http') {
							detailViewHtml += "            <dd><img src=\""+eval("phoneData["+i+"].quickSpecImage"+k)+"\" alt=\""+eval("phoneData["+i+"].quickSpecDesc"+k)+"\" title=\""+eval("phoneData["+i+"].quickSpecDesc"+k)+"\" /></dd>\n";
						}else{
							detailViewHtml += "            <dd><img src=\""+URL_ROOT+""+PUB_LOCAL+""+QUICKSPEC_SAVE_PATH+""+eval("phoneData["+i+"].quickSpecImage"+k)+"\" alt=\""+eval("phoneData["+i+"].quickSpecDesc"+k)+"\" title=\""+eval("phoneData["+i+"].quickSpecDesc"+k)+"\" /></dd>\n";
						}
					}
				}
				
				detailViewHtml += "        </dl>\n";
				detailViewHtml += "        <dl class=\"features\">\n";
				detailViewHtml += "            <dt>Key Features</dt>\n";
				
				if(phoneData[i].features1 != " "){
                    detailViewHtml += "            <dd>"+phoneData[i].features1+"<\/dd>\n";
                }
				if(phoneData[i].features2 != " "){
                    detailViewHtml += "            <dd>"+phoneData[i].features2+"<\/dd>\n";
                }
                if(phoneData[i].features3 != " "){
                    detailViewHtml += "            <dd>"+phoneData[i].features3+"<\/dd>\n";
                } 
                if(phoneData[i].features4 != " "){
                    detailViewHtml += "            <dd>"+phoneData[i].features4+"<\/dd>\n";
                }
                if(phoneData[i].features5 != " "){
                    detailViewHtml += "            <dd>"+phoneData[i].features5+"<\/dd>\n";
                } 
                if(phoneData[i].features6 != " "){
                    detailViewHtml += "            <dd>"+phoneData[i].features6+"<\/dd>\n";
                }
				
				detailViewHtml += "        </dl>\n";
				detailViewHtml += "    </li>\n";
				
            } //end for
            
			detailViewHtml += "</ul>\n";
			
			if( phoneModelLength == 0 ){
				detailViewHtml = "<div class=\"popular_pd\"><div class=\"acc_message\"><img src=\""+URL_ROOT+"images/products/p_acc_1.gif\" border=\"0\" alt=\"Sorry,no product found\" /></div></div>\n";
			}

			document.getElementById("detailView").innerHTML = detailViewHtml;
			
		} //end if
        
        document.getElementById("imageView").style.display="none";
        document.getElementById("thumbnailView").style.display="none";
        document.getElementById("detailView").style.display="";
    }        	
    document.getElementById("viewIcon").innerHTML = inhtml;    
    compareSetting();    
}

// SFC4.0 리뉴얼 후 삭제
function spec_balloon(n, objNm) {
    for(var i = 1; i <= 10; i++) {        
        obj_d = document.getElementById(objNm+'_'+i);
        
        if ( n == i ) {
                obj_d.style.display = "block";
        } 
    }
}

var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ns4||ns6) document.captureEvents(Event.MOUSEMOVE);

function quickview_view(e,id,objCount,phoneModel) {

    var varLeft;
    var varTop;
        
    if(ns4||ns6){        
        varLeft = (e.clientX+window.pageXOffset);
        varTop = (e.clientY+window.pageYOffset+15);        
    }else{
        varLeft = (event.clientX+document.documentElement.scrollLeft);
        varTop = (event.clientY+document.documentElement.scrollTop+15);
    }
	
	if( document.getElementById("viewGbn").value == "T" ){
		if( objCount%6 == 1 ){
			varLeft = 40;
		}else if(objCount%6 == 2){
			varLeft = 172;
		}else if(objCount%6 == 3){
			varLeft = 305;
		}else if(objCount%6 == 4){
			varLeft = 9;
		}else if(objCount%6 == 5){
			varLeft = 142;
		}else if(objCount%6 == 0){
			varLeft = 273;
		}
	}else if( document.getElementById("viewGbn").value == "D" ){
		varLeft = 67;
	}else if( document.getElementById("viewGbn").value == "I" ){
		if( objCount%4 == 1 ){
			varLeft = 33;
		}else if(objCount%4 == 2){
			varLeft = 230;
		}else if(objCount%4 == 3){
			varLeft = 82;
		}else if(objCount%4 == 0){
			varLeft = 282;
		}
	}
    
    if(ns4||ns6){    
        document.getElementById(id).style.left=varLeft+"px";
        document.getElementById(id).style.top=varTop+"px";
    }else{
        document.getElementById(id).style.left=varLeft;
        document.getElementById(id).style.top=varTop;
    }
    
    if(phoneData != null){        
        var arrNum = objCount - 1;    
		var inFeature = "";
		
		var phoneUrl = phoneData[arrNum].phoneName.toLowerCase();
        phoneUrl = phoneUrl.replace(/\s/g, "-").replace(/samsung-|samsung|sgh-|sch-|gt-/g, "");
		phoneUrl = "samsung-" + phoneUrl;
		
		inFeature += "<dt>"+phoneData[arrNum].phoneName+"<br />\n";
		inFeature += "<em>"+phoneData[arrNum].slogon+"</em>\n";
		inFeature += "</dt>\n";							
		
		if( phoneData[arrNum].quickViewImage.indexOf('http') > -1 ){
        	document.getElementById("phoneQuickImage").innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneData[arrNum].phoneName+"\"><img src=\""+phoneData[arrNum].quickViewImage+"\" id=\"quick_phone_image\" width=\"180\" height=\"180\" alt=\""+phoneData[arrNum].phoneName+"\"><\/a>\n";
		}else{
			document.getElementById("phoneQuickImage").innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneData[arrNum].phoneName+"\"><img src=\""+URL_ROOT+phoneData[arrNum].quickViewImage+"\" id=\"quick_phone_image\" width=\"180\" height=\"180\" alt=\""+phoneData[arrNum].phoneName+"\"><\/a>\n";
		}                
        
		document.getElementById("detail_bt").style.display="block";
        document.getElementById("detail_bt").innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneData[arrNum].phoneName+"\"><img src=\""+URL_ROOT+"images/common/btn/bt_detailview_off.gif\" id=\"detail_bt_image\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\""+phoneData[arrNum].phoneName+"\">\n";

        if(phoneData[arrNum].features1 != " "){
            inFeature += "<dd>"+FFStrCutByteString(phoneData[arrNum].features1,30)+"</dd>\n";
        }
        if(phoneData[arrNum].features2 != " "){
            inFeature += "<dd>"+FFStrCutByteString(phoneData[arrNum].features2,30)+"</dd>\n";
        }
        if(phoneData[arrNum].features3!= " "){
            inFeature += "<dd>"+FFStrCutByteString(phoneData[arrNum].features3,30)+"</dd>\n";
        }
        if(phoneData[arrNum].features4 != " "){
            inFeature += "<dd>"+FFStrCutByteString(phoneData[arrNum].features4,30)+"</dd>\n";
        }
        if(phoneData[arrNum].features5 != " "){
            inFeature += "<dd>"+FFStrCutByteString(phoneData[arrNum].features5,30)+"</dd>\n";
        }
        if(phoneData[arrNum].features6 != " "){
            inFeature += "<dd>"+FFStrCutByteString(phoneData[arrNum].features6,30)+"</dd>\n";
        }
		
		document.getElementById("quickDetail").innerHTML = inFeature;        
        
		var detailViewHtml = "";
		
        for(j = 1 ; j < 11 ; j++){
            if(eval("phoneData["+arrNum+"].quickSpecImage"+j) != " "){
                detailViewHtml += "                <li>\n";
                if((eval("phoneData["+arrNum+"].quickSpecImage"+j)).substring(0,4) == 'http') {
                    detailViewHtml += "                <img src=\""+eval("phoneData["+arrNum+"].quickSpecImage"+j)+"\" id=\"quick_view_spec_image"+j+"\" alt=\""+eval("phoneData["+arrNum+"].quickSpecDesc"+j)+"\" width=\"25\" height=\"25\" title=\""+eval("phoneData["+arrNum+"].quickSpecDesc"+j)+"\" />\n";
                } else { 
                    detailViewHtml += "                <img src=\""+URL_ROOT+""+PUB_LOCAL+""+QUICKSPEC_SAVE_PATH+""+eval("phoneData["+arrNum+"].quickSpecImage"+j)+"\" id=\"quick_view_spec_image"+j+"\" width=\"25\" height=\"25\" alt=\""+eval("phoneData["+arrNum+"].quickSpecDesc"+j)+"\" title=\""+eval("phoneData["+arrNum+"].quickSpecDesc"+j)+"\" />\n";
                }    
                detailViewHtml += "                <\/li>\n";
            }
        }
        document.getElementById("qSpecList").innerHTML = detailViewHtml;
    }else{        
        alert("Loading....");
        return;
    }
    document.getElementById(id).style.visibility='visible';
	document.getElementById(id).style.display="";
}

var crossobj;

function drag_drop(e){    
    if (ie4&&dragapproved){
        crossobj.style.left=tempx+event.clientX-offsetx
        crossobj.style.top=tempy+event.clientY-offsety
        return false
    } else if (ns6&&dragapproved) {
        crossobj.style.left=tempx+e.clientX-offsetx+"px"
        crossobj.style.top=tempy+e.clientY-offsety+"px"
        return false
    }
}

function initializedrag(e, id){
    crossobj=ns6? document.getElementById(id) : document.all[id]    
    var firedobj=ns6? e.target : event.srcElement
    var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
    while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!=id){
        firedobj=ns6? firedobj.parentNode : firedobj.parentElement
    }

    if (firedobj.id==id){
        offsetx=ie4? event.clientX : e.clientX
        offsety=ie4? event.clientY : e.clientY
        
        tempx=parseInt(crossobj.style.left)
        tempy=parseInt(crossobj.style.top)
        
        dragapproved=true
        document.onmousemove=drag_drop
    }
}

document.onmouseup=new Function("dragapproved=false")

function hidebox(id){
    crossobj=ns6? document.getElementById(id) : document.all[id]
    if (ie4||ns6)
        crossobj.style.visibility="hidden"
    else if (ns4)
        document.quickview.visibility="hide"
}

function setCookie(phoneModel, phoneName, img){    
    var name="phoneCompare";
    var todayDate = new Date();
    var expiredays = 1;
    todayDate.setDate( todayDate.getDate() + expiredays );
      
    var cookieVal = getCookie(name);      
    var value = phoneModel+"|"+phoneName+"|"+img;
    if(cookieVal != null){
        if( cookieVal.indexOf(value) < 0 ){
            if(cookieVal == ""){
                value = value;    
            }else{
                value = cookieVal+"^"+value;
            }                    
        }else{
            alert(P01);
            return;
        }
        
        if(cookieVal.split("^").length > 2){
            alert(P02);
            return;
        }
    }
    
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"

  	addCompare(phoneModel, phoneName, img);
  	laypopCompareView();    
}

function getCookie(name) {
    var arg = name + "="; 
    var alen = arg.length;
    var clen = document.cookie.length;        
    var i = 0;

    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0)
            break;
    }
    return null;
}

function getCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;

    return unescape(document.cookie.substring(offset, endstr));
}

function delCookie(phoneModel, phoneName, img){
    var name = "phoneCompare";
    var value = "";
    
    var todayDate = new Date();
    var expiredays = 1;
      todayDate.setDate( todayDate.getDate() + expiredays );
      
    var cookieVal = getCookie(name);
    
    if(cookieVal != null){    
        var rowCookie = cookieVal.split("^");
    
        var j = 0;
        for(var i = 0 ; i < rowCookie.length; i++){
            if(rowCookie[i].indexOf(phoneModel) == -1){
                j++;
                
                if(j == 1){
                    value += rowCookie[i];
                }else{
                    value += "^"+rowCookie[i];
                }
            }
        }
        
        document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
    }
    
    removeCompare(phoneModel, phoneName, img);
    
	if(document.getElementById("phoneComparePage").style.display == ""){
        funCompareResult();
    }
	
	laypopCompareView();
}

function delPhoneModelCookie(phoneModel){
    var name = "phoneCompare";
    var value = "";
    
    var todayDate = new Date();
    var expiredays = 1;
    todayDate.setDate( todayDate.getDate() + expiredays );
      
    var textCookieVal = phoneModel.split("|");
    var cookieVal = getCookie(name);
    
    if(cookieVal != null){    
        var rowCookie = cookieVal.split("^");
    
        var j = 0;
        for(var k = 0; k < textCookieVal.length; k++){
            for(var i = 0 ; i < rowCookie.length; i++){    
                var colCookie = rowCookie[i].split("|");        
                if(textCookieVal[k] == colCookie[0]){
                    j++;
                    
                    if(j == 1){
                        value += rowCookie[i];
                    }else{
                        value += "^"+rowCookie[i];
                    }                    
                }
            }
        }
        
        document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
    }
}

function addCompare(phoneModel, phoneName, img){
	
	var strImg = "";
    if(document.getElementById(phoneModel+"_t") != null){
		strImg = document.getElementById(phoneModel+"_timg").src;
		strImg = strImg.replace("bt_compare_type2_on.gif","bt_compare_type2_focus.gif");
		strImg = strImg.replace("bt_compare_type2_off.gif","bt_compare_type2_focus.gif");
		document.getElementById(phoneModel+"_t").innerHTML = "<a title=\"COMPARE\" href=\"javascript:delCookie('"+phoneModel+"','"+phoneName+"','"+img+"');\" class=\"compare\"><img src=\""+strImg+"\" id=\""+phoneModel+"_timg\" alt=\"compare\" title=\"compare\" /></a>";
    }
    
    if(document.getElementById(phoneModel+"_i") != null){
        strImg = document.getElementById(phoneModel+"_iimg").src;
		strImg = strImg.replace("bt_compare_type4_on.gif","bt_compare_type4_focus.gif");
		strImg = strImg.replace("bt_compare_type4_off.gif","bt_compare_type4_focus.gif");
		document.getElementById(phoneModel+"_i").innerHTML = "<a title=\"COMPARE\" href=\"javascript:delCookie('"+phoneModel+"','"+phoneName+"','"+img+"');\" class=\"compare\"><img src=\""+strImg+"\" id=\""+phoneModel+"_iimg\" alt=\"compare\" title=\"compare\" /></a>";
    }
    
    if(document.getElementById(phoneModel+"_d") != null){
		strImg = document.getElementById(phoneModel+"_dimg").src;
		strImg = strImg.replace("bt_compare_type2_on.gif","bt_compare_type2_focus.gif");
		strImg = strImg.replace("bt_compare_type2_off.gif","bt_compare_type2_focus.gif");
        document.getElementById(phoneModel+"_d").innerHTML = "<a title=\"COMPARE\" href=\"javascript:delCookie('"+phoneModel+"','"+phoneName+"','"+img+"');\" class=\"compare\"><img src=\""+strImg+"\" id=\""+phoneModel+"_dimg\" alt=\"compare\" title=\"compare\" /></a>";
    }
    
    if(document.getElementById(phoneModel+"_compare") != null){
		strImg = document.getElementById(phoneModel+"_timg").src;
		strImg = strImg.replace("bt_compare_type2_on.gif","bt_compare_type2_focus.gif");
		strImg = strImg.replace("bt_compare_type2_off.gif","bt_compare_type2_focus.gif");
        document.getElementById(phoneModel+"_t").innerHTML = "<a title=\"COMPARE\" href=\"javascript:delCookie('"+phoneModel+"','"+phoneName+"','"+img+"');\" class=\"compare\"><img src=\""+strImg+"\" id=\""+phoneModel+"_timg\" alt=\"compare\" title=\"compare\" /></a>";
    }
}

function removeCompare(phoneModel, phoneName, img){
	var strImg = "";
	
    if(document.getElementById(phoneModel+"_t") != null){
		strImg = document.getElementById(phoneModel+"_timg").src;
		strImg = strImg.replace("bt_compare_type2_focus.gif","bt_compare_type2_off.gif");
		strImg = strImg.replace("bt_compare_type2_focus.gif","bt_compare_type2_off.gif");
		document.getElementById(phoneModel+"_t").innerHTML = "<a title=\"COMPARE\" href=\"javascript:setCookie('"+phoneModel+"','"+phoneName+"','"+img+"');\" class=\"compare\"><img src=\""+strImg+"\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" id=\""+phoneModel+"_timg\" alt=\"compare\" title=\"compare\" /></a>";
    }
    
    if(document.getElementById(phoneModel+"_i") != null){
		strImg = document.getElementById(phoneModel+"_iimg").src;
		strImg = strImg.replace("bt_compare_type4_focus.gif","bt_compare_type4_off.gif");
		strImg = strImg.replace("bt_compare_type4_focus.gif","bt_compare_type4_off.gif");
        document.getElementById(phoneModel+"_i").innerHTML = "<a title=\"COMPARE\" href=\"javascript:setCookie('"+phoneModel+"','"+phoneName+"','"+img+"');\" class=\"compare\"><img src=\""+strImg+"\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" id=\""+phoneModel+"_iimg\" alt=\"compare\" title=\"compare\" /></a>";
    }
    
    if(document.getElementById(phoneModel+"_d") != null){
		strImg = document.getElementById(phoneModel+"_dimg").src;
		strImg = strImg.replace("bt_compare_type2_focus.gif","bt_compare_type2_off.gif");
		strImg = strImg.replace("bt_compare_type2_focus.gif","bt_compare_type2_off.gif");
        document.getElementById(phoneModel+"_d").innerHTML = "<a title=\"COMPARE\" href=\"javascript:setCookie('"+phoneModel+"','"+phoneName+"','"+img+"');\" class=\"compare\"><img src=\""+strImg+"\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" id=\""+phoneModel+"_dimg\" alt=\"compare\" title=\"compare\" /></a>";
    }
    
    if(document.getElementById(phoneModel+"_compare") != null){
		strImg = document.getElementById(phoneModel+"_timg").src;
		strImg = strImg.replace("bt_compare_type2_focus.gif","bt_compare_type2_off.gif");
		strImg = strImg.replace("bt_compare_type2_focus.gif","bt_compare_type2_off.gif");
        document.getElementById(phoneModel+"_t").innerHTML = "<a title=\"COMPARE\" href=\"javascript:setCookie('"+phoneModel+"','"+phoneName+"','"+img+"');\" class=\"compare\"><img src=\""+strImg+"\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" id=\""+phoneModel+"_timg\" alt=\"compare\" title=\"compare\" /></a>";
    }
}

//2009.11.20 SFC4.0 리뉴얼 후 사용안함
function compareTxtSetting(value){
    var txtArr = value.split("^");    
    var modelArr;
    for(var i=0; i < 3; i++){
        if( txtArr == ""){
            document.getElementById("compare"+(i+1)).value="---";
        }else{                
            if( txtArr[i] != null ){                                        
                modelArr = txtArr[i].split("|");
                document.getElementById("compare"+(i+1)).value = replace(modelArr[1],"Samsung ","");
            }else{
                document.getElementById("compare"+(i+1)).value = "---";
            }
        }
    }
}

function laypopCompareView(){
		
    var comparePhoneInfoHtml = "";
    var rowCookie = "";
    
    if(getCookie("phoneCompare") != null && getCookie("phoneCompare") != ""){                        
        rowCookie = getCookie("phoneCompare").split("^");            
        var colCookie;
								
        for(var i=0; i < rowCookie.length; i++){
            colCookie = rowCookie[i].split("|");
			if( i == 0 ){
            	comparePhoneInfoHtml += "<li class=\"first\">\n";
			}else{
				comparePhoneInfoHtml += "<li>\n";
			}
			
			if( colCookie[2].indexOf('http') > -1 ){
				comparePhoneInfoHtml += "    <img src=\""+colCookie[2]+"\" width=\"120\" height=\"120\" class=\"pd_img\" title=\""+colCookie[1]+"\" alt=\""+colCookie[1]+"\" /></a>\n";	
			}else{
				comparePhoneInfoHtml += "    <img src=\""+URL_ROOT+colCookie[2]+"\" width=\"120\" height=\"120\" class=\"pd_img\" title=\""+colCookie[1]+"\" alt=\""+colCookie[1]+"\" /></a>\n";
			}
			
			comparePhoneInfoHtml += "    <p class=\"pd_name\">"+colCookie[1]+"</p>\n";
			comparePhoneInfoHtml += "    <a title=\"Delete\" href=\"javascript:delCookie('"+colCookie[0]+"','"+colCookie[1]+"','"+colCookie[2]+"');\"><img src=\""+URL_ROOT+"images/common/btn/bt_close_layer2.gif\" alt=\"Delete\" title=\"Delete\" /></a>\n";
			
            comparePhoneInfoHtml += "</li>\n";
        }
        
        for(var j=0; j < (3 - rowCookie.length); j++){
            comparePhoneInfoHtml += "<li>\n";
			comparePhoneInfoHtml += "<img src=\""+URL_ROOT+"images/common/noimg/noimg_120.gif\" class=\"pd_img\" alt=\"Phone Name\" title=\"Phone Name\" />\n";
            comparePhoneInfoHtml += "</li>\n";
        }
    }else{
        for(var k=0; k < 3; k++){
            if( k == 0 ){
            	comparePhoneInfoHtml += "<li class=\"first\">\n";
			}else{
				comparePhoneInfoHtml += "<li>\n";
			}
			comparePhoneInfoHtml += "<img src=\""+URL_ROOT+"images/common/noimg/noimg_120.gif\" class=\"pd_img\" alt=\"Phone Name\" title=\"Phone Name\" />\n";
            comparePhoneInfoHtml += "</li>\n";
        }
    }
        
    document.getElementById("comparePhoneInfo").innerHTML = comparePhoneInfoHtml;

    if(rowCookie.length == 0){
        document.getElementById("compId").innerHTML = "<img src=\""+URL_ROOT+"images/common/btn/bt_compare_type3.gif\" alt=\"Compare Now\" /><img src=\""+URL_ROOT+"images/common/btn/bt_clearall_type3.gif\" alt=\"Clear All\" />\n";
    }else{
        document.getElementById("compId").innerHTML = "<a href=\"#Compare\" OnClick=\"javascript:funCompareResult();\" title=\"Compare Now\"><img src=\""+URL_ROOT+"images/common/btn/bt_compare_type3.gif\" alt=\"Compare Now\" /></a><a href=\"#ClearAll\" OnClick=\"javascript:delAllCompare2();\" title=\"Clear All\"><img src=\""+URL_ROOT+"images/common/btn/bt_clearall_type3.gif\" alt=\"Clear All\" /></a>\n";        
    }
    
    document.getElementById("laypop_compare").style.display='block';
    funDisplayNone();
}

var setTime;
function funDisplayNone(){
    if (document.getElementById("laypop_compare").style.display == "block"){ 
        setTime = setTimeout("selectHide2('laypop_compare')", 20000);
    }else{
        setTime = setTimeout("funDisplayNone()",50);        
    }
}

function laypopCompareView2(cookieValue){
    var comparePhoneInfoHtml = "";
    var rowCookie = "";
    
    if(cookieValue != null && cookieValue != ""){                        
        rowCookie = cookieValue.split("^");            
        var colCookie;
        
        for(var i=0; i < rowCookie.length; i++){
            colCookie = rowCookie[i].split("|");
			if( i == 0 ){
            	comparePhoneInfoHtml += "<li class=\"first\">\n";
			}else{
				comparePhoneInfoHtml += "<li>\n";
			}
			
			comparePhoneInfoHtml += "    <img src=\""+URL_ROOT+colCookie[2]+"\" width=\"120\" height=\"120\" class=\"pd_img\" title=\""+colCookie[1]+"\" alt=\""+colCookie[1]+"\" /></a>\n";
			comparePhoneInfoHtml += "    <p class=\"pd_name\">"+colCookie[1]+"</p>\n";
			comparePhoneInfoHtml += "    <a title=\"Delete\" href=\"javascript:delCookie('"+colCookie[0]+"','"+colCookie[1]+"','"+colCookie[2]+"');\"><img src=\""+URL_ROOT+"images/common/btn/bt_close_layer2.gif\" alt=\"Delete\" title=\"Delete\" /></a>\n";
			
            comparePhoneInfoHtml += "</li>\n";
        }
        
        for(var j=0; j < (3 - rowCookie.length); j++){
            comparePhoneInfoHtml += "<li>\n";
			comparePhoneInfoHtml += "<img src=\""+URL_ROOT+"images/common/noimg/noimg_120.gif\" class=\"pd_img\" alt=\"Phone Name\" title=\"Phone Name\" />\n";
            comparePhoneInfoHtml += "</li>\n";
        }
    }else{
        for(var k=0; k < 3; k++){
            if( k == 0 ){
            	comparePhoneInfoHtml += "<li class=\"first\">\n";
			}else{
				comparePhoneInfoHtml += "<li>\n";
			}
			
            comparePhoneInfoHtml += "</li>\n";
        }
    }
        
    document.getElementById("comparePhoneInfo").innerHTML = comparePhoneInfoHtml;
    
	if(rowCookie.length == 0){
        document.getElementById("compId").innerHTML = "<img src=\""+URL_ROOT+"images/common/btn/bt_compare_type3.gif\" alt=\"Compare Now\" /><img src=\""+URL_ROOT+"images/common/btn/bt_clearall_type3.gif\" alt=\"Clear All\" />\n";
    }else{
        document.getElementById("compId").innerHTML = "<a href=\"#Compare\" OnClick=\"javascript:funCompareResult();\" title=\"Compare Now\"><img src=\""+URL_ROOT+"images/common/btn/bt_compare_type3.gif\" alt=\"Compare Now\" /></a><a href=\"#ClearAll\" OnClick=\"javascript:delAllCompare2();\" title=\"Clear All\"><img src=\""+URL_ROOT+"images/common/btn/bt_clearall_type3.gif\" alt=\"Clear All\" /></a>\n";        
    }
    
    if(document.getElementById("laypop_compare").style.display == "block"){
        document.getElementById("laypop_compare").style.display='block';
    }else if(document.getElementById("laypop_compare").style.display == "none"){
        document.getElementById("laypop_compare").style.display="none";
    }
}

function delCompare(){
    var delCompareVar;    
    var name="phoneCompare";
    var value = "";
    var phoneVal;
    var cookieVal = getCookie(name);
    var rowCookie = "";
    var chkCount = 0;
    if(cookieVal !=null && cookieVal != ""){
        rowCookie = cookieVal.split("^");
    }
    
    var todayDate = new Date();
    var expiredays = 1;
    todayDate.setDate( todayDate.getDate() + expiredays );
      
    for(var i = 0 ; i < document.getElementsByName("comparePhoneModelChk").length; i++){        
        if(document.getElementsByName("comparePhoneModelChk")[i].checked){
            phoneVal = document.getElementsByName("comparePhoneModelChk")[i].value.split("|");
            
            if(cookieVal !=null && cookieVal != ""){
                for(var j = 0 ; j < rowCookie.length; j++){                    
                    if( rowCookie[j].indexOf(phoneVal[0]) == 0 ){
                        rowCookie[j] = "";
                        removeCompare(phoneVal[0], phoneVal[1], phoneVal[2]);
                        
                        chkCount++;
                    }
                }        
            }
        }
    }
    
    if(chkCount == 0){
        return;
    }
    
    var l = 0;
    for(var k = 0; k < rowCookie.length ; k++){        
        if(rowCookie[k] != ""){
            l++;
            if(l == 1){
                value += rowCookie[k];
            }else{
                value += "^"+rowCookie[k];
            }
        }
    }
    
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";    
    laypopCompareView2(value);
    
    if(document.getElementById("phoneComparePage").style.display == ""){
        funCompareResult();
    }
}

function delAllCompare(){
    var delCompareVar;    
    var name="phoneCompare";
    var value = "";
    
    var todayDate = new Date();
    var expiredays = 1;
    todayDate.setDate( todayDate.getDate() + expiredays );
    
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";    
    laypopCompareView2(value);
}

function delAllCompare2(){
    var delCompareVar;    
    var name="phoneCompare";
    var value = "";
    var phoneVal;
    var cookieVal = getCookie(name);
	
    var rowCookie = "";
    var chkCount = 0;
    if(cookieVal !=null && cookieVal != ""){
        rowCookie = cookieVal.split("^");
    }
    
    var todayDate = new Date();
    var expiredays = 1;
    todayDate.setDate( todayDate.getDate() + expiredays );
      
    for(var i = 0 ; i < rowCookie.length; i++){        
		phoneVal = rowCookie[i].split("|");
        for(var j = 0 ; j < phoneVal.length; j++){                    
	        removeCompare(phoneVal[0], phoneVal[1], phoneVal[2]);
        }        
    }
    
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";    
    
	if(document.getElementById("phoneComparePage").style.display == ""){
        funCompareResult();
    }
	
	laypopCompareView();
}

function funClear(){
    var chkLen = document.getElementsByName("chkQuick").length;                
    for(var i = 0; i < chkLen ; i++){
        document.getElementsByName("chkQuick")[i].disabled = true;
        document.getElementsByName("chkQuick")[i].checked = false;
    }
	
	var chkLen2 = document.getElementsByName("chkAdvance").length;                
    for(var i = 0; i < chkLen2 ; i++){
        document.getElementsByName("chkAdvance")[i].disabled = true;
        document.getElementsByName("chkAdvance")[i].checked = false;
    }
    
    funQuickSearch();    
}

function compareSetting(){
    if(getCookie("phoneCompare") != null && getCookie("phoneCompare") != ""){            
        var rowCookie = getCookie("phoneCompare").split("^");                        
        var colCookie;
        for(var i=0; i < rowCookie.length; i++){
            colCookie = rowCookie[i].split("|");
            addCompare(colCookie[0],colCookie[1],colCookie[2]);
        }
    }
}

function funPhoneSort(arg){
	
	var inHtml = "";
	if(document.getElementById("sort") != null){
		if(arg == "popular"){
			inHtml += "<img src=\""+URL_ROOT+"images/products/txt_pdlist_7_on.gif\" alt=\"Popular\" /></a>";
			inHtml += "<a href=\"javascript:funPhoneSort('latest')\" title=\"latest\"><img src=\""+URL_ROOT+"images/products/txt_pdlist_8_off.gif\" alt=\"Latest\" />";
			curSort = "popular";
		}else{
			inHtml += "<a href=\"javascript:funPhoneSort('popular')\" title=\"popular\"><img src=\""+URL_ROOT+"images/products/txt_pdlist_7_off.gif\" alt=\"Popular\" /></a>";
			inHtml += "<img src=\""+URL_ROOT+"images/products/txt_pdlist_8_on.gif\" alt=\"Latest\" />";
			curSort = "latest";
		}
		document.getElementById("sort").innerHTML = inHtml;
	}
	
    if(arg != ""){
        funQuickSearch();
    }
}

function funPhoneCommonSearch(){    
    funQuickSearch();
}

var phoneComboHtml="";

function funCompareResult(){
    
	selectHide2('laypop_compare');
	document.getElementById("sort_terms").className = "pd_sort comparison";
	document.getElementById("sort_terms2").style.display = "none";
	document.getElementById("found_pdnum").style.display = "none";
	funPhoneComboHtml();    
	
	document.getElementById("phoneSearchPage").style.display = "none";
    document.getElementById("phoneComparePage").style.display = "";
    document.getElementById("compPhone").style.display = "";
	document.getElementById("quickview").style.display = "none";
	
}

function funPhoneComboHtml(){
	
	if(window.ActiveXObject){ // IE5.0, IE6.0
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}else if(window.XMLHttpRequest){ //IE7.0, FireFox, Safari, Opera
		xhr = new XMLHttpRequest();
	}
	
	xhr.onreadystatechange = resultProcess;
 	xhr.open("GET", "/ajax/ajaxcombolist.do", "false"); // 요청설정
 	xhr.send(null);
}

function resultProcess(){
	if(xhr.readyState==4){
		if(xhr.status==200){
			phoneComboHtml = xhr.responseText;
		    funCompareResultStart();		    
		}
	}
}	

function funCompareResultStart(){
	var spCompHead1 = "<select id=\"comparePhone1\" name=\"comparePhone1\" class=\"select\" style=\"width:150px;\" OnChange=\"javascript:funCompareOnChange(this)\">\n<option value=\"\">Compare more<\/option>\n";
    var spCompHead2 = "<select id=\"comparePhone2\" name=\"comparePhone2\" class=\"select\" style=\"width:150px;\" OnChange=\"javascript:funCompareOnChange(this)\">\n<option value=\"\">Compare more<\/option>\n";
    var spCompHead3 = "<select id=\"comparePhone3\" name=\"comparePhone3\" class=\"select\" style=\"width:150px;\" OnChange=\"javascript:funCompareOnChange(this)\">\n<option value=\"\">Compare more<\/option>\n";
    var spCompTail = "<\/select>\n";

    document.getElementById("spComparePhone1").innerHTML = spCompHead1+phoneComboHtml+spCompTail;
    document.getElementById("spComparePhone2").innerHTML = spCompHead2+phoneComboHtml+spCompTail;
    document.getElementById("spComparePhone3").innerHTML = spCompHead3+phoneComboHtml+spCompTail;
    
    if(getCookie("phoneCompare") != null && getCookie("phoneCompare") != ""){                        
        var rowCookie = getCookie("phoneCompare").split("^");            
        var colCookie;
        
        var comparePhoneText = rowCookie.length;
        document.getElementById("compareSize").innerHTML = "<img src=\""+URL_ROOT+"/images/products/txt_cplist_num_"+comparePhoneText+".gif\" alt=\""+comparePhoneText+"\" /><img src=\""+URL_ROOT+"images/products/txt_cplist_2.gif\" class=\"txt\" alt=\"Phones\" />";
        
        for(var i = 0 ; i < rowCookie.length; i++){
            colCookie = rowCookie[i].split('|');
			document.getElementById("comparePhone"+(i+1)).value = colCookie[0];
        }
    }else{
        document.getElementById("compareSize").innerHTML = "0";
    }

	document.getElementById("expandViewTab").disabled = true;
    funSpecListSearch();
}

function funCompareOnChange(selectObj){    
    var selecObjId = selectObj.id; 
    
    funSpecListSearch(selecObjId);
}

function funSpecListSearch(selecObjId){    
	blockAll(true);
	
    var resetNum;
    
    if(selecObjId == "comparePhone1"){
        resetNum = 1;
    }else if(selecObjId == "comparePhone2"){
        resetNum = 2;
    }else if(selecObjId == "comparePhone3"){
        resetNum = 3;
    }
    
    var spCompTail = "<\/select>\n";
    
    var compTemp = "";
    
    for(var i = 1 ; i < 3; i++){
        compTemp = document.getElementById("comparePhone"+i).value
        
        if(compTemp == ""){
            continue;
        }
        
        for(var j = i+1; j<4; j++){
            if(compTemp == "" && document.getElementById("comparePhone"+j).value == ""){
                break;
            }
            
            if(compTemp == document.getElementById("comparePhone"+j).value){                
                document.getElementById("spComparePhone"+resetNum).innerHTML = "<select id=\"comparePhone"+resetNum+"\" name=\"comparePhone"+resetNum+"\" class=\"select\" style=\"width:150px\" OnChange=\"javascript:funCompareOnChange(this)\">\n<option value=\"\">Compare more<\/option>\n"+phoneComboHtml+spCompTail;                                
                
                document.getElementById("compPhoneImg"+resetNum).innerHTML = "<img src=\""+URL_ROOT+"images/common/noimg/noimg_120.gif\" class=\"pd_img\" alt=\"Phone Name\" title=\"Phone Name\" />\n";
                document.getElementById("compPhoneFeature"+resetNum).innerHTML = "";    
                
                //new Selectbox('comparePhone'+resetNum);
                
                var strComp = "";
                
                switch(resetNum){
                    case (1) :
                        strComp = "A";
                        break;                
                    case (2) :
                        strComp = "B";
                        break;                
                    case (3) :
                        strComp = "C";
                        break;                                
                }
                
                for(var k = 0;; k++){                    
                    if(document.getElementById("compareCon"+strComp+k) == null){
                        break;
                    }
                    document.getElementById("compareCon"+strComp+k).innerHTML = "";
                }
                
                var cookieVal="";
                for(var l = 1; l < 4; l++){
                    if(cookieVal == ""){
                        cookieVal += document.getElementById("comparePhone"+l).value;
                    }else{
                        cookieVal += "|"+document.getElementById("comparePhone"+l).value;
                    }
                }
                
                delPhoneModelCookie(cookieVal);
				
				var j = 0;
			    for(var i = 1; i< 4; i++){
			        if(document.getElementById("comparePhone"+i).options[document.getElementById("comparePhone"+i).selectedIndex].value != ""){    
			            j++;
			        }
			    }
				document.getElementById("compareSize").innerHTML = "<img src=\""+URL_ROOT+"/images/products/txt_cplist_num_"+j+".gif\" alt=\""+j+"\" /><img src=\""+URL_ROOT+"images/products/txt_cplist_2.gif\" class=\"txt\" alt=\"Phones\" />";
                
                alert(P01);
                //return;
            }
        }
    }
    
    var phoneModel1 = document.getElementById("comparePhone1").value;
    var phoneModel2 = document.getElementById("comparePhone2").value;
    var phoneModel3 = document.getElementById("comparePhone3").value;
    
    //document.getElementById("compare_speclist").innerHTML = "<div class=\"loading_layer\"><img src=\""+URL_ROOT+"images/common/img_loading.gif\" alt=\"Loading\" /></div>";

    ProductsDwrAction.selectGSfcSpecList({
                phoneModel1:phoneModel1
               ,phoneModel2:phoneModel2
               ,phoneModel3:phoneModel3
            },
            function funSpecSearch(data){
				
                var phone1 = data["phone1"];                
                var phone2 = data["phone2"];
                var phone3 = data["phone3"];
                
                var phoneSpec1 = data["phoneSpec1"];
                var phoneSpec2 = data["phoneSpec2"];
                var phoneSpec3 = data["phoneSpec3"];
                
                var copNum;
                
                if( phoneSpec1 != "" ){
                    compNum = 1;     
					
					var phoneUrl = phoneSpec1[0].phoneName.toLowerCase();
                    phoneUrl = phoneUrl.replace(/\s/g, "-").replace(/samsung-|samsung|sgh-|sch-|gt-/g, "");
					phoneUrl = "samsung-" + phoneUrl;            

                    if(phoneSpec1[0].smallImage == ""){
                        document.getElementById("compPhoneImg"+compNum).innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneSpec1[0].phoneName+"\"><img src=\""+URL_ROOT+"images/common/noimg/noimg_120.gif\" class=\"pd_img\" alt=\"Phone Name\" title=\"Phone Name\" />";
                    }else{
                        if(phoneSpec1[0].smallImage.substring(0,4) != 'http'){
                            document.getElementById("compPhoneImg"+compNum).innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneSpec1[0].phoneName+"\"><img src=\""+URL_ROOT+phoneSpec1[0].smallImage+"\" class=\"pd_img\" width=\"120\" height=\"120\" alt=\""+phoneSpec1[0].phoneName+"\" /><\/a>";
                        }
                        if(phoneSpec1[0].smallImage.substring(0,4) == 'http'){
                            document.getElementById("compPhoneImg"+compNum).innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneSpec1[0].phoneName+"\"><img src=\""+phoneSpec1[0].smallImage+"\" class=\"pd_img\" width=\"120\" height=\"120\" alt=\""+phoneSpec1[0].phoneName+"\" /><\/a>";
                        }                       
                    }
                    
                    var featureHtml = "";
					featureHtml += "<dt>Key Features</dt>\n";
                    if(phoneSpec1[0].features1 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec1[0].features1,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec1[0].features2 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec1[0].features2,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec1[0].features3 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec1[0].features3,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec1[0].features4 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec1[0].features4,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec1[0].features5 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec1[0].features5,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec1[0].features6 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec1[0].features6,22)+"</dd>\n";
                    }

                    document.getElementById("compPhoneFeature"+compNum).innerHTML = featureHtml;
                    
                }else{
                    document.getElementById("compPhoneImg1").innerHTML = "<img src=\""+URL_ROOT+"images/common/noimg/noimg_120.gif\" class=\"pd_img\" alt=\"Phone Name\" title=\"Phone Name\" />";
                    document.getElementById("compPhoneFeature1").innerHTML = "";
                }

                if( phoneSpec2 != "" ){
                    compNum = 2;              

					var phoneUrl = phoneSpec2[0].phoneName.toLowerCase();
                    phoneUrl = phoneUrl.replace(/\s/g, "-").replace(/samsung-|samsung|sgh-|sch-|gt-/g, "");
					phoneUrl = "samsung-" + phoneUrl;  
					
                    if(phoneSpec2[0].smallImage == ""){    
                        document.getElementById("compPhoneImg"+compNum).innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneSpec2[0].phoneName+"\"><img src=\""+URL_ROOT+"images/common/noimg/noimg_120.gif\" class=\"pd_img\" alt=\"Phone Name\" title=\"Phone Name\" />";
                    }else{
                        if(phoneSpec2[0].smallImage.substring(0,4) != 'http'){
                            document.getElementById("compPhoneImg"+compNum).innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneSpec2[0].phoneName+"\"><img src=\""+URL_ROOT+phoneSpec2[0].smallImage+"\" class=\"pd_img\" width=\"120\" height=\"120\" alt=\""+phoneSpec2[0].phoneName+"\" /><\/a>";                            
                        }
                        if(phoneSpec2[0].smallImage.substring(0,4) == 'http'){
                            document.getElementById("compPhoneImg"+compNum).innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneSpec2[0].phoneName+"\"><img src=\""+phoneSpec2[0].smallImage+"\" class=\"pd_img\" width=\"120\" height=\"120\" alt=\""+phoneSpec2[0].phoneName+"\" /><\/a>";                            
                        }                            
                    }

                    var featureHtml = "";
					featureHtml += "<dt>Key Features</dt>\n";
                    if(phoneSpec2[0].features1 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec2[0].features1,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec2[0].features2 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec2[0].features2,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec2[0].features3 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec2[0].features3,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec2[0].features4 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec2[0].features4,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec2[0].features5 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec2[0].features5,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec2[0].features6 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec2[0].features6,22)+"</dd>\n";
                    }
                    
                    document.getElementById("compPhoneFeature"+compNum).innerHTML = featureHtml;

                }else{
                    document.getElementById("compPhoneImg2").innerHTML = "<img src=\""+URL_ROOT+"images/common/noimg/noimg_120.gif\" class=\"pd_img\" alt=\"Phone Name\" title=\"Phone Name\" />";
                    document.getElementById("compPhoneFeature2").innerHTML = "";
                }

                if( phoneSpec3 != "" ){
                    compNum = 3;                   
					
					var phoneUrl = phoneSpec3[0].phoneName.toLowerCase();
                    phoneUrl = phoneUrl.replace(/\s/g, "-").replace(/samsung-|samsung|sgh-|sch-|gt-/g, "");
					phoneUrl = "samsung-" + phoneUrl;  
					
                    if(phoneSpec3[0].smallImage == ""){    
                        document.getElementById("compPhoneImg"+compNum).innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneSpec3[0].phoneName+"\"><img src=\""+URL_ROOT+"images/common/noimg/noimg_120.gif\" class=\"pd_img\" alt=\"Phone Name\" title=\"Phone Name\" />";
                    }else{
                        if(phoneSpec3[0].smallImage.substring(0,4) != 'http'){
                            document.getElementById("compPhoneImg"+compNum).innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneSpec3[0].phoneName+"\"><img src=\""+URL_ROOT+phoneSpec3[0].smallImage+"\" class=\"pd_img\" width=\"120\" height=\"120\" alt=\""+phoneSpec3[0].phoneName+"\" /><\/a>";                            
                        }
                        if(phoneSpec3[0].smallImage.substring(0,4) == 'http'){
                            document.getElementById("compPhoneImg"+compNum).innerHTML = "<a href=\""+URL_ROOT+"mobile-phones/" + phoneUrl + "\" title=\""+phoneSpec3[0].phoneName+"\"><img src=\""+phoneSpec3[0].smallImage+"\" class=\"pd_img\" width=\"120\" height=\"120\" alt=\""+phoneSpec3[0].phoneName+"\" /><\/a>";                            
                        }                       
                    }

                    var featureHtml = "";
					featureHtml += "<dt>Key Features</dt>\n";
                    if(phoneSpec3[0].features1 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec3[0].features1,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec3[0].features2 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec3[0].features2,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec3[0].features3 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec3[0].features3,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec3[0].features4 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec3[0].features4,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec3[0].features5 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec3[0].features5,22)+"</dd>\n";
                    }
                    
                    if(phoneSpec3[0].features6 != " "){
                        featureHtml += "<dd>"+FFStrCutByteString(phoneSpec3[0].features6,22)+"</dd>\n";
                    }
                    
                    document.getElementById("compPhoneFeature"+compNum).innerHTML = featureHtml;
                    
                }else{
                    document.getElementById("compPhoneImg3").innerHTML = "<img src=\""+URL_ROOT+"images/common/noimg/noimg_120.gif\" class=\"pd_img\" alt=\"Phone Name\" title=\"Phone Name\" />";
                    document.getElementById("compPhoneFeature3").innerHTML = "";
                }
				
                var inhtml = "";
                var j = 1;
                var k = 1;
                var chkSpecLevel = "";
                var chkSpecSeqNo = "";
                var phoneSpecAdd1 = "";
                var phoneSpecAdd2 = "";
                var phoneSpecAdd3 = "";
                
                var noViewSpecSeqNo = ""
                var viewYn = "Y";
                for(var i = 0; i < phone1.length ; i++){
                    if(phone1[i].specLevel == 1){
						
						//비전시 스펙은 예외처리
						noViewSpecSeqNo = phone1[i].specSeqNo;
                        if(noViewSpecSeqNo != 2 && noViewSpecSeqNo != 15 && noViewSpecSeqNo != 16 && noViewSpecSeqNo != 17){
                            viewYn = "Y";
                        }else{
                            viewYn = "N";
                        } 
						
						//이전과는 다른 level1 스펙이 들어오면 tag 닫고 새로 open한다.
						if(chkSpecLevel != "" && viewYn == "Y"){
							inhtml += "    </ul>\n";
							inhtml += "</dd>\n";
						}                   
                        
                        if(viewYn == "Y"){               
							if( i != 0 ){     
                            	inhtml += "<dt>\n";
							}else{
								inhtml += "<dt class=\"first\">\n";
							}
                            inhtml += "    <span><img src=\""+URL_ROOT+PUB_LOCAL+""+PHONESPEC_SAVE_PATH+""+phone1[i].imagePath+"\" class=\"symbol\" width=\"25\" height=\"25\" alt=\""+phone1[i].specName+"\" />"+phone1[i].specName+"<\/span>\n";
                            inhtml += "<\/dt>\n";
                            inhtml += "<dd id=\"expandView_"+j+"\">\n";
							inhtml += "    <ul>\n";
							
							j++;
                        }                   
                    } //end if( specLevel == 1 )
                    if(phone1[i].specLevel == 2){       

						phoneSpecAdd1 = "";
                		phoneSpecAdd2 = "";
                		phoneSpecAdd3 = "";
				
						if(phone1[i].specYn == "true" && viewYn == "Y" ){    
                            phoneSpecAdd1 = phone1[i].specCaption;
                        }  
						
						if( phone2[i] != null ){
							if(phone2[i].specYn == "true" && viewYn == "Y" ){
                            	phoneSpecAdd2 = phone2[i].specCaption;
							}
                        }	
						
                        if(phone3[i] != null ){
						    if(phone3[i].specYn == "true" && viewYn == "Y" ){
	                            phoneSpecAdd3 = phone3[i].specCaption;
	                        }
						}
							                 
                        if(viewYn == "Y"){    
							inhtml += "        <li>\n";
							inhtml += "            <span class=\"subject\">"+phone1[i].specName+"</span>\n";
                            inhtml += "            <span class=\"filed1\">&nbsp;"+phoneSpecAdd1.split("/").join(" / ")+"</span>\n";
                            inhtml += "            <span class=\"filed2\">&nbsp;"+phoneSpecAdd2.split("/").join(" / ")+"</span>\n";                            
                            inhtml += "            <span class=\"filed3\">&nbsp;"+phoneSpecAdd3.split("/").join(" / ")+"</span>\n";
                            inhtml += "        <\/li>\n";
							
							k++;  
                        }         
                    } //end if( specLevel == 2 )		
                    
					chkSpecLevel = phone1[i].specLevel;
								
                } // end for
                
				inhtml += "    </ul>\n";
				inhtml += "</dd>\n";

                document.getElementById("compare_speclist").innerHTML = inhtml;

                for(var i = 1 ; i < 4; i++){
                    document.getElementById("comparePhone"+i).disabled = false;
                }
                var chkLen = document.getElementsByName("chkQuick").length;                
                for(var i = 0; i < chkLen ; i++){
                    document.getElementsByName("chkQuick")[i].disabled = false;
                }
				
                delAllCompare();
                if( phoneSpec1 != "" ){
                    setCookie(phoneSpec1[0].phoneModel,phoneSpec1[0].mini_name,phoneSpec1[0].smallImage);
                }
                if( phoneSpec2 != "" ){
                    setCookie(phoneSpec2[0].phoneModel,phoneSpec2[0].mini_name,phoneSpec2[0].smallImage);
                }
                if( phoneSpec3 != "" ){
                    setCookie(phoneSpec3[0].phoneModel,phoneSpec3[0].mini_name,phoneSpec3[0].smallImage);
                }
				
				var j = 0;
			    for(var i = 1; i< 4; i++){
			        if(document.getElementById("comparePhone"+i).options[document.getElementById("comparePhone"+i).selectedIndex].value != ""){    
			            j++;
			        }
			    }
			    document.getElementById("compareSize").innerHTML = "<img src=\""+URL_ROOT+"/images/products/txt_cplist_num_"+j+".gif\" alt=\""+j+"\" /><img src=\""+URL_ROOT+"images/products/txt_cplist_2.gif\" class=\"txt\" alt=\"Phones\" />";
				
				selectHide2('laypop_compare');      				
				ToggleCompareSpec(document.getElementById("compare_speclist")); 
				document.getElementById("expandViewTab").disabled = false;        
				expandFlag = !expandFlag;
				expandAll();
				compare();
				topInit();
				unblockAll();
            }
    );
}

//phone search combo
function selectSeries() {
    var siteCd = LANG;
    var langCd = LANG_CD;
    var seriesSeqNo = document.getElementById("seriesSeqNo");
    var selectSeriesSeqNo = seriesSeqNo.value;
    var seriesPhoneModel = document.getElementById("seriesPhoneModel");

    var gSfcPrdSeries;
    gSfcPrdSeries = {siteCd:siteCd, langCd:langCd, seriesSeqNo:selectSeriesSeqNo};
    SeriesPrdActionDWR.selectGSfcPrdSeriesListDWR(
            gSfcPrdSeries,
            function selectPhoneModelSelect(data){    
                
                var phoneModelSelect = "<select id=\"seriesPhoneModel\" name=\"seriesPhoneModel\" style=\"width:163px\" onchange=\"javascript:selectSeriesPhoneModel();\">";
                    phoneModelSelect += "<option value=\"\">Phone Names<\/option>";
                
                for(var i=0; i < data.length; i++) {                    
                    phoneModelSelect += "<option value=\""+data[i].phoneModel+"\">"+data[i].phoneName+"<\/option>";
                }
            
                    phoneModelSelect += "<\/select>";
                    
                document.getElementById("selectPhoneModel").innerHTML = phoneModelSelect;
                
                new Selectbox('seriesPhoneModel');
            }             
        );
}

function selectPhoneList(){
    if(document.getElementById("seriesPhoneModel").value == '1' || document.getElementById("seriesPhoneModel").value == ''){
        return;
    } else {
        selectSeriesPhoneModel();
    }
}

//2009.11.20 신규(셀렉트박스가 없어지면서 대체)
function selectPhoneList2(strModelName){
    if(strModelName == '1' || strModelName == ''){
        return;
    } else {
        selectSeriesPhoneModel2(strModelName);
    }
}

function selectHide2(Name){
    self.clearTimeout(setTime);
    
    selectObj = document.getElementById(Name);
    selectObj.style.display='none';
}

function autoHide(id){
    if( document.getElementById(id).style.display == "none" ){
		document.getElementById(id).style.display = "";
	}else{
		document.getElementById(id).style.display = "none";
	}
}

function funQuickSearch(iNum){
	
	if( modal != 0 ){
		blockAll(true);	
	}
	
	modal++;
    
    var searchSpecSeqNo="";
    var searchCnt=0;
    
    var advanceIsChoice = false;
	
	if(iNum != undefined){
		if(document.getElementsByName("chkAdvance")[iNum-1].checked == true){
			document.getElementsByName("chkAdvance")[iNum-1].checked = false;	
		}else{
			document.getElementsByName("chkAdvance")[iNum-1].checked = true;
		}
	}
	
    var advanceLen = document.getElementsByName("chkAdvance").length;
    for(var i = 0; i < advanceLen ; i++){
        if(document.getElementsByName("chkAdvance")[i] != null){
            if(document.getElementsByName("chkAdvance")[i].checked){
                searchSpecSeqNo += document.getElementsByName("chkAdvance")[i].value+",";
                advanceIsChoice = true;
				document.getElementById("la"+(i+1)).className = "on";
            }else{
				document.getElementById("la"+(i+1)).className = "";
			}
        }
    }
	
	if(advanceIsChoice){
		searchCnt++;
	}
		
    var chkLen = document.getElementsByName("chkQuick").length;
    for(var i = 0; i < chkLen ; i++){
        if(document.getElementsByName("chkQuick")[i] != null){
            if(document.getElementsByName("chkQuick")[i].checked){
                searchSpecSeqNo += document.getElementsByName("chkQuick")[i].value+",";
                searchCnt++;
            }
        }
    }        
	
	searchSpecSeqNo = searchSpecSeqNo.substring(0,searchSpecSeqNo.length-1);

    funSearch(searchSpecSeqNo, searchCnt);
    
    if(feature_num !="" && quick_count == 1 ){
        var form = document.frm ;
        var chkCnt = 0;
        
        for(var j=0; j<form.chkQuick.length; j++){
            if(chkCnt < 2){
                if(form.chkQuick[j].checked == true){
                    if(chkCnt == 0){
                        form.chkDtl1.value = form.chkQuick[j].value
                    }else{
                        form.chkDtl2.value = form.chkQuick[j].value
                    }
                    chkCnt = chkCnt + 1;
                }
            }else{
                break;
            }
        }
		        
        form.action = "/mobile-phones/phone-search.do";
        form.submit(); 
    }
}

function funSearch(searchSpecSeqNo, searchCnt){//searchSpecSeqNo
    try {
		
		var kind;
        var chkAdvanceLen = document.getElementsByName("chkAdvance").length;    
                    
        for(var i = 0; i < chkAdvanceLen ; i++){
            document.getElementsByName("chkAdvance")[i].disabled = true;
        }
        
        var chkLen = document.getElementsByName("chkQuick").length;    
        for(var i = 0; i < chkLen ; i++){
            document.getElementsByName("chkQuick")[i].disabled = true;
        }
        
		modal == 1 ? kind = "latest" : kind = "";
				
		document.getElementById("sort_terms").className = "pd_sort";
		document.getElementById("sort_terms2").style.display = "";
		document.getElementById("found_pdnum").style.display = "";
        
        document.getElementById("phoneSearchPage").style.display = "";
        document.getElementById("phoneComparePage").style.display = "none";
        document.getElementById("compPhone").style.display = "none";
         
        var sort = curSort;   

        ProductsDwrAction.selectGSfcPrdSearchDwrList({
                 searchSpecSeqNo:searchSpecSeqNo
                ,searchCnt:searchCnt
                ,kind:kind
                ,order:sort
                ,phoneModel:""        
            },
            function funPhoneSearch(data){

            if(feature_num !="" || quick_count == 0){
                phoneData = data;
                
                var iconGbn = document.getElementById("viewGbn").value;
                
                viewIconChange(iconGbn);
                                
                var chkLen = document.getElementsByName("chkQuick").length;                
                for(var i = 0; i < chkLen ; i++){
                    document.getElementsByName("chkQuick")[i].disabled = false;
                }
                
                var chkAdvanceLen = document.getElementsByName("chkAdvance").length;                
                for(var i = 0; i < chkAdvanceLen ; i++){
                    document.getElementsByName("chkAdvance")[i].disabled = false;
                }
                document.getElementById("sort").disabled = false;

				//compareSetting();	
                quick_count=1;
            
            }else{
                phoneData = data;                
                var inhtml = "";
				var strLen = "";
				var lenHtml = "";
                
				strLen = ""+data.length;
				
				dispTotalNum(strLen);

				inhtml += "<div class=\"pd_imglist_sec\">\n";
				inhtml += "    <ul>\n";
	            for(var i=0; i< data.length; i++){
					
	                inhtml += "        <li>\n";
	                inhtml += "            <div class=\"pd_img_sec\">\n";    
					
					var phoneUrl = data[i].phoneName.toLowerCase();
	                phoneUrl = phoneUrl.replace(/\s/g, "-").replace(/samsung-|samsung|sgh-|sch-|gt-/g, "");
	                phoneUrl = "samsung-" + phoneUrl;  
					
					if(data[i].quickViewImage.substring(0,4) != 'http'){
		                inhtml += "                <a title=\""+data[i].phoneName+"\" href=\""+URL_ROOT+"mobile-phones/"+phoneUrl+"\"><img src=\""+URL_ROOT+data[i].quickViewImage+"\" class=\"pd_img\" alt=\""+data[i].phoneName+"\" title=\""+data[i].phoneName+"\" /></a>\n";                
	                }else{
						inhtml += "                <a title=\""+data[i].phoneName+"\" href=\""+URL_ROOT+"mobile-phones/"+phoneUrl+"\"><img src=\""+data[i].quickViewImage+"\" class=\"pd_img\" alt=\""+data[i].phoneName+"\" title=\""+data[i].data+"\" /></a>\n";						
					}
	        		
					inhtml += "            </div>\n";
					
	                if(data[i].newgbn == "new"){
		                inhtml += "            <p class=\"pd_name\"><img src=\""+URL_ROOT+"images/common/btn/ico_new_pd.gif\" class=\"ico_mr8\" alt=\"New\" title=\"New\" /><a title=\""+data[i].phoneName+"\" href=\""+URL_ROOT+"mobile-phones/"+phoneUrl+"\">"+data[i].phoneName+"</a><\/p>\n";
	                }else{                
	                    inhtml += "            <p class=\"pd_name\"><a title=\""+data[i].phoneName+"\" href=\""+URL_ROOT+"mobile-phones/"+phoneUrl+"\">"+data[i].phoneName+"</a><\/p>\n";
	                }
					
					inhtml += "            <p class=\"control\">\n";
					inhtml += "                <span id=\""+data[i].phoneModel+"_i\"><a title=\"COMPARE\" href=\"javascript:setCookie('"+data[i].phoneModel+"','"+data[i].mini_name+"','"+data[i].smallImage+"');\" class=\"compare\"><img src=\""+URL_ROOT+"images/common/btn/bt_compare_type4_off.gif\" id=\""+data[i].phoneModel+"_iimg\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"compare\" title=\"compare\" /></a></span><a title=\"IN BRIEF\" onclick=\"javascript:quickview_view(event,'quickview',"+(i+1)+",'"+data[i].phoneModel+"');\" href=\"#quick_view\" class=\"inbrief\"><img src=\""+URL_ROOT+"images/common/btn/bt_inbrief_type4_off.gif\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"in brief\" title=\"in brief\" /></a>\n";
					//inhtml += "                <a title=\"IN BRIEF\" onclick=\"javascript:quickview_view(event,'quickview',"+(i+1)+",'"+data[i].phoneModel+"');\" href=\"#quick_view\" class=\"inbrief\"><img src=\""+URL_ROOT+"images/common/btn/bt_inbrief_type4_off.gif\" onmouseover=\"ImageOver(this)\" onmouseout=\"ImageOut(this)\" alt=\"in brief\" title=\"in brief\" /></a>\n";					
					inhtml += "            </p>\n";
					inhtml += "        </li>\n";

				} //end for
				
				inhtml += "    </ul>\n";
				inhtml += "</div>\n";
                
				if( data.length == 0 ){
					inhtml = "<div class=\"popular_pd\"><div class=\"acc_message\"><img src=\""+URL_ROOT+"images/products/p_acc_1.gif\" border=\"0\" alt=\"Sorry,no product found\" /></div></div>\n";
				}
                
                thumbnailView="";
                detailViewHtml="";
				
                document.getElementById("imageView").innerHTML = inhtml;
                document.getElementById("thumbnailView").innerHTML = thumbnailView;
                document.getElementById("detailView").innerHTML = detailViewHtml;
				            
                var iconGbn = document.getElementById("viewGbn").value;                
                viewIconChange(iconGbn);

                var chkLen = document.getElementsByName("chkQuick").length;                
                for(var i = 0; i < chkLen ; i++){
                    document.getElementsByName("chkQuick")[i].disabled = false;
                }
                
                var chkAdvanceLen = document.getElementsByName("chkAdvance").length;                
                for(var i = 0; i < chkAdvanceLen ; i++){
                    document.getElementsByName("chkAdvance")[i].disabled = false;
                }
                document.getElementById("sort").disabled = false
            	//compareSetting();
            } // end if
            unblockAll();
            } //end funtion
        );  // end DWR
        topInit();
        
    }catch(e){
        alert(PPP);
		unblockAll();
    }    
}


function feature_change(feature_name,feature_num){
    var form = document.frm2;
    form.feature_num.value = feature_num;
    form.action = "/mobile-phones/phone-search.do?feature="+feature_name;
    form.submit();
}

//숫자를 이미지로 변환
function dispTotalNum(arg){
	var strLen = arg+"";	
	var lenHtml = "";
	
	for(var t=0;t<strLen.length;t++){
		lenHtml += "<img src=\""+URL_ROOT+"images/products/txt_pdlist_num_"+strLen.substring(t,t+1)+".gif\" alt=\""+strLen.substring(t,t+1)+"\" />"; 
	}
	document.getElementById("totalPhone").innerHTML = lenHtml;
}

//compare프린트 팝업
function comparePrintPop(){
	
	var popUrl = URL_ROOT+"products/popup/comparePrint.do";
	FFWindowOpen(WINDOW_ALIGN_CENTER,popUrl,"print","835","673","scrollbars=auto");	
}

function blockAll(withLoading) {
	if (withLoading) {
		$('#flash_loading_image').show();
	}

   $.blockUI({ message: null });
   $("#content").block({ message:null });
   //$("#aside").block({ message : null });
   //$(".gnb_sec").block({ message:null });
   //$(".global_search").block({ message:null });
}

function unblockAll() {
	$('#flash_loading_image').hide();
   	$.unblockUI();
   	$("#content").unblock();
   	//$("#aside").unblock();
   	//$(".gnb_sec").unblock();
   	//$(".global_search").unblock();
}