﻿function closewindow()
{
	window.close();	
}	



function closerefreshwindow()
{	
	closewindow();
	window.opener.document.forms(0).submit();	
}
 
function ControlNumeric( obj,e,sep )
{
	var k;	
	k = e.keyCode;		
	if (sep == ",")
	{
		if ((k==46) || (k==44 && (obj.value.indexOf(sep,0) >= 0 ||  obj.value.length == 0)))
		{
			return false;
		} 
	}
	if (sep == ".")
	{
		if ((k==44) || (k==46 && (obj.value.indexOf(sep,0) >= 0 ||  obj.value.length == 0)))
		{
			return false;
		}
	}
	if( k>=32 && k<=255 ) {
		if( (k>=48 && k<58) || k==44 || k==46) 
			return true;
		return false;
	}
}	



var count = 0;	
function StrToMoney(currency) {	
	var num = new String();
	num = currency;
	while (num.indexOf('.',0)>0) {
		num = num.replace('.','');
	}
	return num;
}
 
function FormatNum(thisis) {	
	var tempstr,newstr,str;
	var commapos,aftercomma;
	str = thisis.value;
	str = StrToMoney(str);	
	var mantissa = new String();	
	var tmp = new String();
	tmp = str;			
	if (tmp.indexOf(",",0)>0) {
		str = tmp.substring(0,tmp.indexOf(",",0))
		mantissa = tmp.substring(tmp.indexOf(",",0),tmp.length)
	}

	var output
	commapos=str.indexOf(";");
	if (commapos>=0) {
		aftercomma=str.substr(commapos);
		str=str.substr(0,commapos);
	}
	else aftercomma="";
	
	if (str.length > 3) {
		tempstr=str;
		newstr="";
		while (tempstr.length>3)
		{
			newstr="."+tempstr.substr(tempstr.length-3)+newstr; 
			tempstr=tempstr.substr(0,tempstr.length-3);
		}		
		output = tempstr+newstr+aftercomma;
		if (mantissa.length>0) output+= mantissa;
		thisis.value = output;
	}
	else
	{
		str		= str.replace('.','');
		output	= str;
		if (mantissa.length>0) output+= mantissa;
		thisis.value = output;
	}
	return true;
}

function FormatNumForNegative(thisis) 
{     
      var tempstr,newstr,str;
      var commapos,aftercomma;
      var isItNegative = 0;
      str = thisis.value;
      if(str.indexOf('-',0) >=0 )
      {
            isItNegative = 1;
            str   = str.replace('-','');
      }
      str = StrToMoney(str);  

      var mantissa = new String(); 
      var tmp = new String();
      tmp = str;              
      if (tmp.indexOf(",",0)>0) 
      {
            str = tmp.substring(0,tmp.indexOf(",",0))
            mantissa = tmp.substring(tmp.indexOf(",",0),tmp.length)
      }
      var output
      commapos=str.indexOf(";");

      if (commapos>=0) 
      {
            aftercomma=str.substr(commapos);
            str=str.substr(0,commapos);
      }
      else aftercomma="";
      
      if (str.length > 3) 
      {
            tempstr=str;
            newstr="";
            while (tempstr.length>3)
            {
                  newstr="."+tempstr.substr(tempstr.length-3)+newstr; 
                  tempstr=tempstr.substr(0,tempstr.length-3);

            }           

            output = tempstr+newstr+aftercomma;
            if (mantissa.length>0) output+= mantissa;
            if(isItNegative == 1)
                  output      = '-' + output;
            thisis.value = output;
      }
      else
      {
            str         = str.replace('.','');
            output      = str;
            if (mantissa.length>0) output+= mantissa;
            if(isItNegative == 1)
                  output      = '-' + output;
            thisis.value = output;
      }
      return true;
}

