//ListCollection Response
function ListCollectionResponse (request) {
	var str = '';
	var xml = request.responseXML;

	var elements = xml.documentElement.getElementsByTagName('item');
	var div_space = '<div class="space"></div>';
	var space = '<font class="fontwhite"> | </font>';
	var sub_menu_online = '';
	var detail_feature = '';
	var items_collection = 0;

	for(var i=0;i<elements.length;i++){
		id = getNodeValue(elements[i], "product_cate_id");
		product_cate_name_en = getNodeValue(elements[i], "product_cate_name_en");
		product_cate_id = getNodeValue(elements[i], "product_cate_id");

		var esub = elements[i].getElementsByTagName('sub').item(0).getElementsByTagName('sub_item');
		items_collection = esub.length;

		if((items_collection>0) && (id==cate_id)){
			for (count = 0; count < items_collection; count++){
				detail_feature = '';
				pid = getNodeValue(esub[count], "product_id");
				collec_id = getNodeValue(esub[count], "collec_gp_id");
				collection_en = getNodeValue(esub[count], "collec_gp_name_en");
				collec_pic = getNodeValue(esub[count], "collec_pic");
				detail = getNodeValue(esub[count], "description");
				sp_feature = getNodeValue(esub[count], "sp_feature");

				if((sp_feature!=null) && (sp_feature!="")){
					detail_feature = Special_Feature(sp_feature);
				}

				div_left = '<div class="block_left" id="block_left'+count+'">';
				div_left += '	<div></div>';
				div_left += '</div>';
	
				div_center = '<div class="collection" id="collection'+count+'"><a href="#" onClick="javascript:SlideOpen(collection'+count+',block_left'+count+',block_right'+count+','+collec_id+',block_right_detail'+count+'); return false;"><img src="'+img_collec+collec_pic+'" border="0" height="380" width="300" /></a><div class="Collection_name"><strong>'+collection_en+'</strong></div></div>';
	
				div_right = '<div class="block_right" id="block_right'+count+'">';
				div_right += '	<div class="close" align="right">';
				div_right += '		<a href="#" class="close_block" onClick="javascript:SlideClose(block_left'+count+',block_right'+count+',block_right_detail'+count+',collection'+count+','+count+'); return false;">close</a><br />';
				div_right += '		<div class="collec_name" align="left">'+collection_en+'</div>';
				div_right += '	</div>';
				div_right += '	<div class="close" id="block_right_detail'+count+'">';
				div_right += '		<div class="bodywhite12" align="left"><font class="bodywhite">'+ detail +'</br>'+ detail_feature +'</font><br /></div>';
				div_right += '	</div>';
				div_right += '</div>';
				
				set(div_center,count);
				setInsriation( '<div class="bodywhite12" align="left"><font class="bodywhite">'+ detail +'</br>'+ detail_feature +'</font><br /></div>',count);
				$('collection_container').innerHTML += div_space + div_left + div_center +  div_right;
				str += div_space + div_left + div_center +  div_right;

			}
			resetBrowserW(items_collection);
		}

		if(product_cate_id==cate_id){
			sub_menu_online += '<a href="'+ file +'?cate_id='+product_cate_id+'" target="rightFrame"><font class="SubMenuLeftActive">'+product_cate_name_en+'</font></a>'+space;
		}else{
			sub_menu_online += '<a href="'+ file +'?cate_id='+product_cate_id+'" target="rightFrame">'+product_cate_name_en+'</a>'+space;
		}
		if(product_cate_id==4){sub_menu_online += '<a href="napkins.php" target="rightFrame">Napkins</a>'+space;}
	}
	parent.$('sp_sub_menu_fabric').innerHTML = sub_menu_online;
}

//Silde Colse
function SlideClose(e_Left,e_Right,e_Detail,e_Center,index){
	Effect.SlideClose($(e_Left));
	Effect.SlideClose($(e_Right));

	$(e_Center).innerHTML = get(index);
	$(e_Detail).innerHTML = getInsriation(index);
	$(e_Left).hidden = 'false';
}

//Slider Open
function SlideOpen(e_center,e_Left,e_Right,collec_id,e_Detail){
	if($(e_Left).hidden != 'true'){

		$(e_Left).style.position="relative";
		$(e_Left).style.visibility="visible";
		
		$(e_Right).style.position="relative";
		$(e_Right).style.visibility="visible";
	
		Effect.SlideOpen($(e_Left));
		Effect.SlideOpen($(e_Right));
		$(e_Left).hidden = 'true';

		Collection_Set(collec_id,e_Left,e_center.id,e_Right.id,e_Detail.id);
	}
}

