// JScript source code
var appid="/source.net/"

browserType=navigator.appName;
function logout()
{
	if (confirm("Çıkmak istediğinizden emin misiniz?"))
	{
		document.location.href='?exit=ok'
	}
}
function savePolicy()
{
	if(document.all.selectedApp.value!='')
	{
		document.all.pagi.value='3';
		document.forms(0).submit()
	}else
	{
		alert("Uygulama seçiniz...")
	}
}
function continuePolicy(a)
{
	if(a=='0')
	{
		if(document.all.selectedType.value!='')
		{
			document.all.pagi.value='2';
			document.forms(0).submit()
		}else
		{
			alert("Türlerden seçiniz...")
		}
	
	}else
	{
		if(document.all.selectedAcc.value!='')
		{
			document.all.pagi.value='2';
			document.forms(0).submit()
		}else
		{
			alert("Hesaplardan seçiniz...")
		}
	}
}

function sourceNetPrint(path,q)
{
	window.open(path + "print.snet?"+q,"sprint","scrollbars=yes,resizable=yes,width=770,height=580")
}
function openApplicationPopup(path,addq,snl,z,a,b)
{
	if (addq!='')
	{
		addq="&" + addq
	}
	window.open(path + "index.snet?openerlayer="+snl+"&layer="+z+"&app="+a+addq,z,b+",scrollbars=no,resizable=no,top=0,left=0")
}
function openApplicationPopupCMSUID(path,addq,snl,z,a,b,c)
{
	if (addq!='')
	{
		addq="&" + addq
	}
	window.open(path + "index.snet?openerlayer="+snl+"&layer="+z+"&UID="+a+"&app="+c+addq,z,b+",scrollbars=no,resizable=yes,top=0,left=0")
}
function openApplicationPopupCMSFunction(path,addq,snl,z,a,b,c)
{
	if (addq!='')
	{
		addq="&" + addq
	}
	window.open(path + "index.snet?openerlayer="+snl+"&layer="+z+"&cntrl="+a+"&app="+c+addq,z,b+",scrollbars=no,resizable=yes,top=0,left=0")
}
function openPollPopup(path,pid,idx,nami,tagi,addq)
{
	window.open(path + "?pid="+pid+"&id="+idx+addq,nami,tagi+",scrollbars=no,resizable=yes")
}
function openWizardPopup(path,pid,idx,nami,tagi,addq)
{
	window.open(path + "?wid="+pid+"&id="+idx+addq,nami,tagi+",scrollbars=no,resizable=yes")
}
function openAgendaPopup(path,pid,idx,nami,tagi,addq)
{
	window.open(path + "?agid="+pid+"&id="+idx+addq,nami,tagi+",scrollbars=no,resizable=yes")
}
function treeImageSwitcher(nami,divo)
{
	
	if (document.all.item(nami+'div'+divo).style['display']=="none")
	{
		document.images(nami+'img'+divo).src="/source.net/images/tree/tree1/tree3.gif"
	}else
	{
		document.images(nami+'img'+divo).src="/source.net/images/tree/tree1/tree2.gif"
	}
}
function selectTreeRow(treename,idx,updateval,altlink0,altlink1)
{
	if (document.all.item(treename))
	{	
		//alert(document.all.item(treename).value)
		if (document.all.item(treename+'td'+document.all.item(treename).value))
		{
			document.all.item(treename+'td'+document.all.item(treename).value).className=altlink0
			document.all.item(treename+'md'+document.all.item(treename).value).className=altlink0
		}
		if (document.all.item(treename+'td'+idx))
		{
			document.all.item(treename+'td'+idx).className=altlink1
			document.all.item(treename+'md'+idx).className=altlink1
		}
		document.all.item(treename).value=updateval
	}
}
function checkAllTree(chkall,treename,vals)
{
	var valsArr=vals.split(",")
		for (vl in valsArr)
		{
			if (valsArr[vl]!='')
			{
					var vls=document.all.item(treename).value
					vls=vls.replace(valsArr[vl]+',','')
					vls=vls.replace(valsArr[vl]+',','')
					vls=vls.replace(valsArr[vl]+',','')
					vls=vls.replace(valsArr[vl]+',','')
				
				if (document.all.item(treename+chkall).checked==true)
				{
					if (document.all.item(treename+'chk'+valsArr[vl]).disabled!=true)
					{
						document.all.item(treename+'chk'+valsArr[vl]).checked=true
						document.all.item(treename).value=vls+valsArr[vl]+','
					}
				}else{
						if (document.all.item(treename+'chk'+valsArr[vl]).disabled!=true)
						{
							document.all.item(treename+'chk'+valsArr[vl]).checked=false
						}
					}
			}
		}
}