function ControlNumericForNegative( obj,e )
{
      var k;
      k = e.keyCode;    
      if ((k==46) || (k==44 && (obj.value.indexOf(',',0) >= 0 ||  obj.value.length == 0)))
      {
            return false;
      }
      if( k>=32 && k<=255 ) 
      {
            if( (k>=48 && k<58) || k==44 || k==46) 
            {
                  var   maxLength   = 0;
                  if(obj.value.indexOf('-',0) >= 0)
                        maxLength   = obj.value.length;
                  else 
                        maxLength   = obj.value.length + 1;

                  if(obj.getAttribute("maxlength") > maxLength)
                        return true;                 
            }
            else if (k==45 && obj.value.length==0)
            {
                  return true;                 
            }           
            return false;
      }
}

function confirmsendmail(){ 
	if (confirm("İşlemini tamamlamış kişilere mail göndermek istediğinizden emin misiniz?"))
	{
		return true; 
	}
	else 
	{
		return false; 
	}
}

function confirmdelete(){ //Omer AGCA
	if (confirm("Kaydı silmek istediginizden eminmisiniz?"))
	{
		return true; 
	}
	else 
	{
		return false; 
	}
}
function openpopupwithconfirmandproperty(message, url, showConfirm, openpopup, property){ //Omer AGCA
	if (showConfirm)
	{
		if (confirm(message))
		{
			if (openpopup)
			{
				window.showModalDialog('PopUp.aspx?GoUrl=' + url,window,property);
				return false;
			}
			else
			{
				return true;
			}
		}
		else
		{
			return false;
		}	
	}
	else
	{
		window.showModalDialog('PopUp.aspx?GoUrl=' + url,window,property);
		return false;
	}
}
function openpopupwithconfirm(message, url, showConfirm, openpopup){ //Omer AGCA
	return openpopupwithconfirmandproperty(message,url,showConfirm,openpopup, 'width=700,height=500,resizable=yes,scrollbars=yes');
}

var printit = 0
function printpage(obj)
{
	if( obj!=null ) {
		obj.style.visibility ="hidden";
		obj.style.visibility ="hidden";
		document.all["btn_Back"].style.visibility ="hidden";
		document.all["btn_Back"].style.visibility ="hidden";		
		printit = 1;
	}
	if (window.print) {
		setTimeout('window.print();',100);
	}
	else {
		alert( "Internet tarayıcınıza komut yollanamadı, lütfen Ctrl+P ye basın veya menüden 'Yazdır' ı seçin" );
	}
}
			
function setprintcontrolsvisible()
{
		
		if (printit == 0)
		{			
			document.all["btn_Prnt"].style.visibility ="visible";
			document.all["btn_Back"].style.visibility ="visible";
			document.all["divDescr"].style.visibility ="visible";
		}
		else
			printit = 0
			
}

function openhelppopup(url)
{	
		alert('Hatali');
}

function openhelppopup(url)
{
	if (url != '')
		openpopup('help/' + url);
	else 
		alert('Bu sayfa için yardım sayfası oluşturulmamıştır');
}	

function openpopupwithp(name,url,property)
{		
	window.open(url,name,property).focus();
}


function openpopup(url)
{		
	window.open(url,null,'width=700,height=500,resizable=yes,scrollbars=yes').focus();
}


function opensmallpopup(url)
{	
	window.showModalDialog('Popup.aspx?GoUrl=' + url ,window,'dialogHeight:250px;dialogWidth:500px;resizable:yes');	

}

function resetActionValue()
{
	if (document.forms(0).actionType != null)
		document.forms(0).actionType.value = 'S';
}

function opensmallpopupwithpHedef(url)
{
	opensmallpopupwithp(url,'dialogHeight:500px;dialogWidth:600px;resizable:yes');
}
function opensmallpopupwithp(url,property)
{		
	if (document.forms(0).actionType != null)
		document.forms(0).actionType.value = 'S';
	document.forms(0).submit();	
	window.showModalDialog('Popup.aspx?GoUrl=' + url ,window,property);
	//window.open(url,null,'width=500,height=250,resizable=yes,scrollbars=yes');
}