//Collection Set
function Collection_Set(collec_id,e_Left,e_Center,e_Right,e_Detail) {
	var url = 'service2/collection_set.php';	
	var pars = "collec_id="+collec_id+'&cate_id='+cate_id;

	var myAjax = new Ajax.Request( url,
		{
			method: 'get',
			parameters: pars,
//			onLoading: showLoad('collection_container','<table width=100% height=90%><tr valign="middle" align="center"><td><img src="images/loading.gif" width=50 height=50></td></tr></table>'),
			onComplete: function (t){CollectionSetResponse(t,e_Left,e_Center,e_Right,e_Detail)},
			onFailure: showFail
		} 
	);
}

function CollectionSetResponse(request,e_Left,e_Center,e_Right,e_Detail){

	var xml = request.responseXML;
	var elements = xml.documentElement.getElementsByTagName('item');

	// get data
	var pxml = new ParserXML();
	pxml.parserdata(elements);
	var a = pxml.result;

	var loop = 0;
	var str='';

	index = getIndex($(e_Center).id);

	for (count = 0; count < a.length; count++){
		pid = a[count]['product_id'];
		product_type_name = a[count]['product_type_name_en'];
		product_name = a[count]['product_name_en'];
		design = a[count]['design_name'];
		color = a[count]['color'];
		barcode = a[count]['barcode'];
		pic1 = a[count]['pic1'];
		pic2 = a[count]['pic2'];
		pic3 = a[count]['pic3'];
		thumbnail = a[count]['thumbnail'];
		gp_color = a[count]['gp_id'];

		//discount type
		discount = parseFloat(a[count]['discount']);
		discount_type = parseFloat(a[count]['discount_type']);
		discount_collection = parseFloat(a[count]['discount_collection']);

		// Calculate discount price
		if(isNaN(discount)){
			discount=0;
		}			
		if(isNaN(discount_type)){
			discount_type=0;
		}			
		if(isNaN(discount_collection)){
			discount_collection=0;
		}
		
		_discount = 0;
		if (discount>discount_type){
			if(discount>discount_collection){
				_discount = discount;
			}else{
				_discount = discount_collection;
			}
		}else{
			if(discount_type>discount_collection){
				_discount = discount_type;
			}else{
				_discount = discount_collection;
			}
		}	
	
		// check display price THB or USD
		price = a[count]['price'];
		th_price = a[count]['price'];
		us_price = Math.ceil( (parseFloat(price) / parseFloat(_usd)) );

		if (parseInt(_discount)>0){
			th_discount_price = Math.ceil (th_price - ((th_price * _discount)/100));
			us_discount_price = Math.ceil (us_price - ((us_price * _discount)/100));				
		}else{
			th_discount_price =Math.ceil( th_price );
			us_discount_price =Math.ceil( us_price );
		}
		if(getCookie("excCurrency")=="THB" || getCookie("excCurrency")=="" || getCookie("excCurrency")==null ){
			current_price = th_discount_price;
			display_price = th_price;
			price_unit = 'THB';
		}else{		
			current_price = us_discount_price;
			display_price = us_price;
			price_unit = 'USD';
		}

		str += '<div class="sblock_left" id="s_collec_'+(count+1)+'"><div align="right" class="design_name">'+product_type_name+'</div><a href="javascript:Collection_Detail('+pid+',\''+ product_name +'\',\''+ design +'\',\''+ color +'\',\''+ barcode +'\',\''+ pic1 +'\',\''+ pic2 +'\',\''+ pic3 +'\',\''+ display_price +'\',\''+ current_price +'\',\''+ price_unit +'\',\''+ gp_color +'\',\''+ e_Center +'\',\''+ e_Right +'\',\''+ e_Detail +'\');"><br><img src="'+img_path+thumbnail+'" border="0" /></a></div>';
	}

	$(e_Left).innerHTML = str;
}

