﻿//homepageSearchBar begin
function showHideHomepageSearchBar()
	{
	var searchBar = document.getElementById("homepageSearchBarWrapDiv");
		searchButton = document.getElementById("buttonSubHomeSearch");
	var	searchField = document.getElementById("query");
	
	if (searchBar.style.visibility == "visible")
		{
			searchBar.style.visibility = "hidden";
			searchButton.style.backgroundColor = "transparent";
			searchField.blur();
			var timeoutFocus = setTimeout("document.getElementById('query').blur()", 800);
		}
	else
		{
			searchBar.style.visibility = "visible";
			searchButton.style.backgroundColor = "#5E93D4";
			searchField.focus();
			var timeoutFocus = setTimeout("document.getElementById('query').focus()", 800);
		}
	}
//homepageSearchBar end


//sharedSearchBar begin
function showHideSharedSearchBar()
	{
	var searchBar = document.getElementById("sharedSearchBarDiv");
	var	searchField = document.getElementById("query");
	
	
	if (searchBar.style.visibility == "visible")
		{
			searchBar.style.visibility = "hidden";
			searchField.blur();
			var timeoutFocus = setTimeout("document.getElementById('query').blur()", 800);
		}
	else
		{
			searchBar.style.visibility = "visible";
			searchField.focus();
			var timeoutFocus = setTimeout("document.getElementById('query').focus()", 800);
		}
	}
//sharedSearchBar end

//mainServicesSearchBar begin
function showHideServicesSearchBar()
	{
	var searchBar = document.getElementById("mainServicesSearchBarDiv");
	var	searchField = document.getElementById("query");
	
	if (searchBar.style.visibility == "visible")
		{
			searchBar.style.visibility = "hidden";
			searchField.blur();
			var timeoutFocus = setTimeout("document.getElementById('query').blur()", 800);
		}
	else
		{
			searchBar.style.visibility = "visible";
			searchField.focus();
			var timeoutFocus = setTimeout("document.getElementById('query').focus()", 800);
		}
	}
//mainServicesSearchBar end

//HomePageSearchBar begin

function showHideHomepageSearchBar()
	{
	var searchBar = document.getElementById("mainServicesHomepageSearchBarDiv");
	var	searchField = document.getElementById("query");
		
	if (searchBar.style.visibility == "visible")
		{
			searchBar.style.visibility = "hidden";
			searchField.blur();
			var timeoutFocus = setTimeout("document.getElementById('query').blur()", 800);
		}
	else
		{
			searchBar.style.visibility = "visible";
			searchField.focus();
			var timeoutFocus = setTimeout("document.getElementById('query').focus()", 800);
		}
	}
//HomePageSearchBar end

//CPSearchBar begin
function showHideCPSearchBar()
	{
	var searchBar = document.getElementById("CPSearchBarDiv");
	var	searchField = document.getElementById("query");
	
	if (searchBar.style.visibility == "visible")
		{
			searchBar.style.visibility = "hidden";
			searchField.blur();
			var timeoutFocus = setTimeout("document.getElementById('query').blur()", 800);
		}
	else
		{
			searchBar.style.visibility = "visible";
			searchField.focus();
			var timeoutFocus = setTimeout("document.getElementById('query').focus()", 800);
		}
	}
//CPSearchBar end


//resizeSelectBar begin
function resizeSelectBar()
	{
	var searchBar = document.getElementById("CPSearchBarDiv");
	var portfolioSelectBar = document.getElementById("portfolioSelect");
	
	if (searchBar.style.visibility == "visible")
		portfolioSelectBar.style.height = "250px";
	else
		portfolioSelectBar.style.height = "300px";
	}
//resizeSelectBar end

//portfolio select branch or service begin
function selectBranchOrService(){
	var dropDown = document.getElementById("portfolioRollOut");
	window.open(dropDown.value, "_self")
}
//portfolio select branch or service end

//iframe change location begin
function changeIframeLocation(){
	var selectedClient = document.getElementById("portfolioSelect");
	portfolioIframe.window.location.href = selectedClient.options[selectedClient.selectedIndex].value;
	}
//iframe change location end

//showHideMainRollOutSubMenu begin

var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1));

