var checkflag = "false";
function check(field)
{
	if (checkflag == "false")
	{
		for (i = 0; i < field.length; i++)
		{
			field[i].checked = true;
		}
		checkflag = "true";
		return l_uncheckall; 
	}
	else
	{
		for (i = 0; i < field.length; i++)
		{
			field[i].checked = false;
		}
		checkflag = "false";
		return l_checkall;
	}
};
function ts_show_tag(id, status){if (document.getElementById(id)){if (status == true || status == false){document.getElementById(id).style.display = (status == true)?"none":"";}
else{document.getElementById(id).style.display = (document.getElementById(id).style.display == "")?"none":"";}}}
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 showElement(layer){
var myLayer = document.getElementById(layer);
if(myLayer.style.display=="none"){
myLayer.style.display="block";
myLayer.backgroundPosition="top";
} else { 
myLayer.style.display="none";
}
}
	function toggleuploadmode(mode) 
	{
		switch (mode)
		{
			case 0:
				show('upfile', 'block');
				hide('upurl');           
				break;
			case 1:
				hide('upfile');            
				show('upurl', 'block');  
				break;
		}
	};
	function focusfield(fl)
	{
			fl.value='';
			fl.style.color='black';
	};
	function show(id, type)
	{
		var o = document.getElementById(id);
		if (o)
			o.style.display = type || '';
	};

	function hide(id)
	{
		var o = document.getElementById(id);
		if (o)
			o.style.display = 'none';
	};

function borderit(which,color)
 {
    if (document.all||document.getElementById)
 {
    which.style.borderColor=color
  }
};
                function borderit(which,color)
                {
                    if (document.all||document.getElementById)
                    {
                        which.style.borderColor=color
                    }
                };

function SetSize(obj, x_size)
{
	if (obj.offsetWidth > x_size)
	{
		obj.style.width = x_size;
	};
};


    function ShowOrHide(d1, d2) {
      if (d1 != '') DoDiv(d1);
      if (d2 != '') DoDiv(d2);
    }
    function DoDiv(id) {
      var item = null;
      if (document.getElementById) {
        item = document.getElementById(id);
      } else if (document.all){
        item = document.all[id];
      } else if (document.layers){
        item = document.layers[id];
      }
      if (!item) {
      }
      else if (item.style) {
        if (item.style.display == "none"){ item.style.display = ""; }
        else {item.style.display = "none"; }
      }else{ item.visibility = "show"; }
     }

function windows_pop(idobj, name, bgeffect)
{
	
	win = new Window('modal_window',{url: idobj, options: {method: 'get'}}, {className: "alphacube",  width:900, height:400, zIndex: 50, resizable: true, title: name, showEffect:Element.show, hideEffect: Effect.SwitchOff, draggable:true})
	win.setDestroyOnClose();
	win.setLocation(20, 250);
	win.show(bgeffect);	
}
	
function SmileIT(smile,form,text)
{
	document.forms[form].elements[text].value = document.forms[form].elements[text].value+" "+smile+" ";
	document.forms[form].elements[text].focus();
};

function logout() {
	if (ajax_system == 'yes')
		ajaxpage("logout.php","main_div");
	else 
	 window.location=baseurl+"/logout.php";
		return true;
  };
function log_out() {
if(confirm(logout_t)) {
	return 	logout();
}else{
return false;
}};
function log_out1()
{
    Dialog.confirm(logout_t, 
                   {top: 10, width:250, className: "alphacube", okLabel: "Yes", cancelLabel:"No", ok: logout})
};
function select_all()
{
var text_val=eval("document.getElementById('textarea')");
text_val.focus();
text_val.select();
};
function goback(to)
{
	history.back(to)
};

function jumpto(url,message)
{
	if (typeof message != "undefined")
	{
		document.getElementById("jumpto").style.display = "block"; 
	}
	window.location = url;
};
function loadjs(file1, file2, file3, file4, file5, file6, file7, file8, file9, file10)
{
  // you can add more files if you want
  var scripts = [file1, file2, file3, file4, file5, file6, file7, file8, file9, file10];

  var scriptElement = new Array(scripts.length);
  var headTag = document.getElementsByTagName("head")[0];
  var fragment = document.createDocumentFragment();

  for(var i=0, count = scripts.length; i < count; i++)
  {
    scriptElement[i] = document.createElement("script");
    scriptElement[i].setAttribute("src", scripts[i]);
    fragment.appendChild(scriptElement[i]);
  }

  headTag.appendChild(fragment);
}

function highlight(field)
{
	field.focus();
	field.select();
};

function quote(textarea,form,quote)
{
	var area = document.forms[form].elements[textarea];
	area.value = area.value+" "+quote+" ";
	area.focus();
};
function ShowHide(id,id1) {
    obj = document.getElementsByTagName("div");
    if (obj[id].style.display == 'block'){
     obj[id].style.display = 'none';
     obj[id1].style.display = 'block';
    }
    else {
     obj[id].style.display = 'block';
     obj[id1].style.display = 'none';
    }
}
	function mysubmit(type)
	{
		if(document.getElementById("uploadscript").value=='')
		{
			window.alert('Enter upload processing script file name!');
			return false;
		}
		if(type=='flash')
		{
			var Flash;
			if(document.embeds && document.embeds.length>=1 && navigator.userAgent.indexOf("Safari") == -1)
				Flash = document.getElementById("EmbedFlashFilesUpload");
			else
				Flash = document.getElementById("FlashFilesUpload");		
			Flash.SetVariable("uploadUrl", document.getElementById("uploadscript").value); 
			Flash.SetVariable("SubmitFlash", ""); 
		}
		else
		{
			var FormObj = document.getElementById("myform");
			FormObj.action = document.getElementById("uploadscript").value;
			return true;
		}
	}
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
	target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	target.style.MozUserSelect="none"
else //All other route (ie: Opera)
	target.onmousedown=function(){return false}
target.style.cursor = "default"
}
function GetID(IDName)
{
	if(document.getElementById)
	{
		return document.getElementById(IDName);
	}
	else if(document.all)
	{
		return document.all[IDName];
	}
	else if(document.layers)
	{
		return document.layers[IDName];
	}
	else
	{
		return null;
	}
}
