﻿/**
* Pops up a new window in the middle of the screen
*/
function popupWindow(mypage, myname, w, h, scroll, status) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable, status='+status
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/** 
 * Overi zda je vyplnen mail a pokud ne tak se zepta zda ma opravdu odeslat 
 */
function check_studio_message(textFieldID, mailFieldID, defaultTextValue, defaultMailValue)
{

    if ((document.getElementById(textFieldID).value == '') ||
        (document.getElementById(textFieldID).value == defaultTextValue))
    {
        alert("Vyplňte text zprávy");
        return false;
    }

    var value = document.getElementById(mailFieldID).value;
    
    if ((value == '') || (value == defaultMailValue))
        return confirm("Pokud nevyplníte svůj e-mail, nebudeme Vás moci kontaktovat.  Chcete přesto odeslat vzkaz?");
    else
        return true;
}


/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Url = {
 
	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},	
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	}
	
 
}

// Retrieved from: http://www.htmlcodetutorial.com/forms/index_famsupp_157.html
function SubmitOnEnter(myfield, e)
{
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else if (e)
		keycode = e.which;
	else
		return true;
	if (keycode == 13)
	{
		SearchSite();
		return false;
	}
	else
		return true;
}

function SearchSite()
{

document.location.href='/search_result.aspx?cx=016200694806060125199:nqfodcdf500&cof=FORID:10&ie=UTF-8&q=' + 
    Url.encode(document.getElementById('q').value) + '&sa=Search';
}
