
function WinOpenNamed(height,width,name,url,displayStatus)
{
	var showStatusBar = "no";
	if (displayStatus)
		showStatusBar = "yes";
	pop=window.open(
	url,
	name,
	"toolbar=no,location=no,resizable=yes,scrollbars=yes,status="+showStatusBar+",statusbar="+showStatusBar+",height="+height+",width="+width);
	if(!pop.opener)
	{
		pop.opener = self;
	}
	pop.focus();
	return pop;
}

function WinOpenNamedTopLeft(height,width,name,url,displayStatus)
{
	var showStatusBar = "no";
		if (displayStatus)
			showStatusBar = "yes";
		pop=window.open(
		url,
		name,
		"toolbar=no,location=no,left=0,top=0,resizable=yes,scrollbars=yes,status="+showStatusBar+",statusbar="+showStatusBar+",height="+height+",width="+width);
		if(!pop.opener)
		{
			pop.opener = self;
		}
		pop.focus();
		return pop;
}
function WinOpen(height,width,url,displayStatus)
{
	var showStatusBar = "no";
	if (displayStatus)
		showStatusBar = "yes";
	pop=window.open(
	url,
	"popup",
	"toolbar=no,location=no,left=0, top=0,resizable=yes,scrollbars=yes,status="+showStatusBar+",statusbar="+showStatusBar+",height="+height+",width="+width);
	if(!pop.opener)
	{
		pop.opener = self;
	}
	pop.focus();	
}
function WinOpenMenubar(height,width,url,displayStatus)
{
	var showStatusBar = "no";
	if (displayStatus)
		showStatusBar = "yes";
	pop=window.open(
	url,
	"popup",
	"menubar=yes,toolbar=no,location=no,left=0, top=0,resizable=yes,scrollbars=yes,status="+showStatusBar+",statusbar="+showStatusBar+",height="+height+",width="+width);
	if(!pop.opener)
	{
		pop.opener = self;
	}
	pop.focus();	
}
function WinOpenNoScroll(height,width,url,displayStatus)
{
	var showStatusBar = "no";
	if (displayStatus)
		showStatusBar = "yes";
	pop=window.open(
	url,
	"popup",
	"toolbar=no,location=no,resizable=yes,scrollbars=no,status="+showStatusBar+",statusbar="+showStatusBar+",height="+height+",width="+width);
	if(!pop.opener)
	{
		pop.opener = self;
	}
	pop.focus();	
}

function WinOpenAddReport(height,width,url)
{
	pop=window.open(
	url,
	"popup",
	"toolbar=no,location=no,resizable=yes,scrollbars=yes,status=no,statusbar=no,height="+height+",width="+width);
	if(!pop.opener)
	{
		pop.opener = self;
	}
	pop.focus();
	//document.forms[0].submit();
}   

function OpenImg(url)
{
	pop = window.open(
	url,
	"popup2",
	"toolbar=no,left=0, top=0,location=no,resizable=yes,scrollbars=yes,status=no,statusbar=no,height=510,width=670");
	pop.focus();
}  


function OpenImgWithSize(height,width,url)
{
	window.open(
	url,
	"popup2",
	"toolbar=no,location=no,resizable=yes,scrollbars=yes,status=no,statusbar=no,height="+height+",width="+width);
}  

function printit()
{  
	if (window.print) 
	{
		window.print() ;  
	} 
	else 
	{
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
	}
}

function openCancelConfirmBox(vin_guid, closeWindow) 
{
	ans = confirm('\n' + 'Do you want to cancel this inspection request?' + '\n\n');
	if(ans == true) 
	{
		win = window.open('ViewRequest.aspx?vin_guid='+vin_guid+'&action=cancel','popup','toolbar=no,location=no,resizable=yes,scrollbars=yes,status=no,height=530,width=680');
	}
}

function WinOpenNewBrowser(height,width,name,url)
{
	var showStatusBar = "yes";
	pop=window.open(
	url,
	name,
	"toolbar=yes,location=yes,resizable=yes,scrollbars=yes,status="+showStatusBar+",statusbar="+showStatusBar+",height="+height+",width="+width);
	if(!pop.opener)
	{
		pop.opener = self;
	}
	pop.focus();
	return pop;
}

function PopupGallery(vin_guid, source, location, thedamage,section, url) {
	var theurl = "InspectionImageViewer.aspx?vin_guid="+vin_guid+"&source="+source +
		"&loc="+escape(location) + "&exp="+escape(thedamage)+"&section="+section+"&img="+url;
	Winpop = window.open(theurl, "photopopup", "toolbar=no,left=0,top=0,location=no,resizable=no,scrollbars=yes,status=no,statusbar=no,height=905,width=910");
	Winpop.focus();
}

function PopupGalleryND(vin_guid, source, url) {
	var theurl = "InspectionImageViewer.aspx?vin_guid="+vin_guid+"&source="+source +"&img="+url;
	Winpop = window.open(theurl, "photopopup", "toolbar=no,left=0,top=0,location=no,resizable=no,scrollbars=yes,status=no,statusbar=no,height=905,width=910");
	Winpop.focus();
}

