// *************************************************
// URL and Text array ******************************
// use below to populate the quicklinks menu dynamically. use a pipe to split the url that comes first with the text that comes second and if there is a smalllogo then that is third with the name of it.
var pggwrightsonLinks = new Array()
pggwrightsonLinks[0] = "http://www.agrifeeds.co.nz|Agri-feeds|agrifeeds.jpg"
pggwrightsonLinks[1] = "http://www.pggwrightson.co.nz/wrightson-services/agriculture-nz.html|Agriculture NZ - Training Courses|AgNZ.jpg"
pggwrightsonLinks[2] = "http://www.pggwrightson.co.nz/business-services/consulting-.html|Consulting|pggwfavicon.gif"
pggwrightsonLinks[3] = "http://www.fruitfed.co.nz|Fruitfed Supplies|fruitfed.jpg"
pggwrightsonLinks[4] = "http://www.pggwrightson.co.nz/wrightson-services/insurance.html|Insurance|pggwfavicon.gif"
pggwrightsonLinks[5] = "http://www.pggwrightson.co.nz/business-services/finance.html|Finance|pggwfavicon.gif"
pggwrightsonLinks[6] = "http://www.pggwrightson.co.nz/wrightson-services/irrigation.html|Irrigation|pggwfavicon.gif"
pggwrightsonLinks[7] = "http://www.pggwrightson.co.nz/business-services/kelso.html|Kelso|kelsosmall.jpg"
pggwrightsonLinks[8] = "http://www.pggwrightson.co.nz/wrightson-services/livestock/search-livestock.html|Livestock|pggwfavicon.gif"
pggwrightsonLinks[9] = "http://www.pggwre.co.nz/|Realestate|pggwfavicon.gif"
pggwrightsonLinks[10] = "http://www.pggwrightson.co.nz/business-services/research-and-development.html|Research and Development|pggwfavicon.gif"
pggwrightsonLinks[11] = "http://rewards.pggwrightson.co.nz/|Rewards points|pggwfavicon.gif"
pggwrightsonLinks[12] = "http://www.pggwrightson.co.nz/wrightson-services/rural-supplies/store-locations.html|Rural Supplies - Store locations|pggwfavicon.gif"
pggwrightsonLinks[13] = "http://www.pggwrightson.co.nz/pgg-wrightson-services/seeds.html|Seeds|pggwfavicon.gif"
pggwrightsonLinks[14] = "http://www.pggwrightson.co.nz/pgg-wrightson-services/standardbred.html|Standardbred|pggwfavicon.gif"
pggwrightsonLinks[15] = "http://www.agonline.co.nz|AgOnline|agonlinefavicon.gif"
pggwrightsonLinks[16] = "http://www.pggwrightson.co.nz/wrightson-services/wool.html|Wool|pggwfavicon.gif"


//pggwrightsonLinks[2] = "https://account.pggw.co.nz/pgginternet/RP.jasc?Page=Home|Online Banking|pggwfavicon.gif"
//pggwrightsonLinks[3] = "http://rewards.pggw.co.nz|Rewards|pggwfavicon.gif"
//pggwrightsonLinks[4] = "http://www.newzealanddeer.co.nz|Deer|pggwfavicon.gif"
//pggwrightsonLinks[5] = "http://www.pggwrightson.co.nz/wrightson-services/rural-supplies/store-locations.html|Store Locations|pggwfavicon.gif"
//pggwrightsonLinks[6] = "http://www.pggw.com.au|Livestock - Australia|pggwfavicon.gif"
//pggwrightsonLinks[7] = "http://www.pggwre.com.au/search.cfm?country=aus&action=results|Real Estate - Australia|pggwfavicon.gif"

var otherLinks = new Array()
//otherLinks[0] = "http://www.agricom.co.nz|Agricom|agricomfavicon.gif"
//otherLinks[1] = "http://www.fruitfed.co.nz|Fruitfed Supplies|"
otherLinks[2] = "http://www.nzfsu.co.nz|New Zealand Farming Systems Uruguay|nzfsufavicon.jpg"
//otherLinks[3] = "http://www.pggseeds.com|PGG Seeds|pggseedsfavicon.gif"
// *************************************************
// Config variables *******************************
var imagePath = "http://www.pggw.co.nz/_misc/quicklinks/"
var quicklinksDivWidth = 220;
var growthSpeed = 5;
var growthWidth = 10;
var growthHeight = 25;
var hideDelaySpeed = 1000;
// *************************************************


var t; // sets variable up for use in setTimeout variable later

