
/****************************************************************************/
/*		Following code is used all over in MRM Web Client					*/
/*																			*/
/*																			*/
/****************************************************************************/

//Frame open
function openframe() {
	self.document.body.cols = "*, 200";
}

function closeframe() {
	this.top.document.body.cols = "*, 0";
}

//Window Open
function popCalendar(frmName, fldName, format, winName, event) {
	var fldValue = eval('document.'+frmName+'.elements[\''+fldName+'\'].value');
	var popup;
	if(bOutlook) {
		winName = "mrmpopup";
		openframe();
	}
	popup = window.open('calendar_popup.asp?format='+format+'&formname='+frmName+'&fieldname='+fldName+'&date='+fldValue, winName, 'height=164,width=175,menubar=0,status=0,titlebar=0,toolbar=0,scrollBars=no,resizable=no,screenX='+(event.screenX-180)+',left='+(event.screenX-180)+',screenY='+event.screenY+',top='+event.screenY);
	popup.focus();
}

function popSystemValue(FrmName, FldName, ValType, CurVal, winName, event) {
	//var w = 200;
	//var h = 250;
	//var move = screen ? 'left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '';
	var popup;
	if(winName.length==0) winName = 'ValueList';
	popup = window.open('systemvaluelist.asp?FrmName='+FrmName+'&FldName='+FldName+'&ValType='+ValType+'&CurVal='+CurVal, winName, 'width=200,height=250,menubar=0,status=0,titlebar=0,toolbar=0,scrollBars=no,resizable=no,screenX='+(event.screenX-180)+',left='+(event.screenX-180)+',screenY='+event.screenY+',top='+event.screenY)
	popup.focus();
}

function popCustomValue(FrmName, FldName, CurVal, winName, event) {
	var w = 285;
	var h = 357;
	var move = screen ? 'left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '';
	var popup;
	if(winName.length==0) winName = 'ValueList';
	popup = window.open('valuelist.asp?fieldname='+FldName+'&frm='+FrmName, winName, move + ',width=285,height=357,menubar=0,status=0,titlebar=0,toolbar=0,scrollBars=no,resizable=no'); //,screenX='+(event.screenX-180)+',left='+(event.screenX-180)+',screenY='+event.screenY+',top='+event.screenY);
	popup.focus();
}

function popOpenWindowWithMenu(win, winName, param, w, h, scroll) {
	var move = screen ? 'left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '';
	var url;
	if (param.length == 0) {
		url = win;
	}else{		
		url = win+"?"+param;
	}
	window.open(url, winName, move + ",width=" + w + ",height=" + h + ",scrollBars=" + scroll + ",resizable=yes,menubar=1");
}

function popOpenWindow(win, winName, param, w, h, scroll) {
	var move = screen ? 'left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '';
	var url;
	if (param.length == 0) {
		url = win;
	}else{		
		url = win+"?"+param;
	}
	window.open(url, winName, move + ",width=" + w + ",height=" + h + ",scrollBars=" + scroll + ",resizable=yes");
}

function popOpenWindowRetObj(win, winName, param, w, h, scroll) {
	var move = screen ? 'left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '';
	var url, popup;
	if (param.length == 0) {
		url = win;
	}else{		
		url = win+"?"+param;
	}
	popup = window.open(url, winName, move + ",width=" + w + ",height=" + h + ",scrollBars=" + scroll + ",resizable=yes");
	return popup;
}

function popOpenWindowAtCursor(win, winName, param, w, h, event) {
	var popup;
	//var move = '';//screen ? 'left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '';
	popup = window.open(win+"?"+param, winName, "width=" + w + ",height=" + h + ",scrollBars=1,resizable=no,screenX="+(event.screenX-180)+",left="+(event.screenX-180)+",screenY="+event.screenY+",top="+event.screenY);
	popup.focus();
}

function OpenGridPage(sFrame) {
	window.open('loadview.asp', sFrame);
}

//Form Check
function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
}

//Delete Uploaded file
function DeleteUploadedFile(sform, sfield, smsg) {
	var w = 300; 
	var h=200;
	var sValue = eval("document." + sform).elements[sfield].value;
	if(sValue.length > 0) {
		if(confirm(smsg)) {
			var move = screen ? 'left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '';
			window.open('FileAdd.asp?sfrm=' + sform + '&sfld=' + sfield + '&sDel=' + sValue, 'DeleteFile', move + ',width=' + w + ',height=' + h + ',scrollBars=' + scroll + ',resizable=yes');
		}
	}
}


//Open the given form and field name's value in different browser
function OpeninOtherWindow(sform, sField, winName, param, w, h, scroll) {
	var move = screen ? 'left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '';
	var sValue = eval("document." + sform).elements[sField].value;
	var popup;
	
	popup = window.open(sValue, winName, move + ",width=" + w + ",height=" + h + ",scrollBars=" + scroll + ",resizable=yes");
	popup.focus();
}


//Prompt user for image url
function getimageurl(sform, sField) {
	var ImageURL = prompt("Please enter the image URL (eg. http://www.acme.com/room1.gif)" ,eval("document." +sform).elements[sField].value)
	var imgSrc = new Image();
	
	if (ImageURL != null) {
	
		//Check if ImageURL is image file
		if ((ImageURL.toUpperCase()).indexOf(".GIF") > 0 || (ImageURL.toUpperCase()).indexOf(".JPG") > 0 || (ImageURL.toUpperCase()).indexOf(".BMP") > 0) {
			imgSrc.src = ImageURL;
			document [sField+"_image"].src=imgSrc.src;
			//eval("document." + sform).elements[sField+"_image"].src=imgSrc.src;
		}else {
			if (ImageURL != "") {
				if ((ImageURL.toUpperCase()).indexOf(".DOC") > 0) {
					//word document
					imgSrc.src = "images/word.gif";
				}else if ((ImageURL.toUpperCase()).indexOf(".HTM") > 0 || (ImageURL.toUpperCase()).indexOf(".HTML") > 0) {
					//html page (Link)
					imgSrc.src = "images/html.gif";
				}else if ((ImageURL.toUpperCase()).indexOf(".XLS") > 0) {
					//Excell document
					imgSrc.src = "images/excel.gif";
				}else if ((ImageURL.toUpperCase()).indexOf(".PPT") > 0) {
					//Power Point document
					imgSrc.src = "images/powerpoint.gif";
				}else if ((ImageURL.toUpperCase()).indexOf(".ZIP") > 0) {
					//Zip File
					imgSrc.src = "images/winzip.gif";
				}else {
					//Use generic image
					imgSrc.src = "images/document.jpg";
				}
				document [sField+"_image"].src=imgSrc.src;
			}
		}
	
		if (ImageURL != "") {
			eval("document." + sform).elements[sField].value=ImageURL;
		}
	}
}

/*
function PrintThisPage() 
{ 
	var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
	sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 
	
	if(document.getElementById('PrintContent')) {
		var sHTML = document.getElementById('PrintContent').innerHTML; 
	}else{
		return false;
	}
	   
	var winPrint=window.open("blank.asp", "PrinterFriendly", sOption); 
	winPrint.document.open(); 
	winPrint.document.write('<html><body>'); 
	winPrint.document.write(sHTML);          
	winPrint.document.write('</body></html>'); 
	winPrint.document.close(); 
	winPrint.focus(); 
}
*/