/* xCartMod.com Dynamic Images 3 */
var acc_main_image_height = 0;
var acc_main_image_width = 0;
var acc_detailed_imgs = [];
var acc_dissolve_timer = 0;
var acc_dissolve_opacity;
var acc_dissolve_id = null;
var acc_opacity_step = 1;
var acc_msie_opacity_step = 3;
var acc_thumb_width = 0;
var acc_thumb_height = 0; 
var acc_switch_timer = 0;
var acc_orig_image_src = '';
var acc_curr_imgid = -1; // ??????

var acc_id = '';

function acc_thumbMouse_Out () {
	if (acc_dissolve_mode == "slow") {
		acc_blendimage('product_thumb_div'+acc_id, 'product_thumbnail'+acc_id, acc_orig_image_src, 1);
	} else {
		acc_switch_timer = setTimeout("acc_switch_back_to_orig()", acc_switch_delay);
	}
}

function acc_switch_back_to_orig() {
	document.getElementById('product_thumbnail'+acc_id).src = acc_orig_image_src;
	if (acc_keep_dimension == 'height') {
    	document.getElementById('product_thumb_div'+acc_id).style.width = acc_main_image_width+"px";
    	document.getElementById('product_thumbnail'+acc_id).width = acc_main_image_width;
	} else if (acc_keep_dimension == 'width') {
    	document.getElementById('product_thumb_div'+acc_id).style.height = acc_main_image_height+"px";
    	document.getElementById('product_thumbnail'+acc_id).height = acc_main_image_height;
	}
	acc_switch_timer = 0;
}

function acc_blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
    
    //make image transparent
    changeOpac(0, imageid);
    
    //make new image
    document.getElementById(imageid).src = imagefile;

	acc_dissolve_opacity = 0;
	acc_dissolve_id = imageid;
	acc_dissolve_timer = setInterval("acc_dissolve_cycle()", millisec);
} 

function acc_dissolve_cycle() {

if (localBrowser == 'MSIE') acc_opacity_step = acc_msie_opacity_step;

	acc_dissolve_opacity += acc_opacity_step;
	acc_changeOpac(acc_dissolve_opacity, acc_dissolve_id);

	if (acc_keep_dimension == 'height') {
		acc_temp_width = (acc_main_image_width-acc_thumb_width)*acc_dissolve_opacity/100+acc_thumb_width; 
    	document.getElementById('product_thumb_div'+acc_id).style.width = acc_temp_width+"px";
    	document.getElementById('product_thumbnail'+acc_id).width = acc_temp_width;
	} else if (acc_keep_dimension == 'width') {
		acc_temp_height = (acc_main_image_height-acc_thumb_height)*acc_dissolve_opacity/100+acc_thumb_height;
		document.getElementById('product_thumb_div'+acc_id).style.height = acc_main_image_height+"px";
    	document.getElementById('product_thumbnail'+acc_id).height = acc_main_image_height;
	}

	if (acc_dissolve_opacity >= 100) {
		clearInterval(acc_dissolve_timer);
		acc_dissolve_timer = 0;
		acc_dissolve_id = null;
	}
} 

//change the opacity for different browsers
function acc_changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

//----------------------------------------
function acc_thumbMouse_Over (imgid, image_x, image_y) {

if (localBrowser == 'MSIE') acc_opacity_step = acc_msie_opacity_step;

	if (acc_dissolve_mode == "slow") {
		if (acc_dissolve_timer != 0) {	
			acc_dissolve_opacity = 100-acc_opacity_step;
			acc_dissolve_cycle();
		}
		document.getElementById('product_thumb_div'+acc_id).style.backgroundImage = "none";
	} else {
		if (acc_switch_timer != 0) {
			clearTimeout(acc_switch_timer);
			acc_switch_back_to_orig();	
		}
	}

	acc_orig_image_src = document.getElementById('product_thumbnail'+acc_id).src; 
	document.getElementById('product_thumbnail'+acc_id).src = acc_detailed_imgs[imgid].src;
	ratio_thumb = image_x/image_y;

	if (acc_keep_dimension == 'height') {
		acc_thumb_width = document.getElementById('product_thumbnail'+acc_id).height*ratio_thumb;
		acc_main_image_width = document.getElementById('product_thumbnail'+acc_id).width;
		document.getElementById('product_thumb_div'+acc_id).style.width = acc_thumb_width+"px";
		document.getElementById('product_thumbnail'+acc_id).width = acc_thumb_width; 
	} else if (acc_keep_dimension == 'width') {
		acc_thumb_height = document.getElementById('product_thumbnail'+acc_id).width/ratio_thumb;
		acc_main_image_height = document.getElementById('product_thumbnail'+acc_id).height;
		document.getElementById('product_thumb_div'+acc_id).style.height = acc_thumb_height+"px";
		document.getElementById('product_thumbnail'+acc_id).height = acc_thumb_height;
	}
}

function acc_thumbMouse_Click (thumb_path, image_x, image_y) {
__image_x = image_x+20;
__image_y = image_y+20;

window.open(thumb_path,'images','width='+__image_x+',height='+__image_y+',toolbar=no,status=no,scrollbars=yes,resizable=no,menubar=no,location=no,direction=no');
}

function acc_thumbMouse_Click2 (imgid, image_x, image_y) {
	if (acc_curr_imgid != -1) {
		document.getElementById('det_thumb_'+acc_curr_imgid).className = "DI_thumbs_onclick";
	}
	acc_curr_imgid = imgid;
	document.getElementById('det_thumb_'+imgid).className = "DI_thumbs_onclick_sel"; 
	acc_thumbMouse_Over (imgid, image_x, image_y);
}

function acc_main_img_click () {
	if (acc_curr_imgid != -1)
		Shadowbox.open(document.getElementById('hidden_img_'+acc_curr_imgid));
}

function acc_load_zoomify_img(imgid) {

    if (document.getElementById('zoomify_div_'+imgid) != null && acc_curr_imgid != imgid) {

		if (document.getElementById('zoomify_div_'+imgid).innerHTML == "empty") {
        	document.getElementById('zoomify_div_'+imgid).innerHTML = acc_zoomify_code[imgid]; 
		}
        document.getElementById('zoomify_div_'+imgid).style.display = '';
        if (acc_curr_imgid != -1) {
            document.getElementById('zoomify_div_'+acc_curr_imgid).style.display = 'none';
			document.getElementById('det_thumb_'+acc_curr_imgid).className = "DI_thumbs_zoomify";
		}
		document.getElementById('det_thumb_'+imgid).className = "DI_thumbs_zoomify_sel";
        acc_curr_imgid = imgid;
    }
}
/* xCartMod.com Dynamic Images 3 */
