﻿var nav = navigator.userAgent.toLowerCase();
var ie = nav.search("msie");
var ie6 = nav.search("msie 6");
var browserVer = parseInt(navigator.appVersion); 

//alert(ie6);


function popupOpener(linkto)
{
  window.open(linkto,'popupwindow','scrollbars=yes,resizable,width=800,height=700');
}

var win=null;
function openfenetre(mypage,myname,w,h,scroll,pos)
{
	if(pos=="random")
	    {LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center")
	    {LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null)
	    {LeftPosition=0;TopPosition=20}
	    
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	
	win=window.open(mypage,myname,settings);
}

var winpop=null;
function popWin(url,popname,w,h,pos,scrl,loc,dir,sts,mb,tbr,rsz)
{
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=100;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scrl+',location='+loc+',directories='+dir+',status='+sts+',menubar='+mb+',toolbar='+tbr+',resizable='+rsz+'';
	winpop=window.open(url,popname,settings);
}

function popup(url,w,h,pos)
{
    popWin(url,'popupwin',w,h,pos,'yes','no','no','no','no','no','no');
    //return false;
}

function MM_preloadImages() 
{ //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() 
{ //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) 
{ //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function HideBubble(e)
{
    try 
    {
        EBubble.ShowHoverOverBubble(0,'',0,0,0,0,0);
    }
    catch(e)
    {
    }
}

function toggleDiv(id,flagit) 
{
	if (flagit=="1")
	{
		if (document.layers) document.layers[''+id+''].visibility = "show";
		else if (document.all) document.all[''+id+''].style.display = "block";
		else if (document.getElementById) document.getElementById(''+id+'').style.display = "block";
	}
	else
	{
		if (document.layers) document.layers[''+id+''].visibility = "hide";
		else if (document.all) document.all[''+id+''].style.display = "none";
		else if (document.getElementById) document.getElementById(''+id+'').style.display = "none";
	}
}

function showOrHideAllDropDowns(newState) 
{            
    var elements = document.documentElement.getElementsByTagName('select');
     
    for (var i=0; i<elements.length; i++) 
    {
        elements[i].style.visibility = newState;
    }
} 
    
function toggleRegion(id,flagit,idregion,classname_over,classname_out) 
{
    //alert(document.getElementById(''+idregion+'').className);

	if (flagit=="1")
	{
	    if (ie6 > 0)
        {
            showOrHideAllDropDowns("hidden");
        }
    
	    document.getElementById(''+idregion+'').className = classname_over;
        toggleDiv(id,flagit);
	}
	else
	{
	    if (ie6 > 0)
        {
            showOrHideAllDropDowns("visible");
        }
        	
	    document.getElementById(''+idregion+'').className = classname_out;
        toggleDiv(id,flagit);
	}
}

function toggleBloc(id,flagit) 
{
	if (flagit=="1")
	{
		if (document.layers) document.layers[''+id+''].visibility = "show";
		else if (document.all) document.all[''+id+''].style.display = "";
		else if (document.getElementById) document.getElementById(''+id+'').style.display = "";
	}
	else
	{
		if (document.layers) document.layers[''+id+''].visibility = "hide";
		else if (document.all) document.all[''+id+''].style.display = "none";
		else if (document.getElementById) document.getElementById(''+id+'').style.display = "none";
	}
}

function toggleFieldsByCase(id,idToggle,FieldsToggle) 
{
    //alert(FieldsToggle);
	var arrFields = FieldsToggle.split("|");
	
	if (id == idToggle)
        flagit = 1;
    else
        flagit = 0;
    
	for (i=0;i<arrFields.length;i++)
	{
	    //alert(arrFields[i]);
	    toggleBloc("BlocToggle"+arrFields[i],flagit);
	}       
}

function closeDiv(id) 
{
	if (document.layers) document.layers[''+id+''].visibility = "hide";
	else if (document.all) document.all[''+id+''].style.display = "none";
	else if (document.getElementById) document.getElementById(''+id+'').style.display = "none";
}

function attribDiv(id,val) 
{
    document.getElementById(''+id+'').style.display = "block";
    document.getElementById(''+id+'').innerHTML = val;
}

function attribDiv1ToDiv2(id1,id2) 
{
    //alert(document.getElementById(''+id1+'').innerHTML);
    document.getElementById(''+id2+'').style.display = "block";
    document.getElementById(''+id2+'').innerHTML = document.getElementById(''+id1+'').innerHTML;
}

function replaceDivVal(id,val,red) 
{
    if (red == 1)
        document.getElementById(''+id+'').innerHTML = "<span style='color:red'>*</span> " + val;
    else
        document.getElementById(''+id+'').innerHTML = val;
}

function replaceInputVal(id,val) 
{
    document.getElementById(''+id+'').value = val;
}

function popupMapArea(a,msg,look,x,y)
{ 
    //v1.0.5
    var scrolltop = document.body.scrollTop;
    if(scrolltop==0)
        scrolltop = document.documentElement.scrollTop;
    
    var d=document; if (!a){var ln='pLayer';dx="";dy="";b=(d.layers)?1:0;

    nn=(b||d.getElementById &&!d.all)?1:0;l = new Object();
    l.s=b?d.layers[ln]:MM_findObj(ln).style;l.r=b?d.layers[ln].document:MM_findObj(ln);
    l.w=function (t) {if(b){l.r.write(t);l.r.close()}else l.r.innerHTML=t}
	if(b) d.captureEvents(Event.MOUSEMOVE);d.onmousemove=function(e)
	{dx=(nn)?e.pageX:event.x;dy=(nn)?e.pageY:event.y;}}if (a=='1') {l.s.visibility='hidden'}
    if (a=='2') {l.w('<span class="'+look+'">'+unescape(msg)+'</span>')
	if(d.all) dy=dy+scrolltop;x=(!x)?50:Number(x);
	
	y=(!y)?-20:Number(y);l.s.left=dx+x; l.s.top=dy+y;l.s.visibility='visible'}
}

function expandcontent(id,bullet) 
{
    //alert(document.getElementById(''+id+'').style.display);
    if (document.getElementById(''+id+'').style.display == "none" || document.getElementById(''+id+'').style.display == "")
    {
        document.getElementById(''+bullet+'').innerHTML = "-";
        document.getElementById(''+id+'').style.display = "block";
    }
    else
    {
        document.getElementById(''+bullet+'').innerHTML = "+";
        document.getElementById(''+id+'').style.display = "none";
    }
}


function onEnterpress(e,id)
{
    //define any varible
    var KeyPress;  
  
    //if which property of event object is supported  
  	if (!e) var e = window.event
	if (e.keyCode) KeyPress = e.keyCode;
	else if (e.which) KeyPress = e.which;
  
    //13 is the key code of enter key
    if(KeyPress == 13)
    {
        //alert(':'+KeyPress);
        //alert(':'+id);
        //frmLogin is the name of form
        //document.forms[0].submit();

        WebForm_FireDefaultButton(e,id);
        return false     
    }
    else
    {
        return true
    }
}