// ***** SPOLOCNE FUNKCIE ******

// SSL certifikat - preklik na DigiCert, spolocny
function VerifySSL(num,old) {
	var width = 480; var height = 525;
	var ww = screen.width; var hh = screen.height;
	var left = (ww - width) / 2; var top = (hh - height) / 2;
	window.open('https://www.digicert.com/custsupport/sspopup.php?order_id=' + num + '&hostname=www.superpoistenie.sk','oo',"dependent=1,height="+height+",width="+width+",left="+left+",top="+top+",location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0");
	return false;
}

function switchDisplay(objid) {
	obj = document.getElementById(objid);
	if (obj){
		if (obj.style) {
			if (obj.style.display == 'none'){obj.style.display = 'block';}
			else{obj.style.display = 'none';}
		}
	}
}

function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}

function get_screen_dimensions(popUpDivVar) {
    if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
		viewportwidth = window.innerWidth;
	} else {
		viewportheight = document.documentElement.clientHeight;
		viewportwidth = document.documentElement.clientWidth;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
		blanket_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
			blanket_width = document.body.parentNode.clientWidth;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
			blanket_width = document.body.parentNode.scrollWidth;
		}
	}
	
	return { height: blanket_height, width: blanket_width }
}

function get_window_dimensions() {
     var viewportwidth;
     var viewportheight;
     
     // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
     
     if (typeof window.innerWidth != 'undefined') {
          viewportwidth = window.innerWidth,
          viewportheight = window.innerHeight
     }
     
    // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
    
     else if (typeof document.documentElement != 'undefined'
         && typeof document.documentElement.clientWidth !=
         'undefined' && document.documentElement.clientWidth != 0) {
           viewportwidth = document.documentElement.clientWidth,
           viewportheight = document.documentElement.clientHeight
     }
     
     // older versions of IE
     
     else {
           viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
           viewportheight = document.getElementsByTagName('body')[0].clientHeight
     }

     return { height: viewportheight, width: viewportwidth }
}

function blanket_size(popUpDivVar) {
    dim = get_screen_dimensions(popUpDivVar);
	var blanket = document.getElementById('help_box_bg');
	blanket.style.height = dim.height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv.style.top = (dim.height / 2 - 160) + 'px';
}

function window_pos(popUpDivVar) {
	dim = get_screen_dimensions(popUpDivVar);
	win = get_window_dimensions();
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=dim.width/2-225;
	
	if(document.height) {
	   window_height = document.body.clientHeight;
	} else {
	   window_height = window.innerHeight;
	}
	popUpDiv.style.top = getScrollY()+(win.height/2)-180 + 'px';
	popUpDiv.style.left = (win.width/2)-225 + 'px';
}

function toggleHelp(help_box, help_url) {
    document.getElementById('help_box_iframe').src = help_url;
	blanket_size(help_box);
	window_pos(help_box);
	toggle('help_box_bg');
	toggle(help_box);
}

function getScrollY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    //scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    //scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    //scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfY;
}
