// Image Switcher >>>> /* Victor Bauer - 18/12/2009 */

function imageSwitch(comp, img){

	var source = "imagens/"+img+".jpg";

	if(comp != "2"){
		$("#outViewer_One").attr({src: source});
	}else {
		$("#outViewer_Two").attr({src: source});
	}
}


/**
 * @author victorbauer
 */

function loadXMLDoc(docname){
	
	docname = 'http://' + location.host + docname
	xmlDoc = null
    try 
    {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async = false;
        xmlDoc.load(docname);
    } 
    catch (e) {
        try 
        {
            //xmlDoc = documento.implementation.createDocument("", "", null);
			var xmlhttp = new window.XMLHttpRequest();
			xmlhttp.onreadystatechange = function(e){
				if(xmlhttp.readyState==4 || xmlhttp.readyState=='complete')
				{
					if(xmlhttp.status==200)
						xmlDoc = xmlhttp.responseXML
					else
						erro({message:'Erro ao carregar XML'})
				}
			}
			xmlhttp.open("GET", docname, true);
			xmlhttp.send(null);
        } 
        catch (e) { return erro(e) }
    }
	
    return xmlDoc
	
	
	function erro(e)
	{
		if(location.host.indexOf('svr_devjava')!=-1)
			alert(e.message)
		$(
		function()
		{
			$('.vitrine .quickView').css({display:'none'})
		})
		return null
	}
}


function setQuickView(id){

var qId = parseInt(id) - 1;
var shortTitle = xmlDoc.getElementsByTagName("shortTitle")[qId].childNodes[0].nodeValue;
var pathImg = xmlDoc.getElementsByTagName("pathImg")[qId].childNodes[0].nodeValue;
var altImg = xmlDoc.getElementsByTagName("altImg")[qId].childNodes[0].nodeValue;
var title = xmlDoc.getElementsByTagName("title")[qId].childNodes[0].nodeValue;
var linkCom = xmlDoc.getElementsByTagName("linkCom")[qId].childNodes[0].nodeValue;

	$('#blackOut').css({display: 'block'});
	$('#blackOut').fadeTo("slow", 0.6);
	$('#quickView').fadeIn(800);
	$('#shortTitle').text(shortTitle);
	$('#imgLink').attr({href: linkCom});
	$('#QImage').attr({src: pathImg, alt: altImg});
	$('#QTitle').text(title);
	$('#QBtComprar').attr({href: linkCom});
	$('#goDetails').attr({href: linkCom});
	
	var items = xmlDoc.getElementsByTagName("descricao")[qId].getElementsByTagName("item")
	for(i=0; i<20 && items[i]; i++){
		var noValue = "- "+ items[i].childNodes[0].nodeValue;
		var lista = "<li>"+noValue+"</li>";
		$("#list").append(lista);	
	}
	
	// IE6 Posicionamento
	if(navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1)
	{
		var top = Math.floor(document.documentElement.scrollTop)
			top += Math.floor(screen.availHeight/2)
			top -= Math.floor($('#quickView')[0].offsetHeight/2)
		$('#quickView').css({'position':'absolute'})
		$('#quickView').css({'top':top+'px'})
	}
}

function lightStart(alt,src,width,height){
	$('#blackOut').css({display: 'block'});
	$('#blackOut').fadeTo("slow", 0.6);
	$('#lightBox').fadeIn(800);
	$('#viewer').attr({
		alt: alt,
		src: src,
		width: width,
		height: height
	});
};

function lightSwitch(alt,src,width,height){
	$('#viewer').attr({
		alt: alt,
		src: src,
		width: width,
		height: height
	});
};

function lightStop(){
	$('#lightBox').fadeOut("fast");
	$('#quickView').fadeOut("fast");
	$('#blackOut').fadeOut(20);
	$("#list,#thumbs").empty();
};