//Collection Detail
function Collection_Detail(pid,product_name,design,color,barcode,pic1,pic2,pic3,price,discountprice,price_unit,gp_color,e_Center,e_Right,e_Detail){

	$(e_Center).innerHTML = '<div class="collection_pic"><br><br><br><a href="javascript:product_popup(\''+ product_name +'\',\''+ design +'\',\''+ color +'\',\''+ pic2 +'\',\''+ pic3 +'\');""><img src="'+img_path+pic1+'" border="0" alt="Click to see more image" /></a></div>';
	
	index = getIndex($(e_Center).id);

	str = '';														
	str += '	<table cellpadding="0" cellspacing="0" border="0" align="left">';
	str += '		<tr>';
	str += '			<td align="left" class="bodywhite" colspan="2"><div id="dv_product_name">'+product_name+'</div></td>';
	str += '		</tr>';
	str += '		<tr>';
	str += '			<td align="right" colspan="2"><a href="javascript:changeCurrency(\'THB\',\''+e_Center+'\',\''+pid+'\');">THB</a> | <a href="javascript:changeCurrency(\'USD\',\''+e_Center+'\',\''+pid+'\');">USD</a></td>';
	str += '		</tr>';
	str += '		<tr valign="top" height="20">';
	str += '			<td align="left" colspan="2">';
	str += '				<div class="scroll"><span id="pd_color_'+index+'"></span></div>';
	str += '			</td>';
	str += '		</tr>';
	str += '		<tr valign="top" height="20">';
	str += '			<td align="left" colspan="2"><font class="bodygray11">Choose Size : </font><span id="pd_size_'+index+'"></span></td>';
	str += '		</tr>';
	str += '		<tr valign="top" height="20">';
	str += '			<td align="left" colspan="2"><font class="bodygray11">Unit Price : <span id="sp_pd_price_'+index+'"></span>&nbsp;<span id="sp_unit_currency_'+index+'"></span></font></td>';
	str += '		</tr>';
	str += '		<tr valign="top" height="20">';
	str += '			<td align="left" colspan="2"><font class="bodygray11">Promotion Price : <span class="style2" id="sp_pd_price_discount_'+index+'"></span>&nbsp;<span id="sp_pd_currency_'+index+'"></span></font></td>';
	str += '		</tr>';
	str += '		<tr valign="top" height="20">';
	str += '			<td align="left" colspan="2"><font class="bodygray11">Color : <span id="sp_pd_color_'+index+'"></span></font></td>';
	str += '		</tr>';
	str += '		<tr valign="top" height="20">';
	str += '			<td align="left" colspan="2"><font class="bodygray11">Barcode : <span id="sp_pd_barcode_'+index+'"></span></font></td>';
	str += '		</tr>';
	str += '		<tr valign="top" height="20">';
	str += '			<td align="left" colspan="2"><font class="bodygray11">Quantity : <input name="txtquantity_'+index+'" type="text" class="text-field1" size="2" onKeyPress="cNt()" value="1">&nbsp;&nbsp;Pc.</font></td>';
	str += '		</tr>';
	
	str += '		<tr>';
	str += '			<td align="center" colspan="2"><a href="javascript:add_to_cart('+index+');"><img src="images/button_5641_f01.gif" width="158" height="26" border="0"></a></td>';
	str += '		</tr>';

	str += '<input type="hidden" name="txtprice_'+index+'" value="'+discountprice+'">';
	str += '<input type="hidden" name="txtprice_us_'+index+'" value="'+price_unit+'">';
	str += '<input type="hidden" name="product_'+index+'" value="'+pid+'">';

	str += '	</table>';
	
	$(e_Detail).innerHTML = str;

	viewProductColor(gp_color,e_Center);
	viewProductSize(pid,e_Center);
	viewProduct(index,price,discountprice,price_unit,color,barcode);
}

//viewProduct
function viewProduct(i,price,discountprice,price_unit,color,barcode){
	$('sp_pd_price_'+i).innerHTML = format(price,2);
	$('sp_pd_price_discount_'+i).innerHTML = format(discountprice,2);
	$('sp_unit_currency_'+i).innerHTML = price_unit;
	$('sp_pd_currency_'+i).innerHTML = price_unit;
	$('sp_pd_color_'+i).innerHTML = color;
	$('sp_pd_barcode_'+i).innerHTML = barcode;
}

