function toggleOn(divId) {
	var el = document.getElementById(divId);
	el.style.display = 'block';el.style.display = 'block';
}
function toggleOff(divId) {
	var el = document.getElementById(divId);
	el.style.display = 'none';el.style.display = 'none';
}
function toggle(divId) {
	var el = document.getElementById(divId);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function getContent(id,url)	{
	var xmlhttp;
	if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari
	} else if (window.ActiveXObject) {	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  // code for IE6, IE5
	} else { alert("Your browser does not support XMLHTTP!");}
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			document.getElementById(id).innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function getInternetExplorerVersion() {
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}
/*function checkVersion() {
    var msg = "You're not using Windows Internet Explorer.";
    var ver = getInternetExplorerVersion();
    if (ver > -1) {
        if (ver >= 8.0)
            msg = "You're using a recent copy of Windows Internet Explorer."
        else
            msg = "You should upgrade your copy of Windows Internet Explorer.";
    }
    alert(msg);
}*/

function close() {
	/*if (document.all) {
		toggleOff('blanket');
		toggleOff('popUp');
	} else {*/
		$("#blanket").fadeOut("slow");
		$("#popUp").fadeOut("slow");
		disablePopup();
}
function close3() {
	/*if (document.all) {
		toggleOff('blanket');
		toggleOff('popUp');
	} else {*/
		$("#blanket").fadeOut("slow");
		$("#popUp3").fadeOut("slow");
		disablePopup();
}

function resizeBlanket() {
	
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	if (typeof window.outerHeight != 'undefined') {blanket_height = window.outerHeight;}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
}
function centerWidth(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerWidth;
	} else {
		viewportwidth = document.documentElement.clientWidth;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-433;
	popUpDiv.style.left = window_width + 'px';
}
/*function centerHeight(popUpDivVar) {
	if (typeof window.innerheight != 'undefined') {
		viewportheight = window.innerheight;
	} else {
		viewportheight = document.documentElement.clientheight;
	}
	if ((viewportheight > document.body.parentNode.scrollheight) && (viewportheight > document.body.parentNode.clientheight)) {
		window_height = viewportheight;
	} else {
		if (document.body.parentNode.clientheight > document.body.parentNode.scrollheight) {
			window_height = document.body.parentNode.clientheight;
		} else {
			window_height = document.body.parentNode.scrollheight;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_height=window_height/2-433;
	var ver = getInternetExplorerVersion();
    if (ver > -1) {
        if (ver >= 8.0)
			var hello = "lolololol";
        else
            popUpDiv.style.top = window_height + 'px';
    } else {
		popUpDiv.style.top = window_height + 'px';	
	}
}*/
$(document).ready(
	function(){
		centerWidth('popUp');
		//centerHeight('popUp');
		$('ul#slideshow').innerfade({
			speed: 1000, //also 'slow'
			timeout: 5000,
			type: 'sequence', //'or 'random', 'random_start', or 'sequence'
			containerheight: '351px'
		});		
	}
);
$(window).resize(function() {
    resizeBlanket();
	centerWidth('popUp');
	centerPopup(); 
	//loadPopup(); 
	//centerHeight('popUp');
});
$(window).scroll(function() {
    resizeBlanket();
	centerWidth('popUp');
	centerPopup(); 
	//loadPopup(); 
	//centerHeight('popUp');
});
$(function(){
	$('.fadein img:gt(0)').hide();
	setInterval(function(){$('.fadein :first-child').fadeOut().next('img').fadeIn().end().appendTo('.fadein');}, 3000);
});
$(document).ready(function() {
    $('select').addClass("select");
	$('select').focus(function() {
		$(this).removeClass("select").addClass("selectFocus");
    });
    $('select').blur(function() {
    	$(this).removeClass("selectFocus").addClass("select");
    });
});
$(document).ready(function() {
    $('input[type="password"]').addClass("txt2");
	$('input[type="password"]').focus(function() {
		$(this).removeClass("txt2").addClass("txtFocus");
    });
    $('input[type="password"]').blur(function() {
    	$(this).removeClass("txtFocus").addClass("txt2");
    });
});
$(document).ready(function() {
    $('textarea').addClass("textarea");
	$('textarea').focus(function() {
		$(this).removeClass("textarea").addClass("textareaFocus");
    });
    $('textarea').blur(function() {
    	$(this).removeClass("textareaFocus").addClass("textarea");
    });
});

function loadContent(contentUrl) {
	getContent('pageContent2',contentUrl);
	resizeBlanket();
	
}

function loadContent3(contentUrl) {
	getContent('pageContent3',contentUrl);
	resizeBlanket();
}
function displayContent(contentUrl) {
	resizeBlanket();
	centerPopup(); 
	loadPopup(); 
	centerWidth('popUp');
	/*if (document.all) {
		toggleOn('blanket');
		toggleOn('popUp');
	} else {*/
		//$("#blanket").fadeIn("slow");
		$("#popUp").fadeIn("slow")
	getContent('pageContent2',contentUrl);
}
function displayContent3(contentUrl) {
	resizeBlanket();
	centerPopup(); 
	loadPopup(); 
	centerWidth('popUp3');
	/*if (document.all) {
		toggleOn('blanket');
		toggleOn('popUp');
	} else {*/
		//$("#blanket").fadeIn("slow");
		$("#popUp3").fadeIn("slow")
	getContent('pageContent3',contentUrl);
}
//SETTING UP OUR POPUP  
//0 means disabled; 1 means enabled;  
var popupStatus = 0;  
//loading popup with jQuery magic!  
function loadPopup(){  
//loads popup only if it is disabled  
if(popupStatus==0){  
$("#backgroundPopup").css({  
"opacity": "0.65"  
});  
$("#backgroundPopup").fadeIn("slow");  
popupStatus = 1;  
}  
}  
//disabling popup with jQuery magic!  
function disablePopup(){  
//disables popup only if it is enabled  
if(popupStatus==1){  
$("#backgroundPopup").fadeOut("slow");  
popupStatus = 0;  
}  
}  
function centerPopup(){  
//request data for centering  
var windowWidth = document.documentElement.clientWidth;  
var windowHeight = document.documentElement.clientHeight;  
//only need force for IE6  
$("#backgroundPopup").css({  
"height": windowHeight  
});  
  
}  
