
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 = "";
                }
            }
        }
    loadedImage.src = parent.document.getElementById(imgElementID).src;
}



function Popupimglarge(theimg,thedamage,thelink) {
	
    parent.document.getElementById("ctl00_MainBodyContent_hlImgMain").href = 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");
	
	var popupgallery = "";
	popupgallery +='<table><tr><td valign="top" class="nolink">';
	popupgallery += thedamage;
	popupgallery += '</td></tr></table>';
	parent.document.getElementById("ctl00_MainBodyContent_divDamage").innerHTML = popupgallery;
	popupgallery = "";
}

function SAPopupimglarge(theimg,thedamage,thelink) {
	
    parent.document.getElementById("ctl00_MainBodyContent_hlImgMain").href = 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");
	
	var popupgallery = "";
	popupgallery +='<table><tr><td style="font-size: 11px;" >';
	popupgallery += thedamage;
	popupgallery += '</td></tr></table>';
	parent.document.getElementById("ctl00_MainBodyContent_divDamage").innerHTML = popupgallery;
	popupgallery = "";
}

function PopupimglargeND(theimg,thelink) {
	
    parent.document.getElementById("ctl00_MainBodyContent_hlImgMain").href = 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");
}