//viewProductColor
function viewProductColor(id,e_Center) {
	var url = 'service/product_gp_color_new.php';	
	var pars = "gp_id="+ id +"&location=0";

	var myAjax = new Ajax.Request( url,
		{
			method: 'get',
			parameters: pars,
//			onLoading: showLoad('pd_color_'+i,'<img src="../images/loading.gif" width=30 height=30>'),
			onComplete: function (t){pdcolorResponse(t,e_Center)},
//			onComplete: pdcolorResponse,
			onFailure: showFail
		} 
	);
}

function pdcolorResponse (request,e_Center) {
	var xml = request.responseXML;
	var elements = xml.documentElement.getElementsByTagName('item');
//alert(request.responseText);
	// get data
	var pxml = new ParserXML();
	pxml.parserdata(elements);
	var a = pxml.result;
	
	// render data
	var str = '';
	index = getIndex($(e_Center).id);

	for (count = 0; count < a.length; count++){
		product_id = a[count]['product_id'];
		pic4 = a[count]['pic4'];
		pic1 = a[count]['pic1'];
//		str +='<img src="'+img_path+pic4+'" width="25" height="25" border="1" style="border-color:#FFFFFF;" onClick="viewImg(\''+ product_id +'\',\''+ i +'\');">';
		str +='<a href="javascript:viewImg(\''+ product_id +'\',\''+ e_Center +'\');"><img src="'+img_path+pic4+'" width="25" height="25" border="1" style="border-color:#FFFFFF;"></a>';
		
		if((count==6)||(count==13)||(count==20)||(count==27)||(count==34)||(count==41)||(count==48)||(count==55))
		{str+='<br>';}
	}
	
	if(a.length>0){
		$('pd_color_'+index).innerHTML= str ;
	}else{
		$('pd_color_'+index).innerHTML= '<font color="#000000">-</font>';
	}
}

//viewProductSize
function viewProductSize(id,e_Center) {
	var url = 'service/product_gp_size.php';	
	var pars = "id="+id;

	var myAjax = new Ajax.Request( url,
		{
			method: 'get',
			parameters: pars,
//			onLoading: showLoad('pd_size_'+i,'<img src="../images/loading.gif" width=25 height=25>'),
			onComplete: function (t){pdsizeResponse(t,id,e_Center)},
//			onComplete: pdsizeResponse,
			onFailure: showFail
		} 
	);
}

function pdsizeResponse (request,id,e_Center) {
	var xml = request.responseXML;
	var elements = xml.documentElement.getElementsByTagName('item');

	// get data
	var pxml = new ParserXML();
	pxml.parserdata(elements);
	var a = pxml.result;

	// render data
	var str = '<select name="xx" class="text-field1" onchange="viewProductPrice(this.value,\''+ e_Center +'\')">';
//	str += '<option value="">by size</option>';
	str += '';

	for (count = 0; count < a.length; count++){		
		product_id = a[count]['product_id'];
		product_size = a[count]['size'];

		str +='<option value="'+ product_id +'"';
		if(product_id==id){str+=' selected="selected" '}
		str+='>'+ product_size +'</option>';
	}

	index = getIndex($(e_Center).id);
	if(a.length>0){
		$('pd_size_'+index).innerHTML= str + '</select>';
	}else{
		$('pd_size_'+index).innerHTML= '<font color="#000000">-</font>';
	}
}

//list price
function viewProductPrice(id,e_Center) {
	var url = 'service/product_gp_size_new.php';	
	var pars = "id="+id;

	var myAjax = new Ajax.Request( url,
		{
			method: 'get',
			parameters: pars,
			onLoading: showLoad('sp_pd_price_discount','<img src="../images/loading.gif" width=25 height=25>'),
			onComplete: function (t){pdPriceResponse(t,id,e_Center)},
			onFailure: showFail
		} 
	);
}