function opensmallpopupwithpNoSubmit(url,property)
{		
	window.showModalDialog('Popup.aspx?GoUrl=' + url ,window,property);
	//window.open(url,null,'width=500,height=250,resizable=yes,scrollbars=yes');
}

function openpopupwithoutsubmit(url,property)
{		
	if (document.forms(0).actionType != null)
		document.forms(0).actionType.value = 'S';
	window.showModalDialog('Popup.aspx?GoUrl=' + url ,window,property);
	//ex property: "dialogHeight:600px;dialogWidth:700px;resizable:yes"
}


function opensearchpopup(idname,fullname,url,refreshval,level)
{
	var openurl;
	openurl = url + '?idname=' + idname + '&fullname=' + fullname + '&refresh=' + refreshval + '&level=' + level;
	openpopup(openurl)
}

function openpopup(url,activeObj)
{
    i++;             
    setclickposition(activeObj);    
    window.open(url,null,'width=700,height=500,resizable=yes,scrollbars=yes').focus();
}

function setclickposition(activeObj)
{
    var obj;
    obj = document.forms(0).item('positionY');
    if ( obj != null)
    {
    obj.value =  '40';      
		if (activeObj != null)
		{        
			obj.value = GetOffset(activeObj)-30;                                                      
		}                          
    }
}

function scrooltoY(val)
{
	var obj          = document.forms(0).item('positionY');	
	if ( obj != null && val != null)
		window.scrollTo(0,val); 
}

function GetOffset(activeObj)
{
	var i=0;
	var obj = activeObj ;        
	while( obj != null )
	{           
		if( obj != window.document.body )
		{
			i +=obj.offsetTop;
			obj = obj.offsetParent ;
		}
		else
		{
			obj = null;
		}
	}
	return i;
}

function openmodalpopupDescriptionWithMode(ID, ForeignID, ForeignType, Type, SaveMode)
{
	window.showModalDialog('Popup.aspx?GoUrl=Description_Form.aspx&ID=' + ID + "&ForeignID=" + ForeignID + "&ForeignType=" + ForeignType + "&Type=" + Type + "&SaveMode=" + SaveMode,window,'dialogHeight:350px;dialogWidth:550px;resizable:yes');
	document.forms(0).submit();
}
function openmodalpopupDescription(ID, ForeignID, ForeignType, Type)
{
	//setclickposition(activeObj);
	openmodalpopupDescriptionWithMode(ID, ForeignID, ForeignType, Type,'');
}
function checkBoxAction(check, chkNameStart) {
    var i, j, k;                      
    var str = new String();
    
    j=document.forms(0).elements.length;
    for(i=0;i<j;i++) {
    if (document.forms(0).elements(i)) {			
		if (document.forms(0).elements(i).checked != null)
		{
			if (document.forms(0).elements(i).name.indexOf(chkNameStart,0) > -1) 
			{				
				if (!document.forms(0).elements(i).disabled)
				{
					if (check == 'Toggle') {
						document.forms(0).elements(i).checked = !document.forms(0).elements(i).checked;
					} else 
						document.forms(0).elements(i).checked = check;
					}
				}          
			}
		}          
	}          
}



function GotoUrl(url)
{
	location.href = url;
}

function submitpage()
{
	document.forms(0).submit();
}

function submiturl(urlstr)
{		
	document.forms(0).action = urlstr;
	document.forms(0).submit();
}

function resetcontrolvalues(key1,key2)
{
	var obj1,obj2;
	obj1 = document.forms(0).item(key1);
	obj2 = document.forms(0).item(key2);
	if (obj1 != null)
		obj1.value = '';
	if (obj2 != null)
		obj2.value = '';
}

function GoBack()
	{
		var BackURL;
		BackURL = '';
		
		if (BackURL == "")
		{
			history.back(-1);
		}
		else
		{
			BackURL = BackURL.replace("||", "&")
			BackURL = BackURL.replace("||", "&")
			BackURL = BackURL.replace("||", "&")
			BackURL = BackURL.replace("||", "&")
			BackURL = BackURL.replace("||", "&")
			BackURL = BackURL.replace("||", "&")
			location.href = BackURL;	
		}
	}
	
	function openConfirmation(actionT)
			{
				resetActionValue();
				opensmallpopupwithp('Konfirmasyon_Form.aspx?Action=' + actionT,'dialogHeight:200px;dialogWidth:500px;resizable:yes');					
			}
			
function openclosemenu(str,cnt)
{
	var i, resume, obj;
	var imgObj;
	resume	= true;	
	if (cnt == 0 ) return;
	
	i = 0;	
	for (i=0;i<100;i++)
	{	
		obj = document.all('tr_' + i);			
		imgObj = document.all('img_' + i);			
		if (obj != null)
		{
			obj.style.visibility = 'hidden';
			obj.style.position = 'absolute';		
			if (imgObj != null)
			{
				setMenuImage(imgObj,'Images/menuGroup.gif')
			}
		}		
	}	
	obj = document.all(str);
	imgObj = document.all('img_' + str.substr(3,str.length-3));
	if (obj != null)
	{
		obj.style.visibility = 'visible';
		obj.style.position = 'relative';
		if (imgObj != null)
		{
			setMenuImage(imgObj,'Images/menuGroupDown.gif')
		}
	}
}

function setMenuImage(imgobj, imgPath)
{				
	imgobj.src = imgPath;
}

function ShowAndHideMenu()
{
	var obj_bizmenu,obj_contenttd,obj_menuLink;
	
	obj_bizmenu = document.all.bizmenu;
	obj_contenttd = document.all.contenttd;
	obj_menuLink = document.all.menuLink;
	
	if (obj_bizmenu != null)
	{
		
		if(obj_bizmenu.style.visibility == "hidden")
		{
			if (obj_contenttd != null)
				obj_contenttd.colSpan = '2';
			
			obj_bizmenu.style.visibility = 'visible';
			obj_bizmenu.style.position = 'relative';
			obj_menuLink.innerText = 'Menü Kapat';
		}
		else
		{
			if(obj_contenttd != null)
				obj_contenttd.colSpan = '3';
						
			obj_bizmenu.style.visibility = 'hidden';
			obj_bizmenu.style.position = 'absolute';
			obj_menuLink.innerText = 'Menü Aç';
			
			openclosemenu('99',99);	
		}
	}
}
/*Ömer AĞCA : script.js içeriğini buraya ekledim*/
function OpenLmsTree(idname,TextName, SirketId,postBack)
{
	popUp = window.open('LmsTree.aspx?formname=' + document.forms[0].name + 
		'&idname=' + idname + '&TextName=' + TextName + '&SirketId=' + SirketId + '&postBack=' + postBack, 
		'popupcal', 
		'width=600,height=600,scrollbars=yes');
}
var popUp; 

function OpenCalendar(idname, postBack)
{
	popUp = window.open('Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&postBack=' + postBack, 
		'popupcal', 
		'width=165,height=208,left=200,top=250');
}
function SetDate(formName, id, newDate, postBack)
{
	//alert(formName);
	//alert(id);
	//alert(newDate);
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}						
function OpenNotPopUp(NOT_YAZAN, NOT_YAZILAN,NOTYERI,NOT_KODU)
{
	popUp = window.open('NotPopUp.aspx?NOT_YAZAN=' + NOT_YAZAN + 
		'&NOT_YAZILAN=' + NOT_YAZILAN + '&NOT_YERI=' + NOTYERI+ '&NOT_KODU=' + NOT_KODU, 
		'popupcal', 
		'width=700,height=520,left=250,top=250');
}

function SetLmsIdText(formName, id,text, NewId,NewText, postBack)
{
	//alert(formName);
	//alert(id);	
	//alert(text);
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = NewId;
	theform.elements[text].value = NewText;
	if (postBack)
		__doPostBack(id,'');
}

