// JavaScript Document

function SaveBanner()
{
	
	var CompleteProcess = function (oxml) 
	{
		var result = oxml.responseText;
		//alert(result);
		if(result == 'Success')
		{
			alert('Your Banner and Link has been uploaded, please refresh the website.');	
		}
		else
		{
			alert('An error occur while upload/saving banner: ' + result);	
		}
		regularCursor()
		oxml=null		
	}
	
	if(document.getElementById('txtAdvertFile').value == '')
	{
		alert('Please upload valid image file.');	
	}
	else if(document.getElementById('txtAdvertLink').value == '')
	{
		alert('Please enter valid image file link.');	
		document.getElementById('txtAdvertLink').focus();
	}
	else
	{
		var path = "/modules/upload/processupload.asp";
		var data = fetchInputFormData('frmBannerUpload') + '&action=Update';	
		//alert(data);
		hiddenSubmit(path,data,CompleteProcess,0,null,true,false);		
	}
}

function UploadBanner(Action)
{
	document.getElementById('txtAction').value = Action;
	alert(document.getElementById('txtAction').value);
}

function OpenUpload(ObjField, ObjFilePath, ObjFileName)
{
	var URL = '/modules/Upload/uploadfile.asp';
	var retValue = window.showModalDialog(URL,"","dialogWidth:550px;dialogHeight:140px;z-index:110;")
	if (retValue != '' && retValue != null)
	{
		var FilePath = retValue.split('|');
		document.getElementById(ObjField).value = FilePath[0];
		document.getElementById(ObjFilePath).value = FilePath[1];
		document.getElementById(ObjFileName).value = FilePath[2];
	}	
	
}

function CloseWindow()
{
	var OpenerForm = document.form1.OpenerForm.value;
	var OpenerField = document.form1.OpenerField.value;
	var FilePath = document.form1.FilePath.value;
	var vFilePath = document.form1.vFilePath.value;
	var FileName = document.form1.FileName.value;
	if(FilePath != '')
	{
		alert('Your file has been successfully uploaded')
		var strReturn = vFilePath + '|' + FilePath + '|' + FileName;
		window.returnValue = strReturn;
		window.close();
	}
}

function ValidateForm()
{
	var Me = document.form1;
	if (Me.fUpload.value == '')
	{
		alert('Please select a valid file path');
		return false;
	}
	else
	{
		return true;
	}
}