function pdPriceResponse (request,id,e_Center) {
	var xml = request.responseXML;
	var elements = xml.documentElement.getElementsByTagName('item');

	// get data
	var pxml = new ParserXML();
	pxml.parserdata(elements);
	var a = pxml.result;

	index = getIndex($(e_Center).id);

	var barcode = a[0]['barcode'];
	var gp_color = a[0]['gp_id'];
	var color = a[0]['color'];
	product_name = a[0]['product_name_en'];
	design = a[0]['design_name'];
	pic1 = a[0]['pic1'];	
	pic2 = a[0]['pic2'];	
	pic3 = a[0]['pic3'];	

	// check discount
	discount = a[0]['discount'];
	discount_type = a[0]['discount_type'];
	discount_collection = a[0]['discount_collection'];

	if(isNaN(discount)){
		discount=0;
	}			
	if(isNaN(discount_type)){
		discount_type=0;
	}			
	if(isNaN(discount_collection)){
		discount_collection=0;
	}
	
	_discount = 0;
	if (discount>discount_type){
		if(discount>discount_collection){
			_discount = discount;
		}else{
			_discount = discount_collection;
		}
	}else{
		if(discount_type>discount_collection){
			_discount = discount_type;
		}else{
			_discount = discount_collection;
		}
	}	

	// check display price THB or USD
	price = a[0]['price'];
	th_price = a[0]['price'];
	us_price = Math.ceil( (parseFloat(price) / parseFloat(_usd)) );

	if (parseInt(_discount)>0){
		th_discount_price = Math.ceil (th_price - ((th_price * _discount)/100));
		us_discount_price = Math.ceil (us_price - ((us_price * _discount)/100));				
	}else{
		th_discount_price =Math.ceil( th_price );
		us_discount_price =Math.ceil( us_price );
	}

	$('product_'+index).value = id;
	$('dv_product_name').innerHTML = product_name;
	$('txtprice_'+index).value = th_discount_price;
	$('txtprice_us_'+index).value = us_discount_price;
		
	if(getCookie("excCurrency")=="THB" || getCookie("excCurrency")=="" || getCookie("excCurrency")==null ){
		viewProduct(index,th_price,th_discount_price,"THB",color,barcode);
	}else{
		viewProduct(index,us_price,us_discount_price,"USD",color,barcode);
	}
	
	$(e_Center).innerHTML = '<div class="collection_pic"><br><br><br><a href="javascript:product_popup(\''+ product_name +'\',\''+ design +'\',\''+ color +'\',\''+ pic2 +'\',\''+ pic3 +'\');""><img src="'+img_path+pic1+'" border="0" alt="Click to see more image" /></a></div>';
	
	viewProductColor(gp_color,e_Center);
}

//Switch Image
function viewImg(id,e_Center) {
	var url = 'service/product_switch_img.php';
	var pars = "id="+id;

	var myAjax = new Ajax.Request( url,
		{
			method: 'get',
			parameters: pars,
//			onLoading: showLoad('pd_img','<img src="../images/loading.gif">'),
			onComplete: function (t){pdImgResponse(t,e_Center)},
			onFailure: showFail
		} 
	);
}

function pdImgResponse (request,e_Center) {
	
	var xml = request.responseXML;
	var elements = xml.documentElement.getElementsByTagName('item');

	// get data
	var pxml = new ParserXML();
	pxml.parserdata(elements);

	var a = pxml.result;

	product_id = a[0]['product_id'];
	product_name = a[0]['product_name_en'];
	design = a[0]['design_name'];
	pic1 = a[0]['pic1'];
	pic2 = a[0]['pic2'];
	pic3 = a[0]['pic3'];
	color = a[0]['color'];
	barcode = a[0]['barcode'];

	index = getIndex($(e_Center).id);
	$('product_'+index).value = product_id;

	viewProductPrice(product_id,e_Center);
	viewProductSize(product_id,e_Center);
	SetImg(pic1,pic3,color,barcode,e_Center);
	
	$(e_Center).innerHTML = '<div class="collection_pic"><br><br><br><a href="javascript:product_popup(\''+ product_name +'\',\''+ design +'\',\''+ color +'\',\''+ pic2 +'\',\''+ pic3 +'\');""><img src="'+img_path+pic1+'" border="0" alt="Click to see more image" /></a></div>';

}

//SetImg
function SetImg(pic,pic3,color,barcode,e_Center){
	index = getIndex($(e_Center).id);
	$('sp_pd_barcode_'+index).innerHTML = barcode;
	$('sp_pd_color_'+index).innerHTML = color;

	$(e_Center).innerHTML = '<div class="collection_pic"><br><br><br><img src="'+img_path+pic1+'" border="0" /></div>';
}

//Calculate window
var pageProps = {
	 getBrowserW: function(){

		browserWidth = document.body.clientWidth;

		if(browserWidth < 970)
			browserWidth = 970;
			
		return browserWidth;
	},

	getContentW: function(count){
		
//		contentWidth = ((count * 350));
		contentWidth = ((count * 850));

		return contentWidth;										
	}	

}

