function galleryPopSpecial( url ) {
	width = 1010;
	height = 695;
	fullUrl = "/Gallery_Popup/Default.aspx?gal=" + url;
	scrollbars = "0";

	str = "";
	str += "resizable=1,";
	str += "scrollbars=" + scrollbars + ",";
	str += "width=" + width + ",";
	str += "height=" + height + ",";

	if ( window.screen ) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = ( aw - width ) / 2;
		var yc = ( ah - height ) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	window.open( fullUrl, "slide_show", str );
}

function galleryPopCarousel( cat, url ) {

	width = 1000;
	height = 820;
	fullUrl = "/Top_Photos/CarouselSquare.aspx?cat=" + cat + "&gal=" + url;
	scrollbars = "0";

	str = "";
	str += "resizable=1,";
	str += "scrollbars=" + scrollbars + ",";
	str += "width=" + width + ",";
	str += "height=" + height + ",";

	if ( window.screen ) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = ( aw - width ) / 2;
		var yc = ( ah - height ) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	window.open( fullUrl, "slide_show", str );
}

function galleryPop( cat, url, page ) {
	width = 1010;
	height = 695;
//	fullUrl = "/Top_Photos/SS.aspx?cat=" + cat + "&gal=" + url;
	fullUrl = "/Top_Photos/" + cat + "/" + url + "/SlideShow/" + page + "/";
	scrollbars = "0";

	str = "";
	str += "resizable=1,";
	str += "scrollbars=" + scrollbars + ",";
	str += "width=" + width + ",";
	str += "height=" + height + ",";

	if ( window.screen ) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = ( aw - width ) / 2;
		var yc = ( ah - height ) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	window.open( fullUrl, "slide_show", str );
}

function galleryPopUser( userID, url, page ) {
	width = 1010;
	height = 772;
//	fullUrl = "/Top_Photos/SS.aspx?cat=" + cat + "&gal=" + url;
	fullUrl = "/Profiles/" + userID + "/SlideShow/" + url + "/" + page + "/";
	scrollbars = "0";

	str = "";
	str += "resizable=1,";
	str += "scrollbars=" + scrollbars + ",";
	str += "width=" + width + ",";
	str += "height=" + height + ",";

	if ( window.screen ) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = ( aw - width ) / 2;
		var yc = ( ah - height ) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	window.open( fullUrl, "slide_show", str );
}

function wallPopUser( userID, url ) {
	width = 1050;
	height = 772;
//	fullUrl = "/Top_Photos/SS.aspx?cat=" + cat + "&gal=" + url;
	fullUrl = "/Profiles/" + userID + "/Wall/" + url + "/1/";
	scrollbars = "0";

	str = "";
	str += "resizable=1,";
	str += "scrollbars=" + scrollbars + ",";
//	str += "fullscreen=yes";

	str += "width=" + width + ",";
	str += "height=" + height + ",";

	if ( window.screen ) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = ( aw - width ) / 2;
		var yc = ( ah - height ) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}

	window.open( fullUrl, "slide_show", str );
}

function gPopContest( catString, url ) {
	width = 1010;
	height = 772;
//	fullUrl = "/Top_Photos/SS.aspx?cat=" + cat + "&gal=" + url;
	fullUrl = "/Contest/Slides/" + catString + "/" + url + "/";
	scrollbars = "0";

	str = "";
	str += "resizable=1,";
	str += "scrollbars=" + scrollbars + ",";
	str += "width=" + width + ",";
	str += "height=" + height + ",";

	if ( window.screen ) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = ( aw - width ) / 2;
		var yc = ( ah - height ) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	window.open( fullUrl, "slide_show", str );
}

function galleryPopM( url ) {

	width = 1010;
	height = 695;
	fullUrl = "/MemberSubmitted/SS.aspx?gal=" + url;
	scrollbars = "0";

	str = "";
	str += "resizable=1,";
	str += "scrollbars=" + scrollbars + ",";
	str += "width=" + width + ",";
	str += "height=" + height + ",";

	if ( window.screen ) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = ( aw - width ) / 2;
		var yc = ( ah - height ) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	window.open( fullUrl, "slide_show", str );
}


function cartoonPop() {

	width = 1010;
	height = 695;
	fullUrl = "/Cartoons/CartoonViewer.aspx";
	scrollbars = "0";

	str = "";
	str += "resizable=1,";
	str += "scrollbars=" + scrollbars + ",";
	str += "width=" + width + ",";
	str += "height=" + height + ",";

	if ( window.screen ) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = ( aw - width ) / 2;
		var yc = ( ah - height ) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	window.open( fullUrl, "slide_show", str );
}

function SetCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+ escape( value ) +expires+"; path=/";
}

function GetCookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		a_temp_cookie = a_all_cookies[i].split( '=' );
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	
	if ( !b_cookie_found )
	{
		return null;
	}
}

function URLEncode (clearString) {
	var output = '';
	var x = 0;
	clearString = clearString.toString();
	var regex = /(^[a-zA-Z0-9_.]*)/;
	while (x < clearString.length) {
		var match = regex.exec(clearString.substr(x));
		if (match != null && match.length > 1 && match[1] != '') {
			output += match[1];
			x += match[1].length;
		} else {
			if (clearString[x] == ' ')
				output += '+';
			else {
				var charCode = clearString.charCodeAt(x);
				var hexVal = charCode.toString(16);
				output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();	
			}
			x++;	
		}
	}
	return output;
}

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='http://www.wesay.com/Search/?cx=partner-pub-3493375210657354:2eemr0-rq9n&cof=FORID:10&ie=ISO-8859-1&q=' + document.getElementById('q').value + '&sa=Search';
	document.location.href='http://dev.wesay.com/Search/?cx=partner-pub-3493375210657354:2eemr0-rq9n&cof=FORID:10&ie=ISO-8859-1&q=' + document.getElementById('q').value + '&sa=Search';
}