function checkBoxFieldWriterPoll(idx,fld,chk,count)
{
   	if (count>0)
	{
		var xc=document.all.item(fld).value
		var xcarr=xc.split(",")
			if(document.all.item(chk).checked==true && xcarr.length>count)
			{
				alert("Sadece " + count + " adet seçim yapabilirsiniz...")
				document.all.item(chk).checked=false
			}

	}

	
	if (document.all.item(chk).checked==true)
    {
			
		var vls=document.all.item(fld).value
		vls=vls.replace(idx+',','')
		vls=vls.replace(idx+',','')
		vls=vls.replace(idx+',','')
		vls=vls.replace(idx+',','')
		document.all.item(fld).value=vls+idx+','

	}
	else
	{
		var vls=document.all.item(fld).value
		vls=vls.replace(idx+',','')
		vls=vls.replace(idx+',','')
		vls=vls.replace(idx+',','')
		vls=vls.replace(idx+',','')
		document.all.item(fld).value=vls
	
	}




}

//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------

function openColorPicker()
{
	window.open("assist/colorpicker/colorpicker.snet","cp","top=50,left=50,scrollbars=no,resizable=no,width=360,height=230")
}
function setPicketVal(frm,a)
{
	if (a)
	{
		document.all.item('col'+a).value="#" + document.frames(frm).document.all.pickerhexval.value
		document.all.item('col'+a).style['background']=document.all.item('col'+a).value
		//alert(document.frames(frm).document.all.pickerhexval.value)
	} 
}
//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------


function cdtime(container, targetdate)
{
	if (!document.getElementById || !document.getElementById(container)) return
	this.container=document.getElementById(container)
	this.currentTime=new Date()
	this.targetdate=new Date(targetdate)
	this.timesup=false
	this.updateTime()
}

cdtime.prototype.updateTime=function(){
var thisobj=this
this.currentTime.setSeconds(this.currentTime.getSeconds()+1)
setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
}

cdtime.prototype.displaycountdown=function(baseunit, functionref){
this.baseunit=baseunit
this.formatresults=functionref
this.showresults()
}

cdtime.prototype.showresults=function(){
var thisobj=this


var timediff=(this.targetdate-this.currentTime)/1000 //difference btw target date and current date, in seconds
if (timediff<0){ //if time is up
this.timesup=true
this.container.innerHTML=this.formatresults()
return
}
var oneMinute=60 //minute unit in seconds
var oneHour=60*60 //hour unit in seconds
var oneDay=60*60*24 //day unit in seconds
var dayfield=Math.floor(timediff/oneDay)
var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
if (this.baseunit=="hours"){ //if base unit is hours, set "hourfield" to be topmost level
hourfield=dayfield*24+hourfield
dayfield="n/a"
}
else if (this.baseunit=="minutes"){ //if base unit is minutes, set "minutefield" to be topmost level
minutefield=dayfield*24*60+hourfield*60+minutefield
dayfield=hourfield="n/a"
}
else if (this.baseunit=="seconds"){ //if base unit is seconds, set "secondfield" to be topmost level
var secondfield=timediff
dayfield=hourfield=minutefield="n/a"
}
this.container.innerHTML=this.formatresults(dayfield, hourfield, minutefield, secondfield)
setTimeout(function(){thisobj.showresults()}, 1000) //update results every second
}

/////CUSTOM FORMAT OUTPUT FUNCTIONS BELOW//////////////////////////////

//Create your own custom format function to pass into cdtime.displaycountdown()
//Use arguments[0] to access "Days" left
//Use arguments[1] to access "Hours" left
//Use arguments[2] to access "Minutes" left
//Use arguments[3] to access "Seconds" left

//The values of these arguments may change depending on the "baseunit" parameter of cdtime.displaycountdown()
//For example, if "baseunit" is set to "hours", arguments[0] becomes meaningless and contains "n/a"
//For example, if "baseunit" is set to "minutes", arguments[0] and arguments[1] become meaningless etc


function formatresults(){
	if (this.timesup==false){//if target date/time not yet met
	var displaystring=arguments[0]+" days "+arguments[1]+" hours "+arguments[2]+" minutes "+arguments[3]+" seconds left until March 23, 2009 18:25:00"
	}
	else{ //else if target date/time met
	var displaystring="Future date is here!"
	}
	return displaystring
}

function formatresults2(){
	if (this.timesup==false){ //if target date/time not yet met
	var displaystring="<span class='lcdstyle'>"+arguments[0]+" <sup>days</sup> "+arguments[1]+" <sup>hours</sup> "+arguments[2]+" <sup>minutes</sup> "+arguments[3]+" <sup>seconds</sup></span> left until this Christmas"
	}
	else{ //else if target date/time met
	var displaystring="" //Don't display any text
	alert("Christmas is here!") //Instead, perform a custom alert
	}
	return displaystring
}


function formatresults3(){
	if (this.timesup==false)
	{
		var displaystring="<b>Kalan süre :</b> "+ arguments[2]+" dakika "+arguments[3]+" saniye"
		document.all.pollMin.value=arguments[2]
		document.all.pollSec.value=arguments[3]
	}
		else
		{ 
			var displaystring="Süre tamamlandı !";
			alert("Süreniz tamamlandı ...!");
			document.all.finalizePoll.value='ok';
			document.forms(0).submit();
		}
	return displaystring
}
//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------
function sourceNetHelp(hcode)
{
	window.open("help.snet?hc="+hcode,"Help","scrollbars=no,resizable=yes,width=770,height=500,top=0,left=0")
}
function sourceNetHelpKey(a)
{
	if (event.keyCode=='112')
	{
		sourceNetHelp(a)
	}

}
//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------
function preview(path,a)
{
	window.open(path + "graphicPreview.snet?img="+a,"img","scrollbars=no,resizable=no,width=100,height=100,")
}
//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------
function controlCheckX(x,y,a)
{
	var xc=document.all.item(x).value
	if(xc.indexOf(a)>-1)
	{
		document.all.item(y).checked=true
	}
}

function updateApplicationLabel(labelId,labeltext)
{
	if (document.all.item(labelId)&& labeltext!='')
	{
		document.all.item(labelId).innerText=labeltext
	}
}
function updateApplicationLabelAdd(labelId,labeltext)
{
	if (document.all.item(labelId)&& labeltext!='')
	{
		document.all.item(labelId).innerText="  "+ document.all.item(labelId).innerText + " " + labeltext
	}
}

//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------
function snetProcessDecision(mes,idx)
{
	if (mes!='')
	{
		if (confirm(mes))
		{
			document.all.snetlockpage.value='lock';
			document.all.pro_processDecision.value=idx
			document.forms(0).submit()
		}
	}else
	{
		document.all.snetlockpage.value='lock';
		document.all.pro_processDecision.value=idx
		document.forms(0).submit()
	}
}
//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------
function agendaHighight(id,col1)
{
	document.all.item(id).className=col1
}
function openAgendaDay(dt)
{
	document.all.item('dayDiv').style['display']='inline'
	document.frames['timeTableFrame'].document.location.href="/source.net/assist/agendaTimeTable.snet?dt="+dt
}
function viewHideOpenerLayer(a)
{
	if(top.document.all.item(a).style['display']=='none')
	{
		top.document.all.item(a).style['display']='inline'
	}else{
	top.document.all.item(a).style['display']='none'
		}

}
function viewHideReminderForm(a,tim,dt,dtinf,itemno)
{
	top.document.all.item(a).style['display']='inline'
	top.document.all.atime.value=tim
	
	if (itemno=='0' || itemno=='')
	{
	
	}else
	{	
		top.document.all.atime.selectedIndex=itemno-1
	}
	top.document.all.adate.value=dt
	top.document.all.remFormHeader.innerText=dtinf
	if (tim=='')
	{
		top.document.all.item('dayDiv').style['display']='none'
	}
}
function writeReminder()
{
	if (document.all.reminder.value!='')
	{
		if (confirm("Kaydetmek istediğinizden emin misiniz?"))
		{
			if (document.all.snetlockpage)
			{
				document.all.snetlockpage.value='lock';
			}
			document.forms(0).submit()
		}
		
	}else
	{
		alert("Hatırlatma mesajını kaydediniz...")
	}
}

function snetPrintPreview(OLECMDID) 
{ 
	 //var OLECMDID = 10; 
	 /* OLECMDID values: 
	 * 6 - print 
	 * 7 - print preview 
	 * 8 - page setup (for printing) 
	 * 1 - open window 
	 * 4 - Save As 
	 * 10 - properties 
	 */
	 try
	 {
		 var PROMPT = 1; // 1 PROMPT & 2 DONT PROMPT USER 
		 var oWebBrowser = document.getElementById("WebBrowser1");
		 if(oWebBrowser == null)
	 {
	 var sWebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
	 document.body.insertAdjacentHTML('beforeEnd', sWebBrowser); 
	 oWebBrowser = document.getElementById("WebBrowser1");
	 }
	oWebBrowser.ExecWB(OLECMDID,PROMPT);
	}
	catch(e){alert("Hata oluştu! " + e.message);}
} 

function printFrame(oTgt)
{
	oTgt.focus();
	oTgt.print();
}
//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------
function setClassName(idc,clsname)
{
	document.all.item(idc).className=clsname
}

//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------//---------------------
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}


function snetWizSelectUser(sname,sid)
{
	document.all.snetusernamespan.innerText=sname
	document.all.snetuserid.value=sid
}
function snetWizSelectAccount(sname,sid)
{
	document.all.snetemailspan.innerText=sname
	document.all.snetaccountid.value=sid
}

function newSourceNetUser()
{
	var pass=document.all.password.value
	var nami=document.all.name.value
	var usernami=document.all.username.value
	if (pass!=='' && nami!=='' && usernami!=='')
	{
		document.all.newuser.value='ok'
		document.forms(0).submit()
	}else
	{
		alert("Alanları doldurunuz..")
	}
}
function newSourceNetAccount()
{
	var pass=document.all.code.value
	var nami=document.all.name.value
	var usernami=document.all.email.value
	if (pass!=='' && nami!=='' && usernami!=='')
	{
		document.all.newaccount.value='ok'
		document.forms(0).submit()
	}else
	{
		alert("Alanları doldurunuz..")
	}
}
function UIDWizGoNext(mes)
{
	if (mes!='')
	{
		if (confirm(mes))
		{
			document.location.href="?wizpageparam=next"
		}
	}else
	{
		document.location.href="?wizpageparam=next"
	}
}


//DHTMLSuite.include("imageEnlarger");
function displayImage(imagePath,title,description)
	{
		var enlargerObj = new DHTMLSuite.imageEnlarger({ isDragable:true,isModal:false });
		enlargerObj.displayImage(imagePath,title,description);
		
	}
function demoProgressBar(currentStep)
{
	prObj.moveProgressBar(1);
	currentStep++;
	if(currentStep<=100){
		setTimeout('demoProgressBar(' + currentStep + ')',50);
	}	
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function snetSwitchTab(menuId,tableId,mcount,morder,clsn)
{
	var value1=parseInt(mcount)+1
	for (i=1;i<=value1;i++)
	{
		if (document.all.item(menuId + i))
		{
			document.all.item(menuId + i).className=clsn
		}
		if (document.all.item(tableId + i))
		{
			document.all.item(tableId + i).style['display']="none"
		}
	}
	
	if (document.all.item(menuId + morder))
	{
		document.all.item(menuId + morder).className=clsn+"Alt"
	}
	if (document.all.item(tableId + morder))
	{
		document.all.item(tableId + morder).style['display']="inline"
	}

}