// JavaScript Document
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function getStyle(el)
{
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle['backgroundImage'];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue('background-image');
	return y;
}

function thumbOn(id, img) {
	document.getElementById('thumb-image' + id).className = 'thumb-active'; 
	document.getElementById('thumb-div' + id).className = 'thumb-img-on'; 
}
function thumbOff(id, img) {
	var myx = getStyle('prod-img');
	var imSrc = Right(myx, 28);
	//alert(imSrc);
	var divSrc = Right('media/'+img, 27);
	if (imSrc !== divSrc+')' && 'm'+imSrc !== divSrc+'")') {
	document.getElementById('thumb-image' + id).className = 'thumb-off'; 
	document.getElementById('thumb-div' + id).className = 'thumb-img'; 
	}
}
function setTech(setid) {
	
}
function setSelect(setid) {
	//alert("here setid is" + setid);
	if (document.getElementById('thumb-image' + setid)) {
	for (i=1;i<=6;i++) {
		var thImage = 'thumb-image' + i;
		if (document.getElementById(thImage) !== null) {
			document.getElementById(thImage).className = 'thumb-off'; 
			document.getElementById('thumb-div' + i).className = 'thumb-img'; 

		}
	}
	document.getElementById('thumb-image' + setid).className = 'thumb-active';
	document.getElementById('thumb-div' + setid).className = 'thumb-img-on'; 
	//alert("hmm" + setid);
	}
}
function thumbGo(img) {
	document.getElementById('prod-img').src = 'media/'+img;
	document.getElementById('prod-link').href = 'media/'+img;
}
function bthumbOn(id, img) {
	document.getElementById('bthumb-image' + id).className = 'b-thumb-active'; 
	document.getElementById('bthumb-image' + id).style.background = 'url(media/th_bot_'+img+') no-repeat -4px -18px'; 
	document.getElementById('bthumb-div' + id).className = 'b-thumb-img-on'; 
	document.getElementById('bthumb-div' + id).style.border = '4px solid #FF9933';
}
function bthumbOff(id, img) {
	document.getElementById('bthumb-image' + id).className = 'b-thumb-off'; 
	document.getElementById('bthumb-image' + id).style.background = 'url(media/th_bot_'+img+') no-repeat 0px -14px'; 
	document.getElementById('bthumb-div' + id).className = 'b-thumb-img'; 
	document.getElementById('bthumb-div' + id).style.border = '0px';
}
function getQuery(query, idz){
        var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'pagez.php?query='; //This is the path to the file we just finished making *
        xmlhttp.open('GET', file + query + '&idz=' + idz, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
        xmlhttp.onreadystatechange=function() {
                if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                        var content = xmlhttp.responseText; //The content data which has been retrieved ***
                        if( content ){ //Make sure there is something in the content variable
                                document.getElementById('prodz-img').innerHTML =  content; //Change the inner content of your div to the newly retrieved content ****
                        }
                }
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
        return;
}
function setTech(query, idz){
        var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'techz.php?query='; //This is the path to the file we just finished making *
        xmlhttp.open('GET', file + query + '&idz=' + idz, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
        xmlhttp.onreadystatechange=function() {
                if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                        var content = xmlhttp.responseText; //The content data which has been retrieved ***
                        if( content ){ //Make sure there is something in the content variable
                                document.getElementById('prod-pdf').innerHTML =  content; //Change the inner content of your div to the newly retrieved content ****
                        }
                }
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
        return;
}