var smallTransparentGif = "";
function fixupIEPNG(strImageID, transparentGif) 
{
    smallTransparentGif = transparentGif;
    if (windowsInternetExplorer && (browserVersion < 7))
    {
        var img = document.getElementById(strImageID);
        if (img)
        {
            var src = img.src;
            img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
            img.src = transparentGif;
            img.attachEvent("onpropertychange", imgPropertyChanged);
        }
    }
}

var windowsInternetExplorer = false;
var browserVersion = 0;
function detectBrowser()
{
    windowsInternetExplorer = false;
    var appVersion = navigator.appVersion;
    if ((appVersion.indexOf("MSIE") != -1) &&
        (appVersion.indexOf("Macintosh") == -1))
    {
        var temp = appVersion.split("MSIE");
        browserVersion = parseFloat(temp[1]);
        windowsInternetExplorer = true;
    }
}

function onPageLoad(){
    detectBrowser();
    fixupIEPNG("id1", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id2", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id3", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id4", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id5", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id6", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id7", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id8", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id9", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id10", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id11", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id12", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id13", "Trade-In Form_files/transparent.gif");
    fixupIEPNG("id14", "Trade-In Form_files/transparent.gif");
    return true;
}

var inImgPropertyChanged = false;
function imgPropertyChanged()
{
    if ((window.event.propertyName == "src") && (! inImgPropertyChanged))
    {
        inImgPropertyChanged = true;
        var el = window.event.srcElement;
        if (el.src != smallTransparentGif)
        {
            el.filters.item(0).src = el.src;
            el.src = smallTransparentGif;
        }
        inImgPropertyChanged = false;
    }
}

function isObsolete(){
	if (document.specs.proc.selectedIndex == 1)
	{
		alert("G3 based systems are no longer considered for purchase. Please look in to donating your system to a local charity such as azstrut.org.");
		document.specs.proc.selectedIndex = 0;
	}
	if (document.specs.proc.selectedIndex == 2)
	{
		alert("G4 systems slower than 1GHz are no longer considered for purchase, please only complete the form for machines that are 1GHz or faster.");
	}
}

function checkit() {
	if (document.specs.name.value.length <= 3){
		alert ("Enter your name.");
		document.specs.name.focus();
		return false;
	}		

	  	if ( document.specs.email.value.length <= 6 ){
		alert ("Enter your email address.");
		document.specs.email.focus();
		return false;
	}	

	if ( document.specs.phone.value.length != 12 ){
		alert ("Enter your phone # in the format 480-835-8833.");
		document.specs.email.focus();
		return false;
	}


	if ( (document.specs.sn.value.length >0 ) & (document.specs.sn.value.length !=11 ) & (document.specs.sn.value.length !=18 ) ){
		alert ("Enter the serial number as either 11 or 18 digits. If you do know know your serial number, erase this field and complete the machine specifications section below.");
		document.specs.sn.focus();
		return false;
	}

	if ( ( document.specs.runs[0].checked == false ) & ( document.specs.runs[1].checked == false) & ( document.specs.runs[2].checked == false) ) {
		alert ("Please indicate the operating status of the system.");
		return false;
	}
	
	if ( ( document.specs.looks[0].checked == false ) & ( document.specs.looks[1].checked == false) & ( document.specs.looks[2].checked == false) & ( document.specs.looks[3].checked == false)) {
		alert ("Please indicate the physical condition of the system.");
		return false;
	}

	if  ( document.specs.sn.value.length == 0 ) {
		if ( (document.specs.type.length == 0 ) | (document.specs.proc.length == 0 ) | (document.specs.ram.value.length ==0 ) | (document.specs.speed.length == 0 ) | (document.specs.hd.length ==0 ) | (document.specs.optical.length ==0 ) | (document.specs.screen.length ==0 ) ) {
			alert ("You did not enter a valid serial number, please complete the entire Machine Specifications section.");
			return false;
		}
	}

	if (document.specs.comment.value.length > 2000 ) {
		alert ("We appreciate your zeal, but please shorten your comments to less than 2000 characters. You have entered " + document.specs.comment.value.length + " characters." );
		return false;
	}

	if (document.specs.comment.value.length == 0 ) {
		if ( (document.specs.runs[0].checked == false) | (document.specs.looks[0].checked == false) ) {
			alert ("You have selected issues that require attention for the machine to operate or look new, please list the issues in the commects section.");
		return false;
		}
	}


	if (document.specs.test.value != "yes") {
		alert ("Please select Yes to the question to the left of the submit button.");
		return false;
	}

// This code should eliminate multi-clicking idiots from sending 2, 3 or 4 copies.
// It immediately disables the input button as soon as it is pressed.
	obj=document.getElementById("sendit")
	obj.value="Processing..."
	obj.type="button"
	return true;
}


// Validator script for the contact us form

function check_contact() {
	if (document.contact.name.value.length <= 3){
		alert ("Enter your name.");
		document.contact.name.focus();
		return false;
	}		

	  	if ( document.contact.email.value.length <= 6 ){
		alert ("Enter your email address.");
		document.contact.email.focus();
		return false;
	}	

	if ( document.contact.phone.value.length != 12 ){
		alert ("Enter your phone # in the format 480-835-8833.");
		document.contact.email.focus();
		return false;
	}


	if (document.contact.comment.value.length > 2000 ) {
		alert ("We appreciate your zeal, but please shorten your comments to less than 2000 characters. You have entered " + document.contact.comment.value.length + " characters." );
		return false;
	}

	if (document.contact.comment.value.length < 10 ) {
		alert ("Oops. The cat seems to have your tongue, please type your comments before pressing the send button.");
		document.contact.comment.focus();
		return false;
	}

	if (document.contact.store.value == "") {
		alert ("Please tell us which location you are contacting us about.");
		document.contact.store.focus();
		return false;
	}

	if (document.contact.test.value != "yes") {
		alert ("Please select Yes to the question to the left of the submit button.");
		return false;
	}

// This code should eliminate multi-clicking idiots from sending 2, 3 or 4 copies.
// It immediately disables the input button as soon as it is pressed.
	obj=document.getElementById("sendit")
	obj.value="Processing..."
	obj.type="button"
	return true;
}



function selltradetoggle() {
	obj=document.getElementById("tradenote");
	if (document.specs.selltrade.value == "Trade")
		{ obj.style.display = 'inline'}
	else 
		{ obj.style.display = 'none' }
}


					/***********************************************
					* Show Hint script- Dynamic Drive (www.dynamicdrive.com)
					* This notice MUST stay intact for legal use
					* Visit http://www.dynamicdrive.com/ for this script and 100s more.
					***********************************************/
					var horizontal_offset="0px" //horizontal offset of hint box from anchor link
					/////No further editing needed
					var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
					var ie=document.all
					var ns6=document.getElementById&&!document.all
					function getposOffset(what, offsettype){
					var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
					var parentEl=what.offsetParent;
					while (parentEl!=null){
					totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
					parentEl=parentEl.offsetParent;
					}
					return totaloffset;
					}
					function iecompattest(){
					return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
					}
					function clearbrowseredge(obj, whichedge){
					var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
					if (whichedge=="rightedge"){
					var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
					dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
					if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox

