// JavaScript Document

var firstClick=1;

function submitOnEnter(e){
	var keycode;
	if (window.event) {
		keycode = window.event.keyCode;		
	}
	else{
		keycode=e.which;
	}
	if (keycode == 13){	
		document.forms['main']['main:_idcl'].value='main:searchBtn';	
		document.forms['main'].submit(); 

	}
	
//	if(document.getElementById('main:key').value=='cauta in agenda') {
//		document.getElementById('main:key').value='';
//	}

	if (firstClick ==1) {
		document.getElementById('main:key').value='';
		firstClick=0;
	}

}

function checkAll(object) {
//    var curentRows=document.getElementById('main:curentRows').value;
	for (var i=2;i<document.forms[0].elements.length;i++){	
		
		var checkboxName=document.forms[0].elements[i].name;					
		if(checkboxName.substr(checkboxName.length-5,5)=='check'){						
			document.forms[0].elements[i].checked=object.checked;
		}		
	}
}

function checkAllWk(object) {
//    var curentRows=document.getElementById('main:curentRows').value;
	for (var i=2;i<document.forms[0].elements.length;i++){	
		
		var checkboxName=document.forms[0].elements[i].name;					
		if(checkboxName.substr(checkboxName.length-7,7)=='checkwk'){						
			document.forms[0].elements[i].checked=object.checked;
		}		
	}
}

function highlightRow(thisObj) {
	getRow(thisObj).style.backgroundColor = "#F8ECE0";   
}
 
function getRow(element) {
	currentRow = element.parentNode.parentNode.parentNode;
	return currentRow;
}


function allVerify() {
	// dummy
}

function move_up() //functia afiseaza capul de tabel in care este afisata agenda
{
    scroll_clipper.scrollTop = 0;
}


// scrolling menu
//begin
function setVariables() {
if (navigator.appName == "Netscape") {
v=".top=";
dS="document.";
sD="";
y="window.pageYOffset";
}
else {
v=".pixelTop=";
dS="";
sD=".style";
y="document.body.scrollTop";
   }
}
function checkLocation() {
object="object1";
yy=eval(y);
eval(dS+object+sD+v+yy);
setTimeout("checkLocation()",10);
}
//end

function display()// expand/hide optiuni din main menu PS
{
    if(document.getElementById('optionsMenu').style.display == 'none')
    {
        document.getElementById('optionsMenu').style.display = 'block';
    }
    else
    {
      document.getElementById('optionsMenu').style.display = 'none';
    }
}

function displayAdvSearch() {
    if(document.getElementById('search-table').style.display == 'none')
    {
        document.getElementById('search-table').style.display = 'block';
//        window.scrollTo(0, 0);
        document.getElementById('advsrch').scrollIntoView(true);
    }
    else
    {
      document.getElementById('search-table').style.display = 'none';
    }
}

function EnableSendButton(){
	if(document.getElementById('Text1').value == 'Enter text' || document.getElementById('Text1').value == '')
	{
		document.getElementById('SendButton').disabled = true;
	}
	else
	{
		document.getElementById('SendButton').disabled = false;
	} 
}
	


//start DD menu

/***********************************************
* AnyLink Drop Down Menu- ? Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="#">Grup mesaje scrise <img src="images/bulletarro.gif"></a>'
menu1[1]='<a href="#">Mesaje aniversare <img src="images/bulletarro.gif"></a></br>'

var menu2=new Array()
menu2[0]='<a href="#">SIM Agenda Backup <img src="images/bulletarro.gif"></a></br>'

var menu3=new Array()
menu3[0]='<a href="#">Out of Office <img src="images/bulletarro.gif"></a>'
menu3[1]='<a href="#">P2P Communication <img src="images/bulletarro.gif"></a></br>'

var menuwidth='200px' //default menu width
var menubgcolor='white'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)

dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-17-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu



//end DD menu



//idendtificare browser

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();



    var TBrow = BrowserDetect.browser;
    //document.write(TBrow);


t=t1=t2=null

function testValid(id)
{
    if(TBrow == "Firefox")
    {
        document.getElementById(id).className = "drop4Firefox";
        show(id);    
    }
    else if (TBrow == "Explorer" && id == "drop2")
    {
        document.getElementById(id).className = "drop4IE";
        show(id);
    }
    else if (TBrow == "Explorer" && id == "drop1")
    {
        document.getElementById(id).className = "drop4IE";
        show(id);
    }
    else if (TBrow == "Explorer" && id == "drop")
    {
        document.getElementById(id).className = "drop4IE_2";
        show(id);
    }
    else
    {
        document.getElementById(id).className = "drop4Firefox";
        show(id);
    }
}

function show(element){
  OBJ1=document.getElementById(element);
  OBJ1.style.visibility = 'visible';
}

function hide(element){
  OBJ1=document.getElementById(element);
  OBJ1.style.visibility = 'hidden';
}



