function CoatedBeltsWizard(fieldName, stepCount) {
	this.fieldName = fieldName;
	this.stepCount = stepCount;
	this.errorMessage = {};
	this.alertMessage = {};
}

CoatedBeltsWizard.prototype = new PowerbeltWizard();
CoatedBeltsWizard.prototype.constructor = PowerbeltWizard;
CoatedBeltsWizard.prototype.base = PowerbeltWizard.prototype;

CoatedBeltsWizard.prototype.performPostLoadingOperations = function(data) {
	if (data.currentStep == 1) {
		var imgName = jQuery('#wizardStep0').val();
		var imgUrl = 'images/coating_belt/' + imgName + '.png'; 
		jQuery('#image1Container').html("<img src='" + imgUrl + "' />");
	} else if (data.currentStep == 5) {
		var imgName = jQuery('#wizardStep4').val();
		var imgUrl = 'images/coating_belt/' + imgName + '.png'; 
		jQuery('#image2Container').html("<img src='" + imgUrl + "' />");
	}

	if (data.currentStep >= 6) {
		jQuery('.wizardContactForm').removeAttr("disabled"); 
	} else {
		jQuery('.wizardContactForm').attr("disabled", true); 
	}
	
}

CoatedBeltsWizard.prototype.gotoCoatedBelt = function(cn) {
	jQuery("#currentStep").val(this.currentStep);
	jQuery("#coatedBeltsWizardForm").attr("action", 'index.php?Prod=' + cn);
	jQuery("#coatedBeltsWizardForm").submit();
	return false;	
}

CoatedBeltsWizard.prototype.submitContactForm = function(cn) {
	var contactName = jQuery("#detail_contact_name").val();
	var contactPhone = jQuery("#detail_contact_phone").val();
	var emailAddress = jQuery("#email_address").val();
	
	if (contactName.trim().length == 0) {
		alert(this.errorMessage.contactNameEmpty);
		return false;
	} else if (contactPhone.trim().length == 0) {
		alert(this.errorMessage.contactPhoneEmpty);
		return false;
	} else if (emailAddress.trim().length == 0) {
		alert(this.errorMessage.emailAddressEmpty);
		return false;
	} else if (!echeck(emailAddress)) {
		alert(this.errorMessage.emailAddressError);
		return false;
	}
	jQuery('#wizardExtraData0').removeAttr("disabled"); 
	jQuery("#coatedBeltsWizardForm").attr("action", 'index.php?Prod=' + cn);
	jQuery('#requestedAction').val("sendContactForm");
	return true;
}

CoatedBeltsWizard.prototype.initializeSpecificWizard = function() {
	this.renderUploadContent();
}

CoatedBeltsWizard.prototype.renderUploadContent = function() {
	this.loadUploadedFilesStatus();
}

CoatedBeltsWizard.prototype.openUploadWindow = function() {
	powerbelt_user_upload_window_ref = open('index.php?page=UserFileUpload&type=CoatedBelts', 'powerbelt_user_upload_window', 'width=400, height=300, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, screenX=150, left=150, screenY=150, top=150, status=yes');
	return false;
}

CoatedBeltsWizard.prototype.fileUploadWindowClosed = function() {
	this.renderUploadContent();
}

CoatedBeltsWizard.prototype.loadUploadedFilesStatus = function() {
	var pData = {};
	pData.requestedAction = 'loadUploadedFilesStatus';
	pData.type = 'COATED_BELTS';
	this.loadWizardData(pData, this, 'loadUploadedFilesStatusLoaded', 'index.php?page=UserFileUploadServer');	
}

CoatedBeltsWizard.prototype.loadUploadedFilesStatusLoaded = function(data) {
	var s = '';
	if (data.filesCount < data.filesMaxCount) {
		s += '<a href="javascript://" onclick="wizard.openUploadWindow()">' + this.alertMessage.openFileUpload + '</a>';
	}
	s += '<table class="">';
	for(var i=0; i<data.filesData.length; i++) {
		s += '<tr><td>';
		s += '<a href="' + data.filesDir + data.filesData[i].fileName + '" target="_blank">' + data.filesData[i].originalName + '</a>';
		s += '</td><td>';
		s += '<a href="javascript://" onclick="wizard.deleteUserUploadedFile(\'' + data.filesData[i].fileName + '\')" >' + this.alertMessage.uploadedFileDelete + '</a>';
		s += '</td></tr>';
	}
	s += '</table>'  
	jQuery('#imageUploadContainer').html(s);
	
}

CoatedBeltsWizard.prototype.deleteUserUploadedFile = function(fileName) {
	var pData = {};
	pData.requestedAction = 'deleteUploadedFile';
	pData.type = 'COATED_BELTS';
	pData.fileName = fileName;
	this.loadWizardData(pData, this, 'loadUploadedFilesStatusLoaded', 'index.php?page=UserFileUploadServer');	
}




var powerbelt_user_upload_window_ref = null;


// String prototype extensions
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

String.prototype.ltrim = function() {
	return this.replace(/^\s+/g,"");
}

String.prototype.rtrim = function() {
	return this.replace(/\s+$/g,"");
} 