var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_ie   = (agt.indexOf("msie") != -1);
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1));
var is_ie4up  = (is_ie  && (is_major >= 4));
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_opera = (agt.indexOf("opera") != -1);
var is_opera4 = (is_opera && (is_major == 4));
var is_opera5 = (is_opera && (is_major == 5));
var is_opera5up = (is_opera && (is_major >= 5));

var is_domcom = ((is_nav6up)||(is_ie5up)||(is_opera5up))
var is_mac    = (agt.indexOf("mac")!=-1);
var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || (agt.indexOf("68000")!=-1)));
var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || (agt.indexOf("powerpc")!=-1)));



var _timeout	= 500;

function getElementByIds(_id) {

	var _el;

	if(is_domcom) {
		_el	= document.getElementById(_id);
	} else if(is_ie4) {
		_el	= document.all[_id];
	}

	return _el;
}

function _showMenu(_objID) {
	var _obj	= getElementByIds(_objID);
	if(_obj) {
		_obj.style.display	= 'block';
	}
}

function _hideMenu(_objID) {
	var _obj	= getElementByIds(_objID);
	if(_obj) {
		_obj.style.display	= 'none';
	}
}

//hide other submenus begin
function hideOther(_id){
	var myMenu = getElementByIds(_id);
	var sm1 = getElementByIds("subMenu1WrapDiv");
	var sm2 = getElementByIds("subMenu2WrapDiv");
	var sm3 = getElementByIds("subMenu3WrapDiv");
	var sm4 = getElementByIds("subMenu4WrapDiv");

	if(sm1 && sm1 != myMenu) {
		sm1.style.display	= 'none';
	}
	if(sm2 && sm2 != myMenu) {
		sm2.style.display	= 'none';
	}
	if(sm3 && sm3 != myMenu) {
		sm3.style.display	= 'none';
	}
	if(sm4 && sm4 != myMenu) {
		sm4.style.display	= 'none';
	}
}
//hide other submenus end

/*************************************************
 *	shows element with id passed as parameter
 *************************************************/
function doOver(_id) {
	
	var _el	= getElementByIds(_id);
	hideOther(_id);
	if(_el) {
		if(_el.timer) {
			clearTimeout(_el.timer);
		}
		 _showMenu(_id);
	}
}

/*************************************************
 *	hides element with id passed as parameter
 *************************************************/

var time

function doOut(_id) {

	var _el	= getElementByIds(_id);

	if(_el) {
		var _timer	= setTimeout("_hideMenu('" + _id + "')", _timeout);
		_el.timer	= _timer;
	}
}
//showHideMainRollOutSubMenu end



//function CORRECTPNG BEGIN
function correctPNG() {
if (!is_opera){
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
}
}
//function CORRECTPNG END


//**************************
//NOFLASH PAGE VERSION BEGIN
//**************************

var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes &&
navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0; if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i];
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 &&
(navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}



//************************
//NOFLASH PAGE VERSION END
//************************


function getVarsFromSelect(str){
	var temp = new Array();
	temp = str.split('#!');
	//alert (temp[1]);
	portfolioIframe.window.location.href = temp[0];
	if (window.document.myFlash){
		window.document.myFlash.SetVariable("snowflake_bin_switch",temp[1]);
		window.document.myFlash.SetVariable("switch_str",temp[2]);
	}
	portfolioIframe.window.location.href = temp[0];
}



function changePort() {
getVarsFromSelect(document.form1.portfolioSelect.value);
//alert (clientVar);
}

//showHideContactForm begin
function showHideContactForm(div){
	var _el	= getElementByIds(div);
	
	if (div == 'contactFormSixthOptions'){
		if(document.contactForm.six_main[0].checked == true){
			_el.style.display	= 'block';
		}
	
		if(document.contactForm.six_main[1].checked == true){
			_el.style.display	= 'none';
		}
	}
	
	if (div == 'cotnactFormNinthOptions'){
		if(document.contactForm.got_budget[0].checked == true){
			_el.style.display	= 'block';
		}
	
		if(document.contactForm.got_budget[1].checked == true){
			_el.style.display	= 'none';
		}
	}
}
//showHideContactForm end

