
function getwidth(){
    var scrwide;

         if (typeof window.innerWidth != 'undefined')
         {
              scrwide = window.innerWidth
         }

        // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

         else if (typeof document.documentElement != 'undefined'
             && typeof document.documentElement.clientWidth !=
             'undefined' && document.documentElement.clientWidth != 0)
         {
               scrwide = document.documentElement.clientWidth
         }

         // older versions of IE

         else
         {
               scrwide = document.getElementsByTagName('body')[0].clientWidth
         }
    return scrwide

}

function getheight(){
    var theHeight;
    // Window dimensions:
    if (window.innerHeight) {
    theHeight=window.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) {
    theHeight=document.documentElement.clientHeight;
    }
    else if (document.body) {
    theHeight=document.body.clientHeight;
    }
    return theHeight;
}

function getscreenheight(){
    if (document.body.offsetHeight){
        theHeight=document.body.offsetHeight;
    } else if (window.innerHeight) {
    theHeight=window.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) {
    theHeight=document.documentElement.clientHeight;
    }
    else if (document.body) {
    theHeight=document.body.clientHeight;
    }
    return srcHeight;
}

function getPageSizeWithScroll(){
    if (window.innerHeight && window.scrollMaxY){
        yWithScroll = window.innerHeight + window.scrollMaxY;
        xWithScroll = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollHeight > document.body.offsetHeight){
        yWithScroll = document.body.scrollHeight;
        xWithScroll = document.body.scrollWidth;
    } else {
        yWithScroll = document.body.offsetHeight;
        xWithScroll = document.body.offsetWidth;
    }
    arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
    return arrayPageSizeWithScroll; }

function getresizefactor(oldlength, newlength){
    factor=newlength/oldlength;
    return factor;
}

function show_image(image_name, imgwidth, imgheight, image_text)
{
        factor=1

        if (imgwidth>getwidth()){
            factor=getresizefactor(imgwidth,getwidth())
        }
        if (imgheight>(getheight()-100)){
            factor=getresizefactor(imgheight,(getheight()-100))
        }
        if (factor!=1){
            imgwidth=imgwidth*factor;
            imgheight=imgheight*factor;
        }
        var b=document.getElementById('shade');
        pagesize=getPageSizeWithScroll()
        b.style.height=pagesize[0]+"px";
        b.style.width=pagesize[1]+"px";
        image_name=image_name.replace(/images/,"");
        image_name=image_name.substring(1,(image_name.length-4));
        image="<div style='position:absolute; top:20px; left:10px; z-index:20;'><iframe frameborder='0' scrolling=NO onclick='close_image()' name='image1' width='"+(Number(imgwidth)+20)+"px' height='"+(Number(imgheight)+20)+"px' alt='' src='/scripts/show_image3.php?main="+image_name+"&width="+imgwidth+"&height="+imgheight+"&large=1' /></div>";
        html_string="<div class='pop_up_whole'><div class='pop_up_top'><div style='float:right; width:19px;'><img border='0' alt='' src='/images/background/close_box.gif' onmouseover=\"this.src='/images/background/close_box_on.gif';\" onmouseout=\"this.src='/images/background/close_box.gif';\" onclick='close_image()' alt='' /></div><div style='padding-left:5px; float:left; padding-top:2px'><span class='text_wn11'><b>"+image_text+"<b></span></div></div><br /><center><img id='loading1' style='visibility:visible; float:left; z-index:10; margin-top:30%; margin-left:45%;' src='/images/background/loader.gif'>";
        html_string = html_string + image;
        html_string = html_string + "<br /><div style='height:20px;'><span class='text_gn11'>Images are for illustration purposes only.<br />Click cross above to close</div></center></div>";
        var a=document.getElementById('image_box_off');
        a.innerHTML=html_string;
        var scrwide;
        var scrhigh;
        scrwide=getwidth();
        scrhigh=getheight();
        boxwidth=parseInt(imgwidth)+40;
        boxheight=parseInt(imgheight)+80;
        a.style.width=boxwidth+'px';
        a.style.height=boxheight+'px';
        var leftval=(scrwide/2)-(imgwidth/2)-20;
        var topval=(scrhigh/2)-(imgheight/2)-100;
        if (topval<0)topval=0;
        a.style.top=topval+'px';
        a.style.left=leftval+'px';
//        top.location='#top';
        fadeIn("image_box_off",4,0,100);
        fadeIn("shade",3,0,80);

}

function test(){
    alert("hello");
}

function close_image()
{
        fadeOut("image_box_off",3,100,0);
        fadeOut("shade",3,80,0);
}

// #############################################################################

function setboxtop(type){
var boxtop;
if (!type) return false;
boxtop="<div style='width:90%; height:100%; background:#FFFFFF; border: solid 3.0px silver; text-align:left; padding:15px; position:absolute; top:0px; left:0px;'><img id='emailtype' src='/images/background/"+type+"_on.png' alt='' /><br />"
return boxtop;
}

