//===================================================
	function openWin( windowURL, windowName, windowFeatures ) { 
		return window.open( windowURL, windowName, windowFeatures ) ; 
	}
//===================================================
	function smallwindow(str)
	{
		leftVal = (screen.width-300) / 2;
		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)
	{
		leftVal = (screen.width-xwidth) / 2;
		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();
	}
	
//kontrola formulara main
function kontroluj_main(formularius)
	{
      if (formularius.nick.value=="meno")
	     {
		  alert("Musíš zadať meno !");
		  formularius.nick.focus();
		  return false;
		 }
	  else if (formularius.txt.value=="")
	    {
		 alert("Musíš zadať text k otazke");
		 formularius.txt.focus();
		 return false;
		}
	  else
	    {
	     return true;
		}
	}

//kontrola formulara quest	
function kontroluj_quest(formularius)
	{
      if (formularius.quest.value=="otazka")
	     {
		  alert("Musíš zadať nazov otazky !");
		  formularius.quest.focus();
		  return false;
		 }
      else if (formularius.nick.value=="meno")
	     {
		  alert("Musíš zadať meno !");
		  formularius.nick.focus();
		  return false;
		 }
	  else if (formularius.txt.value=="")
	    {
		 alert("Musíš zadať text k otazke");
		 formularius.txt.focus();
		 return false;
		}
	  else
	    {
	     return true;
		}
	}	
	
//flip farby v inputoch
function flip_class() 
{
		 tab=document.getElementById('nick');
		 if (tab.value=='meno')
		  {tab.className='sform';}
		 else
		  {tab.className='sform_flip';}
		 tab=document.getElementById('email');
		 if (tab.value=='email')
		  {tab.className='sform';}
		 else
		  {tab.className='sform_flip';}
		 tab=document.getElementById('www');
		 if (tab.value=='www')
		  {tab.className='sform';}
		 else
		  {tab.className='sform_flip';}
		  
}

//flip textu butonov aktivujucich scrolling
function flipbutton(nieco,text1,text2)
{
	if (nieco.value==text1)
	 { nieco.value=text2; }
	else
	 { nieco.value=text1; }
	 flip_class();
}

//podla kukis nastav pozadie (ak sa ti to podari:)
function dartbg_onload()
{
	var dartbg = GetCookie('dartbg');
	if (dartbg==null)
	 { SetCookie("dartbg",1);
	   flip_bg_online(1);
	 }
	else if (dartbg!=1)
	 { SetCookie("dartbg",dartbg);
	   flip_bg_online(dartbg);
	 }
}
//===================================================
	function myFill(name,value){
		fox = document.getElementById(name)
		fox.value = value
	}
//===================================================
	function myGet(name){
		fox = document.getElementById(name)
        if (fox.value==undefined){
            x="";
        }
		else if (fox.value==""){
            x="";
        }
		else{
            x=fox.value;
        }
		return x
	}
//===================================================
	function myGetX(name){
		fox = document.getElementById(name)
		return fox
	}
//===================================================
	function flipcolor(obj)
	{
		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";
		}

		else if(b=="FotoBoxLight"){
		obj.className="FotoBox";
		}
		else if(b=="FotoBox"){
		obj.className="FotoBoxLight";
		}
		
		
	}
//===================================================
	function flipselected(obj){
		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";
		}
	}
//===================================================
	function flipcolor_menu_old(obj)
	{
		b=obj.className;
		if (b=="menu_in"){
		obj.className="menu_out";
		}else if(b=="menu_out"){
		obj.className="menu_in";
		}
	}
//===================================================
    function flip_menu(obj){
      //alert(obj.style.backgroundImage)
        b=obj.className;
        if (b=="mmenu_off"){
            obj.className="mmenu_on";
        }else if(b=="mmenu_on"){
            obj.className="mmenu_off";
        }else if(b=="mmenu_sel"){
            obj.className="mmenu_unsel";
        }else if (b=="smenu_off"){
            obj.className="smenu_on";
        }else if(b=="smenu_on"){
            obj.className="smenu_off";
        }

    }
//===================================================
    function form_check_registration(obj){

     if (myGet("txt_loginr")=="" && myGet("txt_registration_type")!=1){
    		alert("Login je povinny");
    		myGetX("txt_loginr").focus();
    		return false;
    	}
      else if (myGet("txt_passwordr")=="" && myGet("txt_registration_type")!=1)
        {
    	 alert("Heslo je povinne");
   		 myGetX("txt_passwordr").focus();
    	 return false;
    	}
      else if (myGet("txt_passwordr")!=myGet("txt_password2") && myGet("txt_registration_type")!=1)
        {
    	 alert("Potvrzeni hesla se neshoduje s heslem.");
    	 myGetX("txt_password2").focus();
    	 return false;
    	}
      else if (myGet("txt_name")=="")
        {
    	 alert("Jmeno je povinny.");
    	 myGetX("txt_name").focus();
    	 return false;
    	}
      else if (myGet("txt_street")=="")
        {
    	 alert("Ulice je povinna.");
    	 myGetX("txt_street").focus();
    	 return false;
    	}
      else if (myGet("txt_city")=="")
        {
    	 alert("Mesto je povinne.");
    	 myGetX("txt_city").focus();
    	 return false;
    	}
      else if (myGet("txt_zip")=="")
        {
    	 alert("PSC je povinne.");
    	 myGetX("txt_zip").focus();
    	 return false;
    	}
      else if (myGet("txt_country")=="")
        {
    	 alert("Zeme je povinne.");
    	 myGetX("txt_country").focus();
    	 return false;
    	}
      else if (myGet("txt_tel")=="" && myGet("txt_mobil")=="")
        {
    	 alert("Musi byt vyplneny aspon jeden telefon\nDoporucujeme vyplnit mobil.");
    	 myGetX("txt_mobil").focus();
    	 return false;
    	}
      else{
    	return true;
    	}
    }
//............................................... 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 openFormInNewWindow(frm, wname){
	  //var aWindow = window.open('', wname,  'scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=400,height=400');
		
		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();
	}