var Infoboxes = {
	init : function(){
		$("span.hidden")
                    .before('<a href="#" class="info"><img src="Info+.png" alt="more details" class="infoimage" width="23" height="23"></a>');
		}
	};
        
var H2PrintIcon = {
	init : function(){
//        alert("test");
		$("h2")
                    .append(' <a href="javascript:SwitchPrintable()" style="border:0px"><img id="printicon" src="SunPrinter.png" alt="print mode" width="43" height="40" style="border:0px; vertical-align:text-top; padding-left:10px"></a>');
		}
	};

        

        
function Switchit(elem) {
        if ($(elem).next().css("display")=="none" || $(elem).next().css("display")==""){
            $(elem).next().slideDown();
            $(elem).find("img").attr("src","Info-.png");
            $(elem).find("img").attr("alt","less details");
        }
        else {
            $(elem).next().hide("slow");
            $(elem).find("img").attr("src","Info+.png");
            $(elem).find("img").attr("alt","more details");
        }
};

function ResizeLeftAndRightDiv ()
{
    document.getElementById('backimg').height=document.getElementById('maindiv').offsetHeight+121;
    document.getElementById('picbar').height=document.getElementById('maindiv').offsetHeight-document.getElementById('pictures').offsetHeight+100;
};

window.onresize = function ()
{
    ResizeLeftAndRightDiv ();
};

window.onload = function ()
{
    ResizeLeftAndRightDiv ();
};

function SwitchPrintable ()
{
    if ($("div.logo").css("display")!="none"){
            $("div.logo").hide();
            $("div.banner").hide();
            $("div.picturebar").hide();
            $("div.navigation").hide();
            $("div.navigationpop").hide();
            $("div.content").addClass("contentPrint").removeClass("content"); 
            setTimeout("window.print()", 300);
            $("#printicon").attr({src:"SunPrinterBack.png", alt:"back from print mode"});
            }
        else {
            $("div.logo").show();
            $("div.banner").show();
            $("div.picturebar").show();
            $("div.navigation").show();
            $("div.navigationpop").show();
            $("div.contentPrint").addClass("content").removeClass("contentPrint");
            $("#printicon").attr({src:"SunPrinter.png", alt:"print mode"});
            }
};


$(document).ready(function(){
    // hide 
    $("#navpop").css("display", "block");
    // add info icons to selected SPANs 
    Infoboxes.init();
    // add click event to info icons 
    $("a.info").click(function(){
        Switchit(this);
        ResizeLeftAndRightDiv ();
        return false;
    });
    H2PrintIcon.init();
    // add click event to info icons 
    // Set Navigation bar mouse actions 
    $("img.navic")
        .hover(function(){
            $("#navpop").css("zIndex",6);
            if(this.id=="lccontact"){
                $("#ld"+this.id.slice(2)).css("height", 124);
                $("#ld"+this.id.slice(2)).animate( { width:"294px"}, 500 );
	        var nm = "info";
                var dom1 = "solar-designs";
                var dom2 = "com.au";
                $(this).parent().get(0).href="mailto:" + nm + "@" + dom1 + "." + dom2 + "?subject=Solar Designs Web Enquiry";
            } else {
	        $("#ld"+this.id.slice(2)).css("height", 86);	
		$("#ld"+this.id.slice(2)).animate( { width:"241px"}, 500 );
		}
            },
        function(){
            $("#ld"+this.id.slice(2)).css("height", 70);
            $("#ld"+this.id.slice(2)).animate( { width:"0px"}, 0 );
            $("#navpop").css("zIndex",0);
            if(this.id=="lccontact"){
                $(this).parent().get(0).href="";
            }
        });
    // Create Email function for contact image 
    $("img.contact")
        .hover(function(){
           var nm = "info";
           var dom1 = "solar-designs";
           var dom2 = "com.au";
           $(this).parent().get(0).href="mailto:" + nm + "@" + dom1 + "." + dom2 + "?subject=Solar Designs Web Enquiry";
            },
        function(){
           $(this).parent().get(0).href="";
        });
    // PNG FIX
    $('img[@src$=.png]').ifixpng(); 
//    $(document).pngFix();
//    ResizeLeftAndRightDiv ();
});


function templatehideall() {
    document.getElementById('ldbasics').style.display="none";
    document.getElementById('ldoffer').style.display="none";
    document.getElementById('lddetails').style.display="none";
    document.getElementById('ldnews').style.display="none";
    document.getElementById('ldlinks').style.display="none";
    document.getElementById('ldcontact').style.display="none";
    document.getElementById('textlinkbasics').style.display="none";
    document.getElementById('textlinkoffer').style.display="none";
    document.getElementById('textlinkdetails').style.display="none";
    document.getElementById('textlinknews').style.display="none";
    document.getElementById('textlinklinks').style.display="none";
    document.getElementById('textlinkcontact').style.display="none";
}

function hideall(p_poptexts) {
    var x=0;
    for (x=0; x<p_poptexts.length; x++)
    {
        document.getElementById(poptexts[x]).style.display="none";
    }
}
