function popup(url, width, height) {
	/* open popup window */
	popupwindow = window.open(url, 'popup', 'scrollbars=yes,resizable=yes,height='+height+',width='+width+'');
	/* set focus on it */
	if (window.focus) {popupwindow.focus()}
	return false;
}

function fixedPopup(url, width, height) {
	/* open popup window */
	popupwindow = window.open(url, 'popup', 'toolbar=no,directories=no,status=no,scrollbars=no,menubar=no,height='+height+',width='+width+'');
	/* set focus on it */
	if (window.focus) {popupwindow.focus()}
	return false;
}

function FindObject(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 = FindObject(n,d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n);
    return x;
}

var btn = {
	    init : function() {
		var ieVer=/*@cc_on function(){ switch(@_jscript_version){ case 1.0:return 3; case 3.0:return 4; case 5.0:return 5; case 5.1:return 5; case 5.5:return 5.5; case 5.6:return 6; case 5.7:return 7; }}()||@*/0;
	        var i;
	        if (!document.getElementById || !document.createElement || !document.appendChild) return false;
	        as = btn.getElementsByClassName('button(.*)');
	        for (i=0; i< as.length; i++) {
	        	//check if node is an input tag
	            if ( as[i].tagName == "INPUT" && ( as[i].type.toLowerCase() == "submit" || as[i].type.toLowerCase() == "button" ) ) {           	        	
	            	//get input type
	            	var type = as[i].type.toLowerCase();
	            	
	            	if(ieVer != 6){	                     		
		                var a1 = document.createElement("a");

		                //set text to link
		                as[i].style.display = "none";
		                a1.appendChild(document.createTextNode(as[i].value));
		                a1.className = as[i].className;          	                
		                a1.id = as[i].id;		             
		                a1.onclick = as[i].onclick;
		                
		                if(type == "submit"){
		                	as[i].parentNode.insertBefore(a1, as[i]);
		                }
		                else{
		                	as[i].parentNode.replaceChild(a1, as[i]);		                	
		                }

		                as[i] = a1;	
               
		                if(type == "submit"){
		                	btn.addEvent(as[i],'click',function() {
		        	        	var form = btn.findForm(this);
		        	    		var submit = btn.findSubmitButton(form);  	    			
		        	    		submit.click();
		        	        });
		                	if(ieVer == 7){
		                		document.onkeypress = function formSubmit() {
		                			// IE7
		                			if(window.event.keyCode == 13){
		                			  var target = window.event.srcElement;
		                			  var form = btn.findForm(target);
		                			  var submit = btn.findSubmitButton(form);  	    			
		                			  submit.click();
		                			}
		                			return true;
		                		 }
		                	}
		                }	                
		                else if(type == "reset"){
			            		btn.addEvent(document.getElementById('reset_btn'),'click',function() {
			            		var form = btn.findForm(this);
			            		form.reset();
		            			});
		                }
	            	}
		            else{	
		            	var s1 = document.createElement('span');
		                var a1 =  as[i].cloneNode(false);		               
		                //set text to link
		            	s1.appendChild(a1)
		                s1.className = as[i].className;          	
		                as[i].parentNode.replaceChild(s1, as[i]);
		                as[i] = a1;   
		             }           	
	                
	            }//if is not an input tag ask for a link
	            else if (as[i].tagName == "A") {
	            	var tt = as[i].childNodes;
	            }
	            
	            if (as[i].tagName != "DEL" && ieVer != 6) {
		            var s1 = document.createElement('span');
		            while (as[i].firstChild) {
		              s1.appendChild(as[i].firstChild);
		            }
		            as[i].appendChild(s1);
	          	}

	        }

	       
	        as = btn.getElementsByClassName('disabled_button(.*)');
	        
	        for (i=0; i<as.length; i++) {
	        	
	            if ( as[i].tagName == "INPUT" && ( as[i].type.toLowerCase() == "submit" || as[i].type.toLowerCase() == "button" ) ) {	            	
	            		var type = as[i].type.toLowerCase();
	                var a1 = document.createElement("a");
	                a1.appendChild(document.createTextNode(as[i].value));
	                a1.className = as[i].className;
	                as[i].className = "";
	                //a1.id = as[i].id;
	                //a1.onclick = as[i].onclick;
	                as[i] = as[i].parentNode.replaceChild(a1, as[i]);
	                as[i] = a1;
	                               	                
	            }
	            else if (as[i].tagName == "A") {
	            	var tt = as[i].childNodes;
	            }
	       		else if (as[i].tagName == "SPAN") {
	       	
	                var del1 = document.createElement("del");
	               	var span1 = document.createElement("span");
									span1.appendChild(document.createTextNode(as[i].firstChild.data));
									del1.className = 'button';
	                del1.appendChild(span1);
	                //a1.id = as[i].id;
	                //a1.onclick = as[i].onclick;
	                as[i] = as[i].parentNode.replaceChild(del1, as[i]);
	                as[i] = del1;
	       		}	       
	        }
	        
	        if (document.getElementById('reset_btn')) {
        		btn.addEvent(document.getElementById('reset_btn'),'click',function() {
        		var form = btn.findForm(this);
        		form.reset();
        		});
        		}
	    },
	    findForm : function(f) {
	        while(f.tagName != "FORM") {
	            f = f.parentNode;
	        }
	        return f;
	    },
	    findSubmitButton: function(f) {
	        var kids = f.childNodes;
	        var button = null;
	        
	        for(var i = 0; i < kids.length; i++){
	        	button = btn.findSubmitButton(kids[i]);
	        	if(kids[i].type == "submit")
	        		button = kids[i];
	        	if(button != null){
	        		break;
	        	}
	        }
	        
	        return button;
	    }
	    ,
	    addEvent : function(obj, type, fn) {
	        if (obj.addEventListener) {
	            obj.addEventListener(type, fn, false);
	        }
	        else if (obj.attachEvent) {
	            obj["e"+type+fn] = fn;
	            obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
	            obj.attachEvent("on"+type, obj[type+fn]);
	        }
	    },
	    getElementsByClassName : function(className, tag, elm) {
	        var testClass = new RegExp("(^|\s)" + className + "(\s|$)");
	        var tag = tag || "*";
	        var elm = elm || document;
	        var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	        var returnElements = [];
	        var current;
	        var length = elements.length;
	        for(var i=0; i<length; i++){
	            current = elements[i];
	            if(testClass.test(current.className)){
	                returnElements.push(current);
	            }
	        }
	        return returnElements;
	    }
	}

	btn.addEvent(window,'load', function() { btn.init();} );