




//*********************************
//***** Group, Type non-tab
//*********************************

function writeImageTag(imgurl) {
	writeImageTag(imgurl,null,null);
}
function writeImageTag(imgurl,alt) {
	writeImageTag(imgurl,alt,null);
}
function writeImageTag(imgurl,alt,gourl) {
	document.write('<img src="' + imgurl + '" ');
	if(alt!=null   && alt!=""   && alt!="undefined")		document.write(' alt="' + alt + '" ');
	if(gourl!=null && gourl!="" && gourl!="undefined")	document.write(' onClick="javascript:location.href=\'' + gourl + '\'" style="cursor:pointer;" ');
	document.write(' />');
}





//*********************************
//***** Type Tab style 
//*********************************

function writeTabImage(num,imgurl,alt) {
	writeTypeImage(num,imgurl,alt,null);
}
function writeTabImage(num,imgurl,alt,gourl) {
	document.write(' <div id="type_image' + num + '" class="type_image" ');
	document.write(' style="background-image:url(\'' + imgurl + '\');" ');
	document.write(' title="' + alt + '" ');
	if(gourl!=null && gourl!="") document.write(' onClick="location.href=\'' + gourl + '\'" style="cursor:pointer;" ');
	document.write(' >&nbsp;</div> ');
}
function toggle_lowband_type(va,all) {
	// initialize
	for(i=1;i<=all;i++) {
		viewlayer('type_image'+i,'off');
		document.getElementById('type_li'+i).className="off";
	}
	// tab select on/off
	document.getElementById('type_image'+va).style.display="block";
	document.getElementById('type_li'+va).className="on";
}




//*********************************
//***** Detail , Gallery 
//*********************************

function chg_lowband_img(n) {
	var str = "image"+n;
	document.getElementById("gallery_lowband").style.backgroundImage = "url('"+ imagesrc[n] +"')";
	gallerynum = n;
}
function prev_img() {
	var cnt = gallerynum-1;
	if(cnt < 0 ) cnt=imagecnt-1;
	if(cnt != gallerynum) chg_lowband_img(cnt);
}
function next_img() {
	var cnt = gallerynum+1;
	if(cnt >= imagecnt) cnt=0;
	if(cnt != gallerynum) chg_lowband_img(cnt);
}
function initialize(n) {
	imagecnt = n;
	gallerynum = -1;
	chg_lowband_img(0);
}



//*********************************
//***** Related Product 
//*********************************

function chg_related_img(cnt) {
	relatednum = cnt;

	//imgurl,alt,gourl
	imgurl = related_img[cnt];
	alt = related_pronm[cnt];
	gourl = related_linkurl[cnt];

	//make string
	var tmpstr;
	tmpstr =								  '<img src="' + imgurl + '" ';
	if(alt!=null   && alt!="")		tmpstr += ' alt="' + alt + '" ';
	if(gourl!=null && gourl!="")	tmpstr += ' onClick="javascript:location.href=\'' + gourl + '\'" style="cursor:pointer;" ';
	tmpstr +=								  '  />';
	tmpstr +=								  '<br /><strong>'+ alt +'</strong>';

	//change html
	document.getElementById("relatedpdt").innerHTML = tmpstr;
}
function prev_rel() {
	var cnt = relatednum-1;
	if(cnt < 0 ) cnt=relatedcnt-1;
	if(cnt != relatednum) chg_related_img(cnt); 
}
function next_rel() {
	var cnt = relatednum+1;
	if(cnt >= relatedcnt) cnt=0;
	if(cnt != relatednum) chg_related_img(cnt); 
}
function related_initialize() {
	relatednum = -1;
	chg_related_img(0); // choose a item for viewing.
}
function add_related_item(n,img,pronm,linkurl) {
	related_img[n] = img;
	related_pronm[n] = pronm;
	related_linkurl[n] = linkurl;
	relatedcnt++;
}
