function OpenWindow(name, url, width, height)
{
	window.open(url, name, "width=" + width + ",height=" + height + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
}

function getElement(id)
{
  return document.getElementById(id);
}


function Deploy(obj, img, img1, img2)
{
  if ("none" == obj.style.display)
  {
    obj.style.display = "";
    img.src = img1;
  }
  else
  {
    obj.style.display = "none";
    img.src = img2;
  } 
}

function delete_photo( id, curPage ){
	if (window.confirm('确定要删除吗？') == true){
		window.location.href = 'photo.php?Action=Delete&&id=' + id + '&&curPage=' + curPage;
		return true;
	}else{
		//window.location.href = '';
		//return false;
	}
}

function delete_comment( id, curPage ){
	if (window.confirm('确定要删除吗？') == true){
		window.location.href = 'view_comment.php?Action=Delete&&id=' + id + '&&curPage=' + curPage;
		return true;
	}else{
		//window.location.href = '';
		//return false;
	}
}

function delete_favorite( id ){
	if (window.confirm('确定要删除吗？') == true){
		window.location.href = 'favorite.php?Action=Delete&&id=' + id;
		return true;
	}else{
		//window.location.href = '';
		//return false;
	}
}

function delete_clubuser( clubid, userid ){
	if (window.confirm('确定要删除吗？') == true){
		window.location.href = 'clubinfo.php?Action=DeleteUser&&clubid=' + clubid + '&&userid=' + userid;
		return true;
	}else{
		//window.location.href = '';
		//return false;
	}
}

function regInput(obj, reg, inputStr)
{
	var docSel	= document.selection.createRange();
	if (docSel.parentElement().tagName != "INPUT")	return false;
	oSel = docSel.duplicate();
	oSel.text = "";
	var srcRange	= obj.createTextRange();
	oSel.setEndPoint("StartToStart", srcRange);
	var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length);
	return reg.test(str);
}

function SelectAllCheckBox(chkall, form)
{
	for (var i = 0; i < form.elements.length; i++)
	{
	    var e = form.elements[i];
    	if (e.name != chkall.name)
	       e.checked = chkall.checked;
  }
}

function isCheckBoxSelect(form)
{
	for (var i = 0; i < form.elements.length; i++)
	{
	    var e = form.elements[i];
		if (e.checked == true)
		{
			return true;
		}
	}
	return false;
}


function trMouseMove(obj, color)
{
	if (obj.bgColor!=color)
		obj.bgColor=color
}

function trMouseOut(obj)
{
	obj.bgColor='';
}

function ComboSelect(obj, list, ID)
{
	var arr;
	if(list.length==0){
		obj.options[0] = new Option("No Record", "0");
		obj.options[0].selected = true;
		return;
	}
	for(i = 0; i < list.length; i++){
		arr = list[i].split("|");
		obj.options[i] = new Option(arr[1], arr[0]);
		if(arr[0] == ID)
			obj.options[i].selected = true;
	}
}


function XYRECheck(pattern, str)
{
	var r = new RegExp(pattern, "g");
	return r.test(str);
}

function XYisMail(str)
{
  var XYMailPattern = "^[a-zA-Z0-9]+([\.\-\_a-zA-Z0-9])*@[a-zA-Z0-9\-\_]+(\.[a-zA-Z0-9\-\_]+)+$";
	return XYRECheck(XYMailPattern, str);
}

function XYisURL(str)
{
  var XYURLPattern = "^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$";
	return XYRECheck(XYURLPattern, str);
}

function XYReplaceURL(URL, paramName, Value)
{
  var r = new RegExp(paramName + "\=(.+)", "g");  
  if (r.test(URL))
  return URL.replace(r, paramName + "=" + Value);  
  else
  {
    if (/\?/.test(URL))
    {
      return URL + "&" + paramName + "=" + Value;
    }
    else
    {
      return URL + "?" + paramName + "=" + Value;
    }
  }
}

function InitialCombo(obj, list)
{
	var arr;
	if(list.length==0){
		obj.options[0] = new Option("No Record", "");
		obj.options[0].selected = true;
		return;
	}
	for(i=0; i<list.length; i++){
		arr = list[i].split("|");
		obj.options[i] = new Option(arr[1], arr[0]);
		if(i == 0)obj.options[i].selected = true;
	}
}

function showMsg(str)
{
	var arr = Array();
	
	arr[1] = "Successful";
	arr[2] = "This user name exists.";
	window.alert(arr[str]);
}
function my_getbyid(id) {
	itm = null;
	if (document.getElementById) {
		itm = document.getElementById(id);
	} else if (document.all)	{
		itm = document.all[id];
	} else if (document.layers) {
		itm = document.layers[id];
	}
	return itm;
}
function change_cell_color( id, cl ) {
	itm = my_getbyid(id);
	if ( itm )	{
		itm.className = cl;
	}
}