﻿// JScript File
/*
What it does:  This file contains commonly used functions from possibly many wizards.
               Functions such as changeImage_afterchange() and downHandler_afterchange().
               This file will help us keep minimum functions within the wizard.asp page.

Referred by:   wizarda.asp
*/

function changeImage_afterchange(yindex) {
	if (flag_MultiplePhoto) {
		SetSelectionPhoto(yindex)
	}
	if (flag_MultipleGraphic) {
		SetSelectionGraphic(yindex)
	}
	if (xsubcatgid.toLowerCase() == "dyesub" && flag_GraphicField.length > 0) {
		MatchBackSideLogo(yindex)
	}
}

function manualCropApply_afterchange(yindex) {
	if (flag_MultiplePhoto) {
		SetSelectionPhoto(yindex)
	}
}

function AutoCropnApply_afterchange(yindex) {
	if (flag_MultiplePhoto) {
		SetSelectionPhoto(yindex)
	}
}

function downHandler_afterchange(yindex) {
	if (flag_MultiplePhoto) {
		if (div_contents[yindex]) {
			if (div_contents[yindex].indexOf('image') >= 0) {
				SelectThisPhoto(yindex, div_fields[yindex])
			}
		}
	}
}

function MatchBackSideLogo(yindex) {
	xlogofield = flag_GraphicField + "2"
	xindex = GetFieldIndex(xlogofield.toUpperCase())
	if (xindex > 0) {
		div_x[xindex] = div_x[yindex]
		div_w[xindex] = div_w[yindex]
		div_text[xindex] = div_text[yindex]

		xdom = document.images["div" + xindex + "img"]
		xdom.src = div_text[yindex]		
		xdom.width = (2 * parseFloat(div_w[xindex]))
		xdom.height = (2 * parseFloat(div_h[xindex]))
	}
}

function GetFieldIndex(xfieldname) {
	xindex = 0
	for(var n=1; n<num_divs; n++) {
		if (div_contents[n]) {
			if (div_contents[n].indexOf('image') >= 0) {
				if (div_fields[n].toUpperCase() == xfieldname) {
					xindex = n
					break;
				}
			}
		}
	}
	return xindex;
}
