//SPN Javascript functions


function getMidWidth() {
	return 1;
}

function rollover(target,imgName) {
	if (document.images) {
		imgchange = '/images/' + imgName + '.gif';
		document[target].src = imgchange;
		}
}
		
function white_space_search(field)
{
	field.value = field.value.replace(/^\s*|\s*$/g,'');
	return field.value;
}

var img1 = new Image;
img1.src = "/images/nav_fav_box_o.gif";
var img2 = new Image;
img2.src = "/images/nav_directory_o.gif";
var img3 = new Image;
img3.src = "/images/send-message_o.gif";
var img4 = new Image;
img4.src = "/images/search-messages_o.gif";
var img5 = new Image;
img5.src = "/images/printview_o.gif";
var img6 = new Image;
img6.src = "/images/but_quicksearch.gif";
var img7 = new Image;
img7.src = "/images/ya_headsearch_o.gif";
var img8 = new Image;
img8.src = "/images/ya_headsearch_ao.gif";
var img10 = new Image;
img10.src = "/images/printview_o.gif";
var img10 = new Image;
img10.src = "/images/nav_forums_o.gif";

var isMajor = parseInt(navigator.appVersion);
var isMinor = parseFloat(navigator.appVersion);
var isNS = (document.layers);
var isIE = (document.all);
var isMoz = (document.getElementById)
var isMac = (navigator.appVersion.indexOf("Mac") != -1);
//swidth = screen.width;
//sheight = screen.height;
if (isMac && !isIE) {
	swidth = document.documentElement.clientWidth;
	sheight = document.height;
} else if (isMac) {
	swidth = document.body.offsetWidth;
	sheight = document.body.offsetHeight;
} else if (isNS && isMajor <= 4) {
	swidth = screen.width;
	sheight = screen.height;
} else if (isMoz) {
	swidth = document.body.clientWidth;
	sheight = screen.height;
} else if (isIE) {
	swidth = document.body.offsetWidth;
	sheight = document.body.offsetHeight;
} else if (document.width) {	
	swidth = document.width;
	sheight = document.height;
} else if (document.body) {
	if (document.body.clientWidth) {
		swidth = document.body.clientWidth;
		sheight = document.body.clientHeight;
	} else if (document.body.offsetWidth) {
		swidth = document.body.offsetWidth;
		sheight = document.body.offsetHeight;
	} else {
		swidth = screen.width;
		sheight = screen.height;
	}
}
if (!swidth) {
	swidth = 800;
}

showRight = false;
wideScreen = false;
columnWidth=22;
if (swidth >= 900) {
	showRight = true;
	columnWidth=22;
}
if (swidth >= 1200) {
	wideScreen = true;
	columnWidth=28;
}

function getMidWidth() {
	midWidth = (swidth-197)*((100-columnWidth)/100);
	midWidth = midWidth - 20
	return 1;
}

winWidthStart = 0
function windload() {
	if (document.body) {
		winWidthStart = document.body.clientWidth;
	}
}

function checkwindow() {
	if (winWidthStart > 0 && document.body) {
		temp = winWidthStart/document.body.clientWidth;
		if (temp < .85) {
			window.location.href = window.location.href;
		}
	}
}

window.onresize = checkwindow;

var newwin;
function popup(y,z,j,k){
	var itop=(screen.height/2)-(k/2) - 20;
	var ileft=(screen.width/2)-(j/2);
	temp = "width=" + j + ",height=" + k + ",screenX=" + ileft + ",screenY=" + itop + ",left=" + ileft + ",top=" + itop;
	temp2 = "toolbar=0,location=0,directories=0,statusbar=0,menubar=0,scrollbars=1,resizable=1,"
	newwin = window.open(y,z,temp2 + temp);
	return false;
}

function popupImage(y,w,h){
	if (isIE) {
		widthPlus = 18;
		heightPlus = 0;
	} else {
		widthPlus = 0;
		heightPlus = 0;
	}
	height = h + heightPlus;
	width = w + widthPlus;
	var itop=(screen.height/2)-(height/2) - 20;
	var ileft=(screen.width/2)-(width/2);
	temp = "width=" + width + ",height=" + height + ",screenX=" + ileft + ",screenY=" + itop + ",left=" + ileft + ",top=" + itop;
	temp2 = "toolbar=0,location=0,directories=0,statusbar=0,menubar=0,scrollbars=1,resizable=1,"
	imgwin = window.open('','img',temp2 + temp);
	imgwin.document.writeln('<html><head><title>Social Psychology Network</title><body topmargin=0 marginheight=0 marginwidth=0 leftmargin=0 onBlur="self.close();" onLoad="self.focus();"><div align="center"><img src="' + y + '" border=0 width=' + w + ' height=' + h + '></div></body></html>');
	imgwin.document.close();
	return false;
}

if (document.layers) {
	document.writeln('<link rel="stylesheet" href="/style-ns.css">');
} else if (swidth >= 1200) {
	document.writeln('<link rel="stylesheet" href="/style-lg.css">');
} else {
	document.writeln('<link rel="stylesheet" href="/style-sm.css">');
}