function show_question_pane()
{
    boxtop=setboxtop("question");
//	question_html=boxtop + "<div id='response'><form action='' method='post'><table bgcolor='#FFFFFF'><tr><td class='text_gn11'>Full Name:<span class='text_r10'>*</span></td><td><input name='full_name' id='full_name' size=27 class='text_gn11' style='background-color:#FFC469;'><input type='hidden' name='part_no2' id='part_no2' size=27 value='"+document.getElementById('part_no').value+"'></td><td rowspan=4><img src='/images/background/contacts.jpg' alt='' /></td></tr><tr><td class='text_gn11'>Email Address:<span class='text_r10'>*</span></td><td><input name='email_address' id='email_address' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr><tr><td class='text_gn11'>Contact Number:</td><td><input name='phone_number' id='phone_number' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr><tr><td class='text_gn11'>Vehicle Details:</td><td><input name='vehicle_details' id='vehicle_details' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr><tr><td class='text_gn11'>Question:<span class='text_r10'>*</span></td><td colspan=2 valign='top'><textarea name='strquestion' id='strquestion' cols=55 rows=5 class='text_gn11' style='background-color:#FFC469;'></textarea></td></tr><tr><td class='text_r10' colspan=3>Field must with a * must be completed before the question can be sent to the team</td></tr><tr><td align='left' colspan=3><br /><div style=\"float:left;\"><a href=\"#top\"><img onclick=close_image() border='0' src='/images/background/cancel.gif' alt='' /></a></div><div style=\"float:right;\"><input type='image' onclick='sendemail()' src='/images/background/send_question.gif'></div></td></tr></table><input type='hidden' name='question' value='yes'></form></div></div>";
	question_html=boxtop + "<div id='response'><form action='' method='post'><table bgcolor='#FFFFFF'><tr><td class='text_gn11'>Full Name:<span class='text_r10'>*</span></td><td><input name='full_name' id='full_name' size=27 class='text_gn11' style='background-color:#FFC469;'><input type='hidden' name='part_no2' id='part_no2' size=27 value='"+document.getElementById('part_no').value+"'></td><td rowspan=4><img src='/images/background/contacts.jpg' alt='' /></td></tr><tr><td class='text_gn11'>Email Address:<span class='text_r10'>*</span></td><td><input name='email_address' id='email_address' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr><tr><td class='text_gn11'>Contact Number:</td><td><input name='phone_number' id='phone_number' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr><tr><td class='text_gn11'>Vehicle Details:</td><td><input name='vehicle_details' id='vehicle_details' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr><tr><td class='text_gn11'>Question:<span class='text_r10'>*</span></td><td colspan=2 valign='top'><textarea name='strquestion' id='strquestion' cols=55 rows=5 class='text_gn11' style='background-color:#FFC469;'></textarea></td></tr><tr><td class='text_r10' colspan=3>Field must with a * must be completed before the question can be sent to the team</td></tr><tr><td align='left' colspan=3><br /><div style=\"float:left;\"><img onclick=close_image() border='0' src='/images/background/cancel.gif' alt='' /></div><div style=\"float:right;\"><input type='image' onclick='sendemail()' src='/images/background/send_question.gif'></div></td></tr></table><input type='hidden' name='question' value='yes'></form></div></div>";
	document.getElementById("image_box_off").innerHTML=question_html;
//	document.getElementById("btnquestion").innerHTML="<a href='#top' onclick='hide_question_pane()'><img border='0' src='/images/background/question_down.png'></a>";

//        var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
        show_pane(600,400);
}

function show_cheaper_pane()
{
    boxtop=setboxtop("seenitcheaper");
//	question_html=boxtop + "<div id='response'></p><form action='' method='post'><table bgcolor='#FFFFFF' cellspacing=5px><tr><td class='text_gn11'>Name:<span class='text_r10'>*</span></td><td><input name='full_name' id='full_name' size=27 class='text_gn11' style='background-color:#FFC469;'><input type='hidden' name='part_no2' id='part_no2' size=27 value='"+document.getElementById('part_no').value+"'></td><td rowspan=4></td></tr><tr><td class='text_gn11'>Email Address:<span class='text_r10'>*</span></td><td><input name='email_address' id='email_address' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr><tr><td class='text_gn11'>Contact Number:</td><td><input name='phone_number' id='phone_number' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr><tr><td class='text_gn11'>Link to cheaper price:<span class='text_r10'>*</span></td><td colspan=2 valign='top'><input type='text' size=40 name='strquestion' id='strquestion' class='text_gn11' style='background-color:#FFC469;' /></td></tr><tr><td class='text_r10' colspan=3>Field must with a * must be completed before the question can be sent to the team</td></tr><tr><td align='left' colspan=3><br /><div style=\"float:left;\"><a href=\"#top\"><img onclick=close_image() border='0' src='/images/background/cancel.gif' alt='' /></a></div><div style=\"float:right;\"><input type='image' onclick='sendemail()' src='/images/buttons/sendlink.png'></div></td></tr></table><input type='hidden' name='question' id='question' value='yes'></form></div></div>";
	question_html=boxtop + "<div id='response'></p><form action='' method='post'><table bgcolor='#FFFFFF' cellspacing=5px><tr><td class='text_gn11'>Name:<span class='text_r10'>*</span></td><td><input name='full_name' id='full_name' size=27 class='text_gn11' style='background-color:#FFC469;'><input type='hidden' name='part_no2' id='part_no2' size=27 value='"+document.getElementById('part_no').value+"'></td><td rowspan=4></td></tr><tr><td class='text_gn11'>Email Address:<span class='text_r10'>*</span></td><td><input name='email_address' id='email_address' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr><tr><td class='text_gn11'>Contact Number:</td><td><input name='phone_number' id='phone_number' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr><tr><td class='text_gn11'>Link to cheaper price:<span class='text_r10'>*</span></td><td colspan=2 valign='top'><input type='text' size=40 name='strquestion' id='strquestion' class='text_gn11' style='background-color:#FFC469;' /></td></tr><tr><td class='text_r10' colspan=3>Field must with a * must be completed before the question can be sent to the team</td></tr><tr><td align='left' colspan=3><br /><div style=\"float:left;\"><img onclick=close_image() border='0' src='/images/background/cancel.gif' alt='' /></div><div style=\"float:right;\"><input type='image' onclick='sendemail()' style='cursor:pointer;' src='/images/buttons/sendlink.png'></div></td></tr></table><input type='hidden' name='question' id='question' value='yes'></form></div></div>";
	document.getElementById("image_box_off").innerHTML=question_html;
//	document.getElementById("btnquestion").innerHTML="<a href='#top' onclick='hide_question_pane()'><img border='0' src='/images/background/send_link.png'></a>";

//        var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
        show_pane(600,400);
}

function show_email_pane()
{
    boxtop=setboxtop('email')
	email_html=boxtop+"<div id='response'><form action='' method='post'><table bgcolor='#FFFFFF'>";
    email_html=email_html + "<tr><td class='text_gn11'>Recipient Name:<span class='text_r10'>*</span></td><td><input id='full_name' size=27 class='text_gn11' style='background-color:#FFC469;'></td><td></td><td rowspan=4><img src='/images/background/contacts.jpg' /></td></tr>";
    email_html=email_html + "<tr><td class='text_gn11'>Your Name: <span class='text_r10'></span></td><td><input id='namefrom' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr>";
    email_html=email_html + "<tr><td class='text_gn11'>Recipient Email Address:<span class='text_r10'>*</span></td><td><input id='email_address' size=27 class='text_gn11' style='background-color:#FFC469;'></td></tr>";
    email_html=email_html + "<tr><td class='text_gn11'>Additional Comments:</td><td colspan=2 valign='top'><textarea id='strcomment' cols=55 rows=5 class='text_gn11' style='background-color:#FFC469;'></textarea></td></tr><tr><td class='text_r10' colspan=3>Field must with a * must be completed before the question can be sent</td></tr>";
//    email_html=email_html + "<tr><td align='left' colspan=3><br /><div style='float:left;'><a href='#top'><img onclick=close_image() border='0' src='/images/background/cancel.gif' /></a></div><div style='float:right;'><a href='#top'><img  onclick=sendemail() border='0' src='/images/buttons/send.png' /></a></div></td></tr></table><input type='hidden' name='question' value='yes'><input type='hidden' id='link' name='link' value='"+window.location+"'></form></div></div>";
    email_html=email_html + "<tr><td align='left' colspan=3><br /><div style='float:left;'><img onclick=close_image() border='0' src='/images/background/cancel.gif' /></div><div style='float:right;'><img onclick=sendemail() border='0' src='/images/buttons/send.png' /></div></td></tr></table><input type='hidden' name='question' value='yes'><input type='hidden' id='link' name='link' value='"+window.location+"'></form></div></div>";

	document.getElementById("image_box_off").innerHTML=email_html;

//        var _docHeight = (document.height !== undefined) ? document.height : document.body.offsetHeight;
        show_pane(650,350);

}

function show_pane(wdth, hght){

        var b=document.getElementById('shade');
        pagesize=getPageSizeWithScroll()
        b.style.height=pagesize[0]+'px';
        b.style.width=pagesize[1]+'px';
        scrwide=getwidth();
        scrhigh=getheight();
        b.style.visibility='visible';
        var a=document.getElementById('image_box_off');
        a.style.visibility="VISIBLE";
        a.style.width=wdth+'px';
        a.style.height=hght+'px';
        var leftval=(scrwide/2)-(wdth/2);
        var topval=(scrhigh/2)-(hght/2)-50;
        if (topval<0)topval=0;
        a.style.top=topval+'px';
        a.style.left=leftval+'px';
//        top.location='#top';
        b.style.width='100%';
//        opacity("image_box_off", 0, 100, 300);
//        opacity("shade", 0, 80, 250);
        fadeIn("image_box_off",4,0,100);
        fadeIn("shade",3,0,80);

}

