
function openWindow(url, options)

	{
		if (options == '') options = "width=400,height=250,resizable=no,scrollbars=yes" ;
		
		window.open(url,'',options);
	}
	
function openModalWindow(url, options)

	{
		if (window.showModalDialog) {
		
			window.showModalDialog(url,'',options);
	} 
	
	else
	
	{
		window.open(url,'',options);
	}
} 

function fnShowHelp(id)
	{
		var out = "help.aspx?id=" + id;
		window.open(out,"","width=400,height=250,resizable=no,scrollbars=yes");
	}
function showFTStandard()	{		alert('x');		var page="ft_standard.aspx";		window.open(page,'','width=400,height=250,resizable=no,scrollbars=yes');	}function setActiveStyleSheet(title) {  var i, a, main;  if (title != 'null'){      for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {         if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {            a.disabled = true;            if(a.getAttribute("title") == title) a.disabled = false;         }      }  }}function getActiveStyleSheet() {  var i, a;  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");  }  return null;}function getPreferredStyleSheet() {  var i, a;  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {    if(a.getAttribute("rel").indexOf("style") != -1       && a.getAttribute("rel").indexOf("alt") == -1       && a.getAttribute("title")       ) return a.getAttribute("title");  }  return null;}function createCookie(name,value,days) {  if (days) {    var date = new Date();    date.setTime(date.getTime()+(days*24*60*60*1000));    var expires = "; expires="+date.toGMTString();  }  else expires = "";  document.cookie = name+"="+value+expires+"; path=/";}function readCookie(name) {  var nameEQ = name + "=";  var ca = document.cookie.split(';');  for(var i=0;i < ca.length;i++) {    var c = ca[i];    while (c.charAt(0)==' ') c = c.substring(1,c.length);    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);  }  return null;}window.onload = function(e) {  var cookie = readCookie("style");  var title = cookie ? cookie : getPreferredStyleSheet();  setActiveStyleSheet(title);}window.onunload = function(e) {  var title = getActiveStyleSheet();  createCookie("style", title, 365);}var cookie = readCookie("style");var title = cookie ? cookie : getPreferredStyleSheet();setActiveStyleSheet(title);function underline1(elem){      for(i=0; (a = document.getElementsByTagName("a")[i]); i++) {         a.getAttribute("class") = "";       }      elem.getAttribute("class") = "on";}function toggle( targetId ){  if (document.getElementById){  		target = document.getElementById( targetId );  			if (target.style.display == "none"){  				target.style.display = "";  			} else {  				target.style.display = "none";  			}  	}}
function checkIt(firstcb,secondcb){
	if (firstcb.checked){
		//eval(form + '.' + secondcb + '.checked=false;');
		document.getElementById(secondcb).checked=false;
	}else{firstcb.checked=true;}
}

function fillYear(){
	document.frmIndex.CYear.selectedIndex = 2005
}

function fillDay(maxval){
	while (document.frmIndex.CDay.options.length > 0){
		document.frmIndex.CDay.options[0] = null;
	}
	for(i=1;i<=maxval;i++){
		var oOption = document.createElement("OPTION");
		oOption.text=i;
		oOption.value=i;
		document.frmIndex.CDay.add(oOption);
	}
}

function changeMonths(month){
	if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12){
		var selVal = document.frmIndex.CDay.value - 1;
		fillDay(31);
		//if selected day is biger then the max in this month not select it, sel the first
		if (selVal <= 31){document.frmIndex.CDay.selectedIndex = selVal}else{document.frmIndex.CDay.selectedIndex = 0};
	}else if (month==4 || month==6 || month==9 || month==11 ){
		var selVal = document.frmIndex.CDay.value - 1;
		fillDay(30);
		//if selected day is biger then the max in this month not select it, sel the first
		if (selVal < 30){document.frmIndex.CDay.selectedIndex = selVal}else{document.frmIndex.CDay.selectedIndex = 0};				
	}else if (month==2){
		var ValDays = 28;
		if (document.frmIndex.CYear.options[document.frmIndex.CYear.selectedIndex].value % 4 == 0) ValDays = 29 ;
		var selVal = document.frmIndex.CDay.value - 1;
		fillDay(ValDays);
		//if selected day is biger then the max in this month not select it, sel the first
		if (selVal < ValDays){document.frmIndex.CDay.selectedIndex = selVal;}else{document.frmIndex.CDay.selectedIndex = 0; alert('Your birth DAY value has been reseted. \r\n No such day for selected month! \r\n Please select the correct birth DAY from list.'); document.frmIndex.CDay.focus();};				
	}
}

function initBirthDate(){
	if (document.frmIndex.BRYear.value != 1){
		if (document.frmIndex.BRDay.value >=1 && document.frmIndex.BRDay.value <=31)
			document.frmIndex.CDay.selectedIndex=document.frmIndex.BRDay.value-1;
		if (document.frmIndex.BRMonth.value >=1 && document.frmIndex.BRMonth.value <=12)
			document.frmIndex.CMonth.selectedIndex=document.frmIndex.BRMonth.value -1;
		document.frmIndex.CYear.selectedIndex = 2005 - document.frmIndex.BRYear.value;
	}else {fillYear();}
}

function changeYear(){
	changeMonths(document.frmIndex.CMonth.options[document.frmIndex.CMonth.selectedIndex].value);
}

function LoadBirthDates(){
	fillDay(31);
	initBirthDate();
}

// Put focus on form
function putFocus(formInst, elementInst) {
	if (document.forms.length > 0) {
	document.forms[formInst].elements[elementInst].focus();
	}
}


// function to validate a form and set focus if error
function validateForm()
{

	if (window.loaded != true)
	{
		return false;
	} 
	else 
	{ 
		Page_ClientValidate(); 
		if (Page_IsValid)
		{
			//showhide('divError', 'none');
		}
		else
		{ 
			setValidateFocus() ;
		} 
	}
}

function setValidateFocus() 	
{	

	var first = -1
	
	for (i=0; i < Page_Validators.length; i++)
	{
		if (!Page_Validators[i].isvalid) {
		
				var first = i;
				var focusfield = Page_Validators[i].controltovalidate
				break;
			
		}				
	}
	
	if (first != -1) {
		putFocus(0, Page_Validators[first].controltovalidate);
	}

}