//showHideContactFormNumbering begin
function showHideContactFormNumbering(){
	var num_1 = getElementByIds("contactFormSixthOptionNumbering1");
	var num_3 = getElementByIds("contactFormSixthOptionNumbering3");
	
	if(document.contactForm.six_main[0].checked == true){
		num_1.style.display = 'none';
		num_3.style.display = 'block';
	}
	
	if(document.contactForm.six_main[1].checked == true){
		num_1.style.display = 'block';
		num_3.style.display = 'none';
	}
	
}
//showHideContactFormNumbering end

//***************************
//validateContactForm() BEGIN
//***************************

function validateContactForm(lang){
	var i = 0, temp = 0;
	var errorArray = new Array(4);
	var errorReport = 'The following fields are empty or incomplete:\n';
	
	if(lang == "sk")
		errorReport = 'Nasledujúce polia nie sú správne vyplnené:\n'

	//fisrt name
	if(document.contactForm.first_name.value == '')
		errorArray[0] = true;
		

	
	//telephone number begin
	if(document.contactForm.tel_num.value.length < 7)
		errorArray[2] = true;
	
	for(i = 0; i < document.contactForm.tel_num.value.length; i++){
		if(document.contactForm.tel_num.value.substring(i, i + 1) != '9' && document.contactForm.tel_num.value.substring(i, i + 1) != '8' &&
			document.contactForm.tel_num.value.substring(i, i + 1) != '7' && document.contactForm.tel_num.value.substring(i, i + 1) != '6' &&
			document.contactForm.tel_num.value.substring(i, i + 1) != '5' && document.contactForm.tel_num.value.substring(i, i + 1) != '4' &&
			document.contactForm.tel_num.value.substring(i, i + 1) != '3' && document.contactForm.tel_num.value.substring(i, i + 1) != '2' &&
			document.contactForm.tel_num.value.substring(i, i + 1) != '1' && document.contactForm.tel_num.value.substring(i, i + 1) != '0' &&
			document.contactForm.tel_num.value.substring(i, i + 1) != ' ' && document.contactForm.tel_num.value.substring(i, i + 1) != '-' &&
			document.contactForm.tel_num.value.substring(i, i + 1) != '/' && document.contactForm.tel_num.value.substring(i, i + 1) != '.'
			)
			errorArray[2] = true;

	}
	//telephone number end
		
	//email begin
	for (i = 0; i < document.contactForm.email.value.length; i++){
		if(document.contactForm.email.value.substring(i, i + 1) =='@'){
			temp++;
		}
	}
	if(temp != 1 | document.contactForm.email.value.substring(0,1) == '@' | document.contactForm.email.value.substring(document.contactForm.email.value.length - 1 , document.contactForm.email.value.length) == '@')
		errorArray[3] = true;
	//email end
	
	//errorReport begin
	if(errorArray[0] == true){
		if(lang == "en")
			errorReport += '\nFirst Name';
		else
			errorReport += '\nMeno';
	}

	if(errorArray[1] == true){
		if(lang == "en")
			errorReport += '\nLast Name';
		else
			errorReport += '\nPriezvisko';
	}
	
	if(errorArray[2] == true){
		if(lang == "en")
			errorReport += '\nTelephone Number';
		else
			errorReport += '\nTelefón';
	}
	
	if(errorArray[3] == true){
		errorReport += '\nE-mail';
	}
	
	if(lang=="en"){

		if(errorReport != 'The following fields are empty or incomplete:\n')
			alert(errorReport);
		else
			document.contactForm.submit();
	}
	
	else{
		
		if(errorReport != 'Nasledujúce polia nie sú správne vyplnené:\n')
			alert(errorReport);
		else
			document.contactForm.submit();
	}
	//errorReport end

	
}

//***************************
//validateContactForm()   END
//***************************

//disableEnableProvince begin
function disableEnableProvince(){
	if(document.contactForm.country.value == 'United States'){
		document.contactForm.state_province.disabled = false;
	}
	else
		document.contactForm.state_province.disabled = true;
}
//disableEnableProvince end


function newsletter(link) {
	window.open(link,'newsletter', 'width=600, height=400');
	return false;
}

function checkNewsletter() {
	var email = document.getElementById('email').value;
	if (!isValidEmail(email)) {
		alert("Zabudli ste vyplniť e-mail");
		document.getElementById('email').focus();
		return false;
	}
	else if (document.getElementById('name').value == "") {
		alert("Zabudli ste vyplniť meno");
		document.getElementById('name').focus();
		return false;
	}
	else return true;
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
