var BrowserType
var Saved = 0;
//var PageAction;
function MM_checkBrowser() { //v4.0
  var app=navigator.appName
  if (app.indexOf('Netscape') != -1) {
    BrowserType = 'Netscape'
  } else if (app.indexOf('Microsoft') != -1) {
	BrowserType = 'Microsoft'
  } else {
	  BrowserType = 'UnKonwn'
  }
}
//MM_checkBrowser() ' For Default Execution

function SmallerGreaterDate(FirstDate, SecondDate){
	var FDate = new Date(FirstDate)
	var SDate = new Date(SecondDate)

	if (FDate < SDate) {
		return true; // Second  Date Is Greater
	}
	else{
		return false; // First Date Is Greater
	}
}

function datediff(Interval, StartDate, EndDate){
	var Result
	datDate2= Date.parse(StartDate); 
	datDate1= Date.parse(EndDate); 
	days = ((datDate1-datDate2)/(24*60*60*1000))
	if (Interval == 'y' || Interval == 'Y'){
		Result = days/365;
	}else if (Interval == 'm' || Interval == 'M'){
		Result = days/12;
	}
	else if (Interval == 'd' || Interval == 'D'){
		Result = days;
	}
	return Result;
}
function DisplayDiv(DivName){// To display div tags of the months
	//DivName.style.visibility = 'visible';
	document.getElementById(DivName).style.visibility = "visible";	
}
function HideDiv(DivName){// To Hide div tags of the months
	//DivName.style.visibility = 'hidden';
	document.getElementById(DivName).style.visibility = 'hidden';
}
function checkAllwithHighlight(field,element)
{
	var x = 0;
	if(element.checked == true){
		for (i = 0; i < field.length; i++){
			if (field[i].disabled == false){
				field[i].checked = true ;
			}
			if (x == 0) {x = 1} else { x=0}
			highlight_row(field[i],x);
		}
	} else {
		x = uncheckAll(field,element)
	}
}
function uncheckAll(field,element)
{
var x = 0;
	for (i = 0; i < field.length; i++){
		field[i].checked = false ;
		if (x == 0) {x = 1} else { x=0}
		highlight_row(field[i],x);
	}
}

function highlight_row(the_element,EvenOdeRow) {
	if(the_element.checked == true) {
		the_element.parentNode.parentNode.className = 'TdChecked';
	} 
	else {
		if (EvenOdeRow ==0) {
			the_element.parentNode.parentNode.className = 'TdUnchecked';
		}else{
			the_element.parentNode.parentNode.className = 'TdUnchecked2';
		}
	}
}


function Move_otherPage(CurrentPage ,frm, Action, SendTo){
	if (UserReadOnly == false){
		if (ValidatePagesData(CurrentPage,frm) == true){
			frm.method = "post";
			frm.action = Action
			frm.submit();
		}
	}else{
		window.location = SendTo
	}
}


function ConfirmSave(CurrentClaimNo)
{	if (UserReadOnly == true || Saved == 1) return true;
	if (CurrentClaimNo != ''){
		var r = showModalDialog(HomeURL+'/InsuranceWeb/Includes/ConfirmSave.asp?ClaimNo='+CurrentClaimNo,
			null,
			"dialogWidth:456px;dialogHeight:140px;resizable:no;scroll:no;center:yes;resizeable:no;status:no;help:yes");
		if(r)
		{
			if ((r.del)==1){
				//CS = showModalDialog(HomeURL+'/InsuranceWeb/Includes/SaveClaim.asp',
				//	null,
				//	"dialogWidth:456px;dialogHeight:140px;resizable:no;scroll:no;center:yes;resizeable:no;status:no;help:yes");
				OpenSaveWindow();
				return false;
			}else if((r.del)==2){
				return true;
			}else if((r.del)==3){
				return false;
			}else {
				return false;
			}
		}
	}else{
		return true;
	}
}

function ConfirmSave2(CurrentClaimNo)
{	if (UserReadOnly == true || Saved == 1) return true;
	if (CurrentClaimNo != ''){
		var r = showModalDialog(HomeURL+'/InsuranceWeb/Includes/ConfirmSave.asp?ClaimNo='+CurrentClaimNo,
			null,
			"dialogWidth:456px;dialogHeight:140px;resizable:no;scroll:no;center:yes;resizeable:no;status:no;help:yes");
		if(r)
		{
			if ((r.del)==1){
				return 1;
			}else if((r.del)==2){
				return 2;
			}else if((r.del)==3){
				return 3;
			}else {
				return 3;
			}
		}
	}else{
		return 1;
	}
}

function ConfirmClear(CurrentClaimNo)
{	if (UserReadOnly == true) return false;
	if (CurrentClaimNo != ''){
		var r = showModalDialog(HomeURL+'/InsuranceWeb/Includes/ConfirmClear.asp?ClaimNo='+CurrentClaimNo,
			null,
			"dialogWidth:456px;dialogHeight:140px;resizable:no;scroll:no;center:yes;resizeable:no;status:no;help:yes");
		if(r)
		{
			if ((r.del)==1){
				//CS = showModalDialog(HomeURL+'/InsuranceWeb/Includes/ClearClaim.asp',
				//	null,
				//	"dialogWidth:456px;dialogHeight:140px;resizable:no;scroll:no;center:yes;resizeable:no;status:no;help:yes");
				//window.open (HomeURL+'/InsuranceWeb/Includes/ClearClaim.asp','','scrollbars=no,width=400,height=140')
				window.location = HomeURL+'/InsuranceWeb/Asp/ClearClaimFile.asp'
				return false;
			}else if((r.del)==2){
				return false;
			}else if((r.del)==3){
				return false;
			}else {
				return false;
			}
		}
	}else{
		alert('No Claim Found To Be Clear...!');
		return false;
	}
}

function SelectPageFire(){
	document.form1.method = 'post';
	document.form1.Action = document.form1.CurrentPage.value
	//'Search_Claims.asp?Action=y&CurrentPage='+document.form1.CurrentPage.value
	document.form1.submit();
}
function NextPrevious_Page(PageNo){
	document.form1.CurrentPage.value = PageNo
	SelectPageFire();
}

function ShowChildWindow(theURL, width, height, scrollyn) { //v2.0
  //window.open(theURL,winName,features);
	leftPos = 0;
	topPos = 0;
	if (screen) {
		leftPos = ((screen.width - width )/ 2) 
		topPos = ((screen.height - height)/ 2) 
	} 
	win = open (theURL,'UploadImage','scrollbars='+scrollyn+',width='+width+',height='+height+',left='+leftPos+',top='+topPos);
	win.opener = top;
}

function ReturnSelected(field,msg)
{
	var x = 0
	for (i = 0; i < field.length; i++){
		if (field[i].checked == true) {
			x = 1;
			return i;
		}
	}
	if (x==0){
		if (msg != ''){
			alert(msg);
		}
		return false;
	}
}

function SeletAllChecks(field,element)
{
	var x = 0;
	if(element.checked == true){
		for (i = 0; i < field.length; i++){
			if (field[i].disabled == false){
				field[i].checked = true ;
			}
			if (x == 0) {x = 1} else { x=0}
		}
	}else{
		x = UnSeletAllChecks(field,element)
	}
}
function UnSeletAllChecks(field,element)
{
var x = 0;
	for (i = 0; i < field.length; i++){
		field[i].checked = false ;
		if (x == 0) {x = 1} else { x=0}
	}
}

function FireSubmit(URL){
	document.form1.method = 'post';
	document.form1.action = URL
	document.form1.submit();
}


function ShowUserDetails(userid){
	//var width = screen.width
	//var height = screen.height
	//ShowChildWindow('member_details.php?section=general&userid='+userid,width,height,'yes');
	window.location = 'userprofile.php?profileid='+userid;
}
function getId(id){
	return document.getElementById(id);
}