// functions **************************************************
function show(){ //show quick links div
    document.getElementById("quicklinksDiv").style.display="block";
    growDiv();
    clearTimeout(t);
}
function hide(){ //hide quick links div with 2 second delay
    t = setTimeout("resizeDiv();document.getElementById('quicklinksDiv').style.display='none';", hideDelaySpeed);        
}

function growDiv(){ // animation for growing the div with links on it
  if (parseInt(document.getElementById("quicklinksDiv").style.width) < quicklinksDivWidth){
    document.getElementById("quicklinksDiv").style.width = parseInt(document.getElementById("quicklinksDiv").style.width) + growthWidth + 'px';
    document.getElementById("quicklinksDiv").style.height = parseInt(document.getElementById("quicklinksDiv").style.height) + growthHeight + 'px';
    setTimeout("growDiv();", growthSpeed);
  }
}
function resizeDiv(){ // resets the grown div back to 0 width and height onmouseout
    document.getElementById("quicklinksDiv").style.width = 0;
    document.getElementById("quicklinksDiv").style.height = 0;
}

function changeStateOvaDiv(obj){ //onmouseover state
    // chages css styles for quick links divs
    obj.style.border="solid 1px #ffffff";  
    obj.style.backgroundColor="#C6E1FF"; 

    // changes css styles for a tags within quick link divs
    var innerObj = obj.childNodes[0];    
    innerObj.style.color="#ffffff"; 
    innerObj.style.textDecoration="none"; 
}
function changeStateOffDiv(obj){ // onmouseout state
    // chages css styles for quick links divs
    obj.style.border="solid 1px #ffffff";
    obj.style.backgroundColor="#F3F8FF";
    
    // changes css styles for a tags within quick link divs
    var innerObj = obj.childNodes[0];
    innerObj.style.color="#999999";
    innerObj.style.textDecoration="none";  
}

function navigate(url){ // onmouseout state
    parent.location.href=url;
}
// ************************************************************



// quick links floating div and title
document.write("<table id='quicklinks' cellpadding='0' cellspacing='0' onmouseover='show()' onmouseout='hide()' style='background-color:#ededed; position:absolute; top:0px; right:0px; padding:3px; cursor:hand; filter:alpha(opacity=96); -moz-opacity:.96; opacity:.96;' border='0'><tr><td style=' font-size:10px; font-family:arial; color:#000000;'>");
    document.write("<img src='http://www.pggw.co.nz/_misc/quicklinks/down-arrows.gif' /> Quick Links");
document.write("</td></tr></table>");
//************************************

// floating div with links
document.write("<div id='quicklinksDiv' onmouseover='show()' onmouseout='hide()' style='z-index:20000; white-space:nowrap; overflow:hidden; display:none; position:absolute; top:18px; right:0px; width:0; height:0; background-color:#ededed; padding:5px; filter:alpha(opacity=96); -moz-opacity:.96; opacity:.96;'>");
    document.write("<span style='font-weight:bold; font-size:10px; font-family:arial; color:#000000;'>PGG Wrightson - Business Services</span>");
    // pgg wrightson links
    for (x in pggwrightsonLinks){
        x = pggwrightsonLinks[x].split("|");        
        document.write("<div onClick=navigate('" + x[0] + "') onmouseover='changeStateOvaDiv(this)' onmouseout='changeStateOffDiv(this)' style='border:solid 1px #ffffff; padding:3px; margin:2px; background-color:#F3F8FF; cursor:hand;'>");
            document.write("<a href='" + x[0] + "' style='color:#999999; text-decoration:none; font-size:10px; font-family:arial;' target='_parent'>")
                if(x[2].length > 1){
                    document.write("<img src='" + imagePath + x[2] + "' border='0' />&nbsp;");
                }    
                document.write(x[1]);
            document.write("</a>");
        document.write("</div>");
    } 
    
    // other links
    document.write("<br/><span style='font-weight:bold; font-size:10px; font-family:arial; color:#000000;'>Other</span>");
    for (x in otherLinks){
        x = otherLinks[x].split("|");        
        document.write("<div onClick=navigate('" + x[0] + "') onmouseover='changeStateOvaDiv(this)' onmouseout='changeStateOffDiv(this)' style='border:solid 1px #ffffff; padding:3px; margin:2px; background-color:#F3F8FF; cursor:hand;'>");
            document.write("<a href='" + x[0] + "' style='color:#999999; text-decoration:none; font-size:10px; font-family:arial;' target='_parent'>")
                if(x[2].length > 1){
                    document.write("<img src='" + imagePath + x[2] + "' border='0' />&nbsp;");
                }    
                document.write(x[1]);
            document.write("</a>");
        document.write("</div>");
    }   
    // ***************************
document.write("</div>");