﻿// JavascriptStore
function pviiClassNew(obj, new_style) 
{
    if(obj)
	    obj.className = new_style;
}
function OpenDialogWindow(url, name, w, h)
{
	t = (screen.height/2)-(h/2);
	l = (screen.width/2)-(w/2);	
	win = window.open(url, name, 'toolbar=0, status=1, menubar=0, location=0, resizable=1, scrollbars=auto, dependent=1, width=' + w + ', height=' + h + ', top=' + t + ', left=' + l);
	win.focus();
}
function getTotalOffsetWidth(element) 
{
	var offset = 0;
	for(var i = element; i && i.tagName != "BODY"; i = i.offsetParent)
		offset+=i.offsetWidth;
	return offset;
}
function GetDialogResult(command, parameter)
{
	FindObject('DialogResultCommand').value=command;
	FindObject('DialogResultParameter').value=parameter;
	FindObject('DialogResultIsReceipt').value='1';
	FindObject('Form1').submit();
}

function Popup(url,w,h,rs,sc){
	t = (screen.height/2)-(h/2);
	l = (screen.width/2)-(w/2);	
	window.open(url,'','toolbar=0, status=1, menubar=0, location=0, resizable='+rs+', scrollbars='+sc+', dependent=1, width=' + w + ', height=' + h + ', top=' + t + ', left=' + l).focus();
}
function popup(url,w,h){
	t = (screen.height/2)-(h/2);
	l = (screen.width/2)-(w/2);	
	window.open(url,'','toolbar=0, status=1, menubar=0, location=0, resizable=1, scrollbars=1, dependent=1, width=' + w + ', height=' + h + ', top=' + t + ', left=' + l).focus();
}
function OpenTankInfo(UsrID)
{
    //Popup("/TankInfo.aspx?UI="+UsrID,650,600,0,1);
    
}

var isNS = (navigator.appName.indexOf("Netscape")!=-1); 

function FindObject(n, d)
{
  var p,i,x;  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n]; 
		for (i=0;!x&&i<d.forms.length;i++) 
				x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=FindObject(n,d.layers[i].document);
  if(!x && document.getElementById) 
		x=document.getElementById(n); 
	return x;
}

function onlyNumber(e) 
{
	var keyCode = (isNS) ? e.which : e.keyCode;
	if ((keyCode<48 || keyCode>57)&&keyCode!=8&&keyCode!=0){
	return false;}
}

function onlyLetter(e) 
{
	var keyCode = (isNS) ? e.which : e.keyCode;
	if (keyCode > 47 && keyCode<58){
		return false;
	}
}

function CheckEmail(TmpStr) 
{
	if (TmpStr=="")
	{
		return true;
	}
	else
	{
		var i, atPos, atPos2, InvalidChars=" üÜğĞışŞİçÇöÖ!#/*{[()]}";

		for (i=0; i<InvalidChars.length; i++)
			if (TmpStr.indexOf(InvalidChars.charAt(i)) != -1) {
				return false;
			}
		atPos = TmpStr.indexOf("@");
		atPos1 = TmpStr.indexOf(".");
		atPos2 = TmpStr.indexOf("@", atPos+1);
		if ((atPos < 1) || (atPos1 < 1) || (atPos2 != -1)) {
			return false;
		}
	}
}

function autoTab(input,focus, len, e) { 
	var keyCode = (isNS) ? e.which : e.keyCode; 
	if (keyCode == 13)  window.event.keyCode = 9;
	var filter = (isNS) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46]; 
	if(input.value.length >= len && !containsElement(filter,keyCode)) { 
		input.value = input.value.slice(0, len); 
		document.all[focus].focus();
	//	input.form[(getIndex(input)+1) % input.form.length].focus(); 
	} 
	return true; 
}

function trim(str)
{
	while(str.charAt(0)==' ')
		str=str.substring(1,str.length);
	while(str.charAt(str.length-1)==' ')
		str=str.substring(0,str.length-1);
	return str;
}

function isNumber(theElement)
{
	var s = Math.abs(theElement.value);
	var filter=/(^\d+$)/;
	if (s.length == 0 ) return true;
	if (isNaN(theElement)) return true;
	if (filter.test(s))
		return true;
	else {
		return false;
	}
}

function PressTabInsteadOfEnter(elementIDToFocus, doPostBackForElement){
		keyCode=(document.layers)?e.which:window.event.keyCode;
		if (keyCode == 13){
			window.event.keyCode = 9;
			FindObject(elementIDToFocus).focus();
			if (doPostBackForElement)
				__doPostBack(elementIDToFocus,'');
		}
		return true;
}

function Flash(objID)
{
		var obj  = FindObject(objID);
		
		if (obj.style.visibility == 'hidden')
			obj.style.visibility = 'visible';
		else
			obj.style.visibility = 'hidden';
		
		window.setTimeout("Flash('"+objID +"')", 500);
}

function SetVisibilityForElement(objID)
{
    var obj  = FindObject(objID);
    if (obj.style.display == 'none')
			obj.style.display = 'block';
		else
			obj.style.display = 'none';
		
}
function keypress_number(isdecimal) {

	try
	{
		var kc = window.event.keyCode;
		var t = window.event.srcElement.value ;
		
			if (isdecimal) 
			{
				var idxOfComma = t.indexOf(',');
				if (idxOfComma != -1) {
					if( (kc >= 48 && kc <= 57) == false) 
					{
						window.event.keyCode = 0;
					}
					else 
					{
						var rNmb = t.substring(idxOfComma+1);
						if (rNmb.length == 2)
						window.event.keyCode = 0;
					}
				}
				else 
				{
					if ((kc >= 48 && kc <= 57 || kc == 44) == false) 
					{
						window.event.keyCode = 0;
					}
		            
					var ft = removeFormat(t, ".");
					if (ft.length >= 14 && (kc >= 48 && kc <= 57)) {
						window.event.keyCode = 0;
					}
				}
			}
			else 
			{
				if ((kc >= 48 && kc <= 57) == false) 
				{
					window.event.keyCode = 0;
				}
				
				
			}
	}
    catch(e)
    {
        /*alert(e.message);*/
    }
        
	
}


/*
	var slideSpeed=10;
	var slideTimer;
	var totalHeight=0;
	var paused=false;
	var t=0;
	
	function SlideStart()
	{		
		SetItemOrder();
		SlideTable();		
	}
	
	function SlideTable()
	{		
		
		var obj=getReference("Announcement1_rptAnnouncements__ctl0_tblItem");
		var i=1;
		
		while(obj!=null)
		{
			var top=parseInt(obj.style.top.replace("px",""));
			var divHeight=getHeight(obj);//getHeight("Announcement1_rptAnnouncements__ctl"+(i-1).toString()+"_divItem");
			
			if(top+divHeight<0)
			{				
				obj.style.top=(totalHeight-divHeight)+"px";
			}
			else
			{
				obj.style.top=(top-1)+"px";
			}
			obj=getReference("Announcement1_rptAnnouncements__ctl"+i.toString()+"_tblItem");
			i+=1;
		}
			
		//t=t-1;
		slideTimer=setTimeout("SlideTable();",slideSpeed);
				
	}
	
	function getReference(id)
	{
		//return document.getElementById(id);
		//return document.all(id);
		return  xDOM(id,0);
		
				
	}
	
	function SetItemOrder()
	{
		var obj=getReference("Announcement1_rptAnnouncements__ctl0_tblItem");
		var i=1;
		var h=300;
		
		while(obj!=null)
		{
			//obj.style.position="absolute";
			//alert(obj.offsetHeight);
			var height=getHeight(obj);//parseInt(obj.style.height.replace("px",""));//getHeight("Announcement1_rptAnnouncements__ctl"+(i-1).toString()+"_divItem");
			
			obj.style.top=h+"px";
			//alert(obj.style.left);
			h=h+height+5;
			totalHeight=totalHeight+height+5;
			obj=getReference("Announcement1_rptAnnouncements__ctl"+i.toString()+"_tblItem");
			i=i+1;
		}
	}
	
	function getHeight(obj)
	{
		//return parseInt(obj.style.posHeight);
		//return obj.clientHeight; //FireFox'da çalışıyor.
		//return obj.document.heigth.replace("px","");
		//return obj.scrollHeight;
		//return obj.offsetParent.height;
		//return obj.style.height.replace("px","");
		//alert(obj.getAttribute("height"));
		return obj.offsetHeight;
		
		if(obj.offsetHeight)
			return obj.offsetHeight;
		if(obj.clip)
			return obj.clip.height;
		
		return 0;		
			
		
	}
	
	function Pause()
	{
		//paused=true;
		clearTimeout(slideTimer);
	}
	
	function Play()
	{
		//paused=false;
		slideTimer=setTimeout("SlideTable();",slideSpeed);
	}
	
	var aDOM = 0, ieDOM = 0, nsDOM = 0; 
	var stdDOM = document.getElementById;
	if (stdDOM)
		aDOM = 1;
	else 
	{
		ieDOM = document.all;
		if (ieDOM)
			aDOM = 1;
		else
		{
			var nsDOM = ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) ==4)); if (nsDOM) aDOM = 1;
		}
	}

	
	function xDOM(objectId, wS) 
	{
		if (stdDOM) return wS ? document.getElementById(objectId).style:document.getElementById(objectId);
		if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];
		if (nsDOM) return document.layers[objectId];
	}


*/


