function submitFaultReport() {
    document.faultReport.url.value = window.location.href;
    document.faultReport.templateId.value = templateId;
    ajaxpage('/listings/faultReport.html', 'faultReportDiv', 'faultReport');
    return false;
}

function submitInapproriateItemReport() {
    document.inappropriateItemReport.templateId.value = templateId;
    document.inappropriateItemReport.itemId.value = itemId;
    ajaxpage('/listings/inappropriateItemReport.html', 'inappropriateItemReportDiv', 'inappropriateItemReport');
    return false;
}

function resizeImages() {
    var images = document.getElementsByTagName('img');
    for (var i = 0; i < images.length; i++) {
        var image = images[i];

        var className = image.className;
        try {
            if (className.indexOf('solImage') != -1 && (image.src.indexOf("NoImage.JPG") == -1)) {
                var index = className.indexOf('_');
                var width = className.substr(8, index - 8);
                var height = className.substr(index + 1);
                ResizeImage(image, width, height);
            }
        } catch (e) {}
    }
}

function ResizeImage(obj, solwidth, solheight) {
   
	
	var width;
    var height;
    var scaleRatio;
    try {
        width = obj.width;
        height = obj.height;
        var image = new Image();
        image.onload = function () {
            width = image.width;
            height = image.height;
            if (width > solwidth || height > solheight) {
                if (width > height) {
                    scaleRatio = width / solwidth;
                    width = width / scaleRatio;
                    height = height / scaleRatio;
                } else {
                    scaleRatio = height / solheight;
                    width = width / scaleRatio;
                    height = height / scaleRatio;
                }
            }
			
            document.getElementById("itemImage").innerHTML = '<img src="' + obj.src + '"id="imageId"width="' + width + '"height="' + height + '"onmouseover="showtrail(\'' + obj.src + '\',250,250,128,128,false,false,true);"onmouseout="hidetrail();"class="solImage128_128"alt="' + obj.alt + '"/><div id="imagePreviewContainerOuterDiv"/>';
        }
		
        image.src = obj.src;
    } catch (e) {
		
	}
}

var iADialogue;
// used from item pages


function showIADialog() {

	
	$('#inappropriateItemReportDiv').dialog({ position: 'center' });

    $("#inappropriateItemReportDiv").dialog(
		{ 
			width: 390, 
			height: 450,
			modal: true,
			zIndex:10,			
			title:"Inappropriate Item"
		}
	);
	

	
}

function closeIADialog() {
    setTimeout('ajaxpage(\'/listings/inappropriateItemReport.html\', \'inappropriateItemReportDiv\')', 1000);
	$("#inappropriateItemReportDiv").dialog("close");
}