//Resize Browser
function resetBrowserW(items_collection){

	var browserWidth = document.body.clientWidth ? document.body.clientWidth : window.innerWidth;
	if(browserWidth < 970){
		browserWidth = 970;

		$('left').style.left = 40+'px';
		$('track').style.left = (40+16)+'px';
		$('track').style.width = (970-(40*4)-16-16)+'px';
		$('drag').style.left = $('track').style.left;
		$('img_track').style.width = $('track').style.width;
		$('right').style.left = (970-(40*3)-12)+'px';
	}else{
		var n = (((pageProps.getBrowserW()-970)/2) + 40);

		$('left').style.left = (parseInt(n) + 40)+'px';
		$('track').style.left = (parseInt(n) + 40 + 16)+'px';
		$('drag').style.left = $('track').style.left;
		$('track').style.width = (browserWidth - ((parseInt(n) + 40 + 16)*2))+'px';
		$('img_track').style.width = $('track').style.width
		$('right').style.left = (browserWidth - parseInt(n) - 40 - 12)+'px';
	}

	$('browserMask').style.clip = 'rect(0px,'+pageProps.getBrowserW()+'px, 400px, 0px)';
	$('browserMask').style.width = pageProps.getBrowserW()+'px';
	$('productbrowser').style.width = pageProps.getContentW(items_collection)+'px';
	
	initScroll();
}

//InitScroll
function initScroll(){
	var	n = $('img_track').style.width.length;
	var trackWidth = $('img_track').style.width.substring(0,n-2);	

// speed, dragwidth, trackWidth, trackObj, upObj, downObj, dragObj, contentMaskObj, contentObj
	myScroll = new ScrollObj(6,19,trackWidth,"track","left","right","drag","browserMask","productbrowser");
}

//list Special Feature
function Special_Feature(sp){

	var arr_sp_feature = sp.split(","); 
	var str = '';
	var page = '';
	var alt = '';

	for(i=0;i+1<arr_sp_feature.length;i++){
	
		switch(arr_sp_feature[i]){
			case "01":
				alt = '100%&nbsp;Cotton';
				str += '<img src= images/sp_'+ arr_sp_feature[i] +'.gif border="1" width="30" height="30" style="border-color:#FFFFFF;" alt='+ alt  +'>&nbsp;';
				break;
			case "02":
				page = 'sofin.php';
				alt = 'Finest&nbsp;and&nbsp;softest&nbsp;quality&nbsp;from&nbsp;Micro&nbsp;fiber&nbsp;&quot;Sofin&quot;';
				str += '<a href="javascript:ViewSpecialFeature(\''+page+'\');">';
				str += '<img src= images/sp_'+ arr_sp_feature[i] +'.gif border="1" width="30" height="30" style="border-color:#FFFFFF;" alt='+ alt ;	
				str += '>&nbsp;</a>';
				break;
			case "03":
				page = 'formaldehyde.php';
				alt = 'Formaldehyde&nbsp;Free&nbsp;for&nbsp;health&nbsp;concern';
				str += '<a href="javascript:ViewSpecialFeature(\''+page+'\');">';
				str += '<img src= images/sp_'+ arr_sp_feature[i] +'.gif border="1" width="30" height="30" style="border-color:#FFFFFF;" alt='+ alt ;	
				str += '>&nbsp;</a>';
				break;
			case "04":
				page = 'sanitized.php';
				alt = 'Free&nbsp;from&nbsp;germs&nbsp;and&nbsp;dust&nbsp;mites&nbsp;with&nbsp;the&nbsp;application&nbsp;of&nbsp;Sanitized';
				str += '<a href="javascript:ViewSpecialFeature(\''+page+'\');">';
				str += '<img src= images/sp_'+ arr_sp_feature[i] +'.gif border="1" width="30" height="30" style="border-color:#FFFFFF;" alt='+ alt ;	
				str += '>&nbsp;</a>';
				break;
			case "05":
				alt = 'Enhanced&nbsp;absorbency&nbsp;by&nbsp;Hydrophilic&nbsp;finishfor&nbsp;comfort&nbsp;and&nbsp;dry&nbsp;feel';
				str += '<img src= images/sp_'+ arr_sp_feature[i] +'.gif border="1" width="30" height="30" style="border-color:#FFFFFF;" alt='+ alt  +'>&nbsp;';
				break;
			case "06":
				alt = 'High&nbsp;density&nbsp;jacquard&nbsp;weaving&nbsp;for&nbsp;fine&nbsp;touch&nbsp;and&nbsp;elegance';
				str += '<img src= images/sp_'+ arr_sp_feature[i] +'.gif border="1" width="30" height="30" style="border-color:#FFFFFF;" alt='+ alt  +'>&nbsp;';
				break;
			case "07":
				alt = 'Easy&nbsp;care&nbsp;with&nbsp;our&nbsp;durable&nbsp;press&nbsp;finish&nbsp;Eliminating&nbsp;the&nbsp;need&nbsp;to&nbsp;iron';
				str += '<img src= images/sp_'+ arr_sp_feature[i] +'.gif border="1" width="30" height="30" style="border-color:#FFFFFF;" alt='+ alt  +'>&nbsp;';
				break;
			case "08":
				alt = 'Anti&nbsp;Slip&nbsp;prevents&nbsp;from&nbsp;any&nbsp;damage&nbsp;might&nbsp;be&nbsp;occurred';
				str += '<img src= images/sp_'+ arr_sp_feature[i] +'.gif border="1" width="30" height="30" style="border-color:#FFFFFF;" alt='+ alt  +'>&nbsp;';
				break;
			case "09":
				alt = 'Anti&nbsp;spill&nbsp;property:&nbsp;prevent&nbsp;you&nbsp;any&nbsp;spill&nbsp;from&nbsp;any&nbsp;liquid&nbsp;such&nbsp;as&nbsp;wine,&nbsp;water,&nbsp;etc.';
				str += '<img src= images/sp_'+ arr_sp_feature[i] +'.gif border="1" width="30" height="30" style="border-color:#FFFFFF;" alt='+ alt  +'>&nbsp;';
				break;
			case "10":
				alt = 'Machine&nbsp;Washable';
				str += '<img src= images/sp_'+ arr_sp_feature[i] +'.gif border="1" width="30" height="30" style="border-color:#FFFFFF;" alt='+ alt  +'>&nbsp;';
				break;
			case "11":
				page = 'energy_saving.php';
				alt = 'Energy&nbsp;Saving&nbsp;Curtain';
				str += '<a href="javascript:ViewSpecialFeature(\''+page+'\');">';
				str += '<img src= images/sp_'+ arr_sp_feature[i] +'.gif border="1" width="30" height="30" style="border-color:#FFFFFF;" alt='+ alt ;	
				str += '>&nbsp;</a>';
				break;

			default:break;
		}	
	}
	return str;
}

