function hideWindowed(div,iframe){
    iframe.style.top=div.style.top
    iframe.style.left=div.style.left
    iframe.style.width=div.style.width
    iframe.style.height=div.style.height
    iframe.style.zIndex=div.style.zIndex-1
    iframe.style.display='block';
}
var checkedall=false;
function checkAll(form){
    if(checkedall) {
        uncheckAll(form);
        return;
    }
    for (i=0; i<form.elements.length; i++){
        var chkName=form.elements[i];
        if (form.elements[i].type=='checkbox'){
            //filter only checkbox
            chkName.checked=true;
        }
    }
    checkedall=true;
}

function uncheckAll(form){
    for (i=0; i<form.elements.length; i++){
        var chkName=form.elements[i];
        if (form.elements[i].type=='checkbox'){
            //filter only checkbox
            chkName.checked=false;
        }
    }
    checkedall=false;
}

function changecss(theClass,element,value) {
	var cssRules;
	if (document.all) {
	    cssRules = 'rules';
	}else if (document.getElementById) {
	    cssRules = 'cssRules';
	}
	for (var S = 0; S < document.styleSheets.length; S++){
	    for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
            //alert(document.styleSheets[S][cssRules][R].selectorText+" "+theClass);
	        if (document.styleSheets[S][cssRules][R].selectorText == "."+theClass) {
                //alert('ok');
	            document.styleSheets[S][cssRules][R].style[element] = value;
	        }
	    }
	}	
}
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function checkIt(string){
    var detect = navigator.userAgent.toLowerCase();
	place = detect.indexOf(string) + 1;
	return place;
}
function findObj(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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById)
	x=d.getElementById(n);
  return x;
}

function isValidAlphaNum(text)
{
	var i;

	for(i=0;i<text.length;i++)
	{
	ch=text.substr(i,1);
	if (!((ch>="a" && ch<="z") || (ch>="A" && ch<="Z") || (ch>="0" && ch<="9") || ch=="-" || ch=="_" || ch=="." || ch==" " || (ch>="À" && ch<="ý")))
	{
		return false;
	}
	}
	return true;
}



function isValidGeneral(text)
{
    var i;

    for(i=0;i<text.length;i++)
    {
	ch=text.substr(i,1);
	if (!((ch>="a" && ch<="z") || (ch>="A" && ch<="Z") || (ch>="0" && ch<="9") || ch=="?" || ch=="-" || ch=="_" || ch=="." || ch=="," || ch==" " || ch=="@" || ch=="!" || ch=="*" || ch=='$' || ch=='#' || ch=='&' || ch=='/' || ch=="æ" || ch=="Æ" || ch=="ø" || ch=="Ø" || ch=="å" || ch=="Å"))
	{
	    return false;
	}
    }
    return true;
}

function isValidAlphaNumSpec(text)
{
    var i;

    for(i=0;i<text.length;i++)
    {
	ch=text.substr(i,1);
	if (!((ch>="a" && ch<="z") || (ch>="A" && ch<="Z") || (ch>="0" && ch<="9") || ch=="-" || ch=="_" || ch=="." || ch==" " || ch=="æ" || ch=="Æ" || ch=="ø" || ch=="Ø" || ch=="å" || ch=="Å"))
	{
	    return false;
	}
    }
    return true;
}

function isValidEmail(str)
{
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp)
  {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
 return (!r1.test(str) && r2.test(str));
}

function isValidNum(text)
{
    var i;
    for(i=0;i<text.length;i++)
    {
	ch=text.substr(i,1);
	if (!((ch>="0" && ch<="9") || ch=="-" || ch=="_" || ch=="." || ch==" "))
	{
	    return false;
	}
    }

    return true;
}

function isValidMatch(str){
    m=str.split(";");
    var pass1=findObj(m[0]);
    var pass2=findObj(m[1]);
    if (pass1.value!=pass2.value){
		pass1.value="";
		pass2.value="";
		pass1.focus();
		return false;
    }
    return true;
}

function isValidLength(str){
    m=str.split(";");
    var pass1=findObj(m[0]);
    if (pass1.value.length<m[1]){
		pass1.value="";
		pass1.focus();
		return false;
    }
    return true;
}

function validateForm(){
    var currVar;
    for (i=0;i<val_names.length;i++){
        currVar=findObj(val_names[i]);
	    if (val_types[i]<5){
            if(currVar.value==""){
    		    alert(val_titles[i]);
		        currVar.focus();
		        return false;
	        }
	    }else{
	        val_types[i]-=4;
	    }
	    if ((val_types[i]==1) && !isValidAlphaNum(currVar.value)){
	        alert(val_titles[i]);
	        currVar.focus();
	        return false;
	    }
	    if ((val_types[i]==2) && !isValidNum(currVar.value)){
	        alert(val_titles[i]);
	        currVar.focus();
	        return false;
	    }
	    if ((val_types[i]==3) && !isValidEmail(currVar.value)){
	        alert(val_titles[i]);
	        currVar.focus();
	        return false;
	    }
	    if ((val_types[i]==4) && !isValidGeneral(currVar.value)){
	        alert(val_titles[i]);
	        currVar.focus();
	        return false;
	    }

	    if ((val_types[i]==9) && !currVar.checked){
	        alert(val_titles[i]);
	        return false;
	    }
    }
	return true;
}
function openWindow(href,name,width,height)
{
	window.open(href,name,"menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0,,width="+width+",height="+height);
}
function enlarge(mylink,size) 
{ 
	if (typeof(mylink) == 'string') href=mylink; 
	else href=mylink.href; 
	
	newwindow=window.open(href,'_blank',size); 
	if (window.focus) 
	{
		newwindow.focus()
	}; 
	return false; 
}

/* Table cell functions begin*/
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.style.backgroundImage =  x.oSrc; 
  }
}

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_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.style.backgroundImage;}
   	x.style.backgroundImage = 'url(' + a[i+2] + ')';
   }
}

function goTo(addr,targ)
{
	if(targ!='_self')
	window.open(addr,targ);
	else
	document.location=addr;
}

function getBrowser() {
	var browser = navigator.appName,
	res;
	switch(browser) {
		case "Microsoft Internet Explorer":
		res = "IE";
		break;
		
		case "Netscape":
		res = "NN";
		break;
		
		case "Opera":
		res = "OP";
		break;
		
		default:
		res = "OTHER";
		break;
	}
	return(res);
}

/* Table cell functions end*/

/* Image functions */
function MM_swapImgRestoreI() { //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_swapImageI() { //v3.0
  var i,j=0,x,a=MM_swapImageI.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];}
}
/* Image functions end */

function goTo(addr,targ)
{
	if(targ!='_self')
	window.open(addr,targ);
	else
	document.location=addr;
}


var win=null;
function NewWindow(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, addressbar=no';
win=window.open(mypage,myname,settings);}


// POopu

//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamicindex9/dhtmlwindow.htm

var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="30px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
}
}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","restore.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
document.getElementById("dwindow").style.display="none"
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}