function PopupGalleryDmg(vin_guid, source, location, thedamage, chargeable, total, section, url) {
	var theurl = "InspectionImageViewer.aspx?vin_guid="+vin_guid+"&source="+source +
		"&loc="+escape(location)+"&exp="+escape(thedamage)+"&chg="+chargeable+"&total="+total+"&section="+section+"&img="+url;
	Winpop = window.open(theurl, "photopopup", "toolbar=no,left=0,top=0,location=no,resizable=no,scrollbars=yes,status=no,statusbar=no,height=905,width=910");
	Winpop.focus();
}

function SAPopupGallery(vin_guid, source, location, thedamage,section, url) {
	var theurl = "SAInspectionImageViewer.aspx?vin_guid="+vin_guid+"&source="+source +
		"&loc="+escape(location) + "&exp="+escape(thedamage)+"&section="+section+"&img="+url;
	Winpop = window.open(theurl, "photopopup", "toolbar=no,left=0,top=0,location=no,resizable=no,scrollbars=yes,status=no,statusbar=no,height=685,width=790");
	Winpop.focus();
}

function SAPopupGalleryND(vin_guid, source, url) {
	var theurl = "SAInspectionImageViewer.aspx?vin_guid="+vin_guid+"&source="+source +"&img="+url;
	Winpop = window.open(theurl, "photopopup", "toolbar=no,left=0,top=0,location=no,resizable=no,scrollbars=yes,status=no,statusbar=no,height=685,width=790");
	Winpop.focus();
}

function SAPopupGalleryDmg(vin_guid, source, location, thedamage, chargeable, total, section, url) {
	var theurl = "SAInspectionImageViewer.aspx?vin_guid="+vin_guid+"&source="+source +
		"&loc="+escape(location)+"&exp="+escape(thedamage)+"&chg="+chargeable+"&total="+total+"&section="+section+"&img="+url;
	Winpop = window.open(theurl, "photopopup", "toolbar=no,left=0,top=0,location=no,resizable=no,scrollbars=yes,status=no,statusbar=no,height=685,width=790");
	Winpop.focus();
}


function sizeImg(imgElementID) {
    
    var loadedImage = new Image();
    loadedImage.onload = function sizeImgOnload() {
            var iw = this.width;
            var ih = this.height;
            
            var table_width = 640;
            var table_height = 480;
            
            if (iw <= table_width && ih <= table_height) {
                parent.document.getElementById(imgElementID).style.width = "";
                parent.document.getElementById(imgElementID).style.height = "";
            }
            else {
                var height_ratio = ih/table_height;
                var width_ratio = iw/table_width;
                
                if (height_ratio > width_ratio) {
                    parent.document.getElementById(imgElementID).height = table_height;
                    parent.document.getElementById(imgElementID).style.width = "";
                }
                else {
                    parent.document.getElementById(imgElementID).width = table_width;
                    parent.document.getElementById(imgElementID).style.height = "";
                }
            }
        }

        if (parent.document.getElementById(imgElementID) != null) {
           loadedImage.src = parent.document.getElementById(imgElementID).src;
        }
        var ctrlPrefix = 'ctl00'; //_ctl0
        if (parent.document.getElementById(ctrlPrefix + "_MainBodyContent_hlImgDownload") != null) {
            parent.document.getElementById(ctrlPrefix + "_MainBodyContent_hlImgDownload").href = "javascript: OpenImgWithSize('600', '800', '" + loadedImage.src + "');";
        }
}



function Popupimglarge(theimg,thedamage,thelink) {
    //CR 287 rps 20110602 ----------------------------------------
    var img1 = new Image();
    img1.onload = imgLoaded;
    img1.src = theimg;
    //var ctrlPrefix = 'ctl00'; //_ctl0

    function imgLoaded() {
        var ctrlPrefix = 'ctl00'; //_ctl0
        if (this.width > 640 && this.height > 480) {
            parent.document.getElementById(ctrlPrefix + "_MainBodyContent_hlImgMain").href = thelink;  //ctl00
            parent.document.getElementById(ctrlPrefix + "_MainBodyContent_hlImgMain").setAttribute("rel", "position: \'inside\', showTitle: false,  adjustX:-4, adjustY:-4");
            parent.document.getElementById(ctrlPrefix + "_MainBodyContent_hlImgMain").setAttribute("class", "cloud-zoom");
            parent.document.getElementById(ctrlPrefix + "_MainBodyContent_imgMain").width = 640;
            parent.document.getElementById(ctrlPrefix + "_MainBodyContent_imgMain").height = 480;
            parent.SetZoom(thelink);
        } else {
            //640X480 is the minimum, so for smaller images the Zoom functionaly is disable

        parent.document.getElementById(ctrlPrefix + "_MainBodyContent_hlImgMain").setAttribute("href", "javascript: OpenImgWithSize('600', '800', '" + this.src + "');");
        parent.DisableZoom();
        parent.document.getElementById(ctrlPrefix + "_MainBodyContent_imgMain").removeAttribute("width");   
        parent.document.getElementById(ctrlPrefix + "_MainBodyContent_imgMain").removeAttribute("height");
            
        if (parent.document.getElementById(ctrlPrefix + "_MainBodyContent_hlImgMain").getAttribute("class") != null) {
            parent.document.getElementById(ctrlPrefix + "_MainBodyContent_hlImgMain").removeAttribute("class");
        }
        if (parent.document.getElementById(ctrlPrefix + "_MainBodyContent_hlImgMain").getAttribute("rel") != null) {
            parent.document.getElementById(ctrlPrefix + "_MainBodyContent_hlImgMain").removeAttribute("rel");
        }
            
        }
    }
    //CR 287 -----------------------------------------------------
    var ctrlPrefix = 'ctl00'; //_ctl0
    parent.document.getElementById(ctrlPrefix + "_MainBodyContent_hlImgDownload").href = "javascript: OpenImgWithSize('600', '800', '" + thelink + "');";

    parent.document.getElementById(ctrlPrefix + "_MainBodyContent_imgMain").src = theimg;

    //parent.document.getElementById(ctrlPrefix + "_MainBodyContent_imgMain").style.width = 640;
    //parent.document.getElementById(ctrlPrefix + "_MainBodyContent_imgMain").style.height = 480;

    sizeImg(ctrlPrefix + "_MainBodyContent_imgMain");
	
	var popupgallery = "";
	popupgallery +='<table><tr><td valign="top" class="nolink">';
	popupgallery += thedamage;
	popupgallery += '</td></tr></table>';
	parent.document.getElementById(ctrlPrefix + "_MainBodyContent_divDamage").innerHTML = popupgallery;
	popupgallery = "";
}

function SAPopupimglarge(theimg, thedamage, thelink) {

    //CR 287 rps 20110602 ----------------------------------------
    var img1 = new Image();
    img1.onload = imgLoaded;
    img1.src = theimg;

    function imgLoaded() {
        if (this.width > 640 || this.width > 480) {
            parent.document.getElementById("ct100_MainBodyContent_hlImgMain").href = thelink;
            parent.document.getElementById("ct100_MainBodyContent_hlImgMain").setAttribute("rel", "position: \'inside\', showTitle: false,  adjustX:0, adjustY:0");
            parent.document.getElementById("ct100_MainBodyContent_hlImgMain").setAttribute("class", "cloud-zoom");
            parent.SetZoom(thelink);
        } else {
            //640X480 is the minimum, so for smaller images the Zoom functionaly is disable

        parent.document.getElementById("ct100_MainBodyContent_hlImgMain").setAttribute("href", "javascript: OpenImgWithSize('600', '800', '" + this.src + "');");
            parent.DisableZoom();
            if (parent.document.getElementById('ct100_MainBodyContent_hlImgMain').getAttribute("class") != null) {
                parent.document.getElementById('ct100_MainBodyContent_hlImgMain').removeAttribute("class");
            }
            if (parent.document.getElementById('ct100_MainBodyContent_hlImgMain').getAttribute("rel") != null) {
                parent.document.getElementById('ct100_MainBodyContent_hlImgMain').removeAttribute("rel");
            }
        }
    }
    //CR 287 -----------------------------------------------------


    //parent.document.getElementById("hlImgMain").rel = 'position: \'inside\', showTitle: false,  adjustX: 0, adjustY:0';
    parent.document.getElementById("ct100_MainBodyContent_hlImgDownload").href = "javascript: OpenImgWithSize('600', '800', '" + thelink + "');";

    parent.document.getElementById("ct100_MainBodyContent_imgMain").src = theimg;

    parent.document.getElementById("ct100_MainBodyContent_imgMain").width = 640;
    parent.document.getElementById("ct100_MainBodyContent_imgMain").height = 480;

    sizeImg("ct100_MainBodyContent_imgMain");

    var popupgallery = "";
    popupgallery += '<table><tr><td style="font-size: 11px;" >';
    popupgallery += thedamage;
    popupgallery += '</td></tr></table>';
    parent.document.getElementById("ct100_MainBodyContent_divDamage").innerHTML = popupgallery;
    popupgallery = "";
}

function PopupimglargeND(theimg,thelink) {

    parent.document.getElementById("ctl00_MainBodyContent_hlImgMain").href = thelink;
    //CR 287 rps
    parent.document.getElementById("ctl00_MainBodyContent_hlImgMain").rel = 'position: \'inside\', showTitle: false,  adjustX: -4, adjustY:-4';
    parent.document.getElementById("ctl00_MainBodyContent_hlImgDownload").href = "javascript: OpenImgWithSize('600', '800', '" + thelink + "');";
    //---------------------------
    parent.document.getElementById("ctl00_MainBodyContent_imgMain").style.width = 640;
    parent.document.getElementById("ctl00_MainBodyContent_imgMain").style.height = 480;

    parent.document.getElementById("ctl00_MainBodyContent_imgMain").src = theimg;

    sizeImg("ctl00_MainBodyContent_imgMain");

	parent.setzoom(thelink); //CR 287 rps
}