function ViewSpecialFeature(page){
	theURL = 'http://www.pasaya.com/onlineshop/e-shopping/ecatalog/'+page;
	winName = '';
	features = 'menubar=0, toolbar=0, location=1, scrollbars=1, status=0, resizable =1,width=900, height= 375’';
	
	MM_openBrWindow(theURL,winName,features);
//	top.location.href='http://<?=$_SERVER['HTTP_HOST']?>\/productshowcase/specialfeature.php';
}

function changeCurrency(n,index,pid){
	setCookie("excCurrency",n);
	viewProductPrice(pid,index);
	render_cart();
}
function add_to_cart(index){
	quantity = $('txtquantity_'+index).value;
	if(quantity!=''){
		price = $('txtprice_'+index).value;
		price_us = $('txtprice_us_'+index).value;
		id = $('product_'+index).value;

		select_product_detail(id,price,price_us,quantity);
	}
}
function product_popup(n1,n2,n3,n4,n5){
	theURL = 'ecatalog/product_popup.php?n1='+ n1 +'&n2='+ n2 +'&n3='+ n3 + '&n4='+ n4 +'&n5='+ n5;
	winName = '';
	features = 'scrollbars=yes,width=720,height=400';
	
	MM_openBrWindow(theURL,winName,features);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function setInsriation(data,index){
	TempInsriation[index]=data;
}
function getInsriation(index){
	return TempInsriation[index];
}
function set(data,index){
	TempData[index]=data;
}
function get(index){
	return TempData[index];
}
function getIndex(str){
var i;
	ChCode = str.charAt(str.length - 2);
	ChCode = ChCode.charCodeAt();
	if((ChCode < 48) || (ChCode > 57)) {i=1;} else {i=2;}
	index = str.substr((str.length - i),i);
	return 	index;
}