// JavaScript Document
function clearCombo(combo)
{
	if(combo)
	{
		opt=combo.options.length=0;
		return true;
	}
	
	return true;
}

function updateMessage(obj,str)
{
	show(obj);	
	document.getElementById(obj).innerHTML=str;
}

function show(id)
{
		document.getElementById(id).style.display='';
		
}
function hide(id)
{
		document.getElementById(id).style.display='none';
}

// this function finds how many options of a multiselect listbox are selected
function getSelectedLength(obj)
{
	var i=0,len=0;
	
	for(i=0;i<obj.length;i++)
	{
		if(obj[i].selected == true)
			len++;
	}
	
	return len;
}

// this function finds the value of checked radio button
function getRadioValue(objID)
{
	obj=document.getElementsByName(objID);
	objValue="";
	
	for(i=0;i<obj.length;i++)
	{
		if(obj[i].checked == true)
		{
			objValue=obj[i].value;
			break;
		}
	}
	return objValue;
}

function isContainDuplicate(obj)
{
	var i=0,j=0;
	
	for(i=0;i<obj.length;i++)
	{
		for(j=0;j<obj.length;j++)
		{
			if(i==j)
				continue;
			if(obj[i].value==obj[j].value)
			{
				return true;
			}	
		}
	}	
	
	return false;
}

// move options from one listbox to another listbox
function moveOptions(from,to)
{
	fromOpt=from.options;
	
	for (i=0;i<fromOpt.length;i++)
	{
		if(fromOpt[i].selected == true)
		{
			to.options[to.length]=new Option(fromOpt[i].text,fromOpt[i].value);	
			fromOpt[i]=null;		
			i--;
		}
	}
}

//select all options of a listbox
function selectAllOptions(obj)
{
	opt=obj.options;
	
	for(i=0;i<opt.length;i++)
	{
		opt[i].selected = true;
	}
}

//
function openPopUpWindow(url,height,width)
{
   	
	 window.open(url,"","menubar=no,width="+width+",height="+height+",toolbar=no,resizable=yes,status=yes");	
   
}

function isChecked(name)
{
	var obj = document.getElementsByName(name);
	var result = false;
	
	for(i=0;i<obj.length;i++) {
			if(obj[i].checked == true) {
					result=true;
					break;
			}
	}
	
	return result;
}

function callAjax(strURL,strPostData,method,callBack) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
	www=(window.location.href.toLowerCase().indexOf("//www.")>0)?"http://www.":"http://";
	strURL=strURL.replace("http://",www);
	
	if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	
    self.xmlHttpReq.open(method, strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
		 if (self.xmlHttpReq.readyState == 4) 
		 {
				result=self.xmlHttpReq.responseText;
				callBack(result);
				
		}
	}
    self.xmlHttpReq.send(strPostData);
}

function LoadImage(path) {
	x = new Image();
	x.src = path;
}