//===================================================
	function openWin( windowURL, windowName, windowFeatures ) { 
		return window.open( windowURL, windowName, windowFeatures ) ; 
	}
	
	function openInNewWindow(url) {
		var newWindow = window.open(url, '_blank');
		newWindow.focus();
		return false;
	}
//===================================================
	function smallwindow(str)
	{
		var leftVal = (screen.width-300) / 2;
		var topVal = (screen.height-200) / 2;
		
		newWindow = window.open( str, null, 'width=300,height=200,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0,top='+topVal+',left='+leftVal+'' );
		newWindow.focus();
	     	return false;
	}
//===================================================
	function smallwindow_sized(str,xwidth,xheight)
	{
		var leftVal = (screen.width-xwidth) / 2;
		var topVal = (screen.height-xheight) / 2;

		newWindow = window.open( str, null, 'width='+xwidth+',height='+xheight+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1,left='+leftVal+',top='+topVal+'' );
		newWindow.focus();
	     	return false;
	}
//===================================================
function IsNumeric(strString)
   //  check for valid numeric strings
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

//transfer
function skok(kam)
	{
	 	location = kam;
	}

//onfocus input
function cistic(komu,original)
	{
	if (komu.value==original)
	 { 	komu.value=''; }
	}
	
//onblur input
function opravar(komu,co)
	{
		if (komu.value=='')
	 	 { komu.value=co; }
	 flip_class();
	}
	
function check_registration(formularius)
	{
      if (myGetX("vars_podminky").checked==false)
	     {
		  alert("Pokud chcete odeslat Vaši ubytovnu musíte souhlasit s podmínkamy !");
		  myGetX("vars_podminky").focus();
		  return false;
		 }
	  else if (myGet("meno")=="")
	    {
		 alert("Jméno ubytovny je povinna položka.");
		 myGetX("meno").focus();
		 return false;
		}
	  else if (myGet("osoba")=="")
	    {
		 alert("Jméno osoby ktera provedla registraci je povinna položka.");
		 myGetX("osoba").focus();
		 return false;
		}
	  else
	    {
	     return true;
		}
	}

function check_quick_registration(formularius)
	{
      if (myGet("ICO")=="")
	    {
		 alert("ICO je povinna položka.");
		 myGetX("ICO").focus();
		 return false;
		}
	  else if (myGet("www")=="")
	    {
		 alert("www je povinna položka.");
		 myGetX("www").focus();
		 return false;
		}
	  else if (myGet("Zadal")=="")
	    {
		 alert("Jméno osoby ktera provedla registraci je povinna položka.");
		 myGetX("Zadal").focus();
		 return false;
		}
	  else if (myGet("Email")=="")
	    {
		 alert("Email je povinna položka.");
		 myGetX("Email").focus();
		 return false;
		}
	  else
	    {
	     return true;
		}
	}
//===================================================
	function myFill(name,value){
		var fox = document.getElementById(name)
		fox.value = value
	}
//===================================================
	function myGet(name){
		var fox = document.getElementById(name)
        if (fox.value==undefined){
            x="";
        }
		else if (fox.value==""){
            x="";
        }
		else{
            x=fox.value;
        }
		return x
	}
//===================================================
	function myGetX(name){
		var fox = document.getElementById(name)
		return fox
	}
//===================================================
	function flipcolor(obj)
	{
		var b=obj.className;
		if (b=="colflip1"){
		obj.className="colflip31";
		}else if(b=="colflip2"){
		obj.className="colflip32";
		}
		else if(b=="colflip32"){
		obj.className="colflip2";
		}
		else if(b=="colflip31"){
		obj.className="colflip1";
		}

		else if(b=="colflip1light"){
		obj.className="colflip2light";
		}
		else if(b=="colflip2light"){
		obj.className="colflip1light";
		}
	}
//===================================================
	function flipselected(obj){
		var b=obj.className;
		if (b=="colflip1"){
		obj.className="colflip71";
		}else if(b=="colflip2"){
		obj.className="colflip72";
		}
		else if(b=="colflip32"){
		obj.className="colflip72";
		}
		else if(b=="colflip31"){
		obj.className="colflip71";
		}
		else if(b=="colflip72"){
		obj.className="colflip32";
		}
		else if(b=="colflip71"){
		obj.className="colflip31";
		}
	}
//............................................... Cookies management
function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}

function SetCookie (name, value) {  
var DartExpDays = 30;
var DartExp = new Date(); 
DartExp.setTime(DartExp.getTime() + (DartExpDays*24*60*60*1000));

var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var expires=DartExp; //add by dart
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}

function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
//===================================================
	function DisableAllInput(xdisable){
		var xDoc = document.body.getElementsByTagName("input");
		var xSel = document.body.getElementsByTagName("select");
		var i=0
		var s=""
		//disable all textbox, checkbox
		for (i=0;i<xDoc.length;i++){
			if (xDoc.item(i).getAttribute("type") != "submit"){
				xDoc.item(i).disabled=xdisable;
			}
		}
		//disable all select
		for (i=0;i<xSel.length;i++){
				xSel.item(i).disabled=xdisable;
		}
		return true
	}

//======================================================
// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

//======================================================
function myShowHide(objID,show){
		var objCT=myGetX(objID);
		
		show = typeof(show) != 'undefined' ? show : -1;
		
		if (show==-1){
			if (objCT.style.display==""){
				objCT.style.display="none";
			}else{
				objCT.style.display="";
			}
		}else if(show==1){
			objCT.style.display="";
		}else{
			objCT.style.display="none";
		}
}

//===================================================
	function openFormInNewWindow(frm, wname){
		var leftVal = (screen.width-300) / 2;
		var topVal = (screen.height-200) / 2;
		
		var aWindow = window.open( '', wname, 'width=300,height=200,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0,top='+topVal+',left='+leftVal+'' );
		if (!aWindow.opener) aWindow.opener = self;

		frm.target = wname;
		frm.submit();
	}
