jQuery(document).ready(

	/*
	This function gets loaded when all the HTML, not including the portlets, is
	loaded.
	*/

	function() {
	}
);

Liferay.Portlet.ready(

	/*
	This function gets loaded after each and every portlet on the page.

	portletId: the current portlet's id
	jQueryObj: the jQuery wrapped object of the current portlet
	*/

	function(portletId, jQueryObj) {
	}
);

jQuery(document).last(

	/*
	This function gets loaded when everything, including the portlets, is on
	the page.
	*/

	function() {
	}
);

	/*
	WhereToGo Specific Staff
	*/



function launchpopupscroll(url, name, width, height,scroll) {
winSet = "toolbar=no,location=no,directories=no,menubar=no,scrollbars="+scroll+",resizable=no";
winSet += ",width="+width +",height="+height+",left="+(screen.availWidth-width)/2+",top="+(screen.availHeight-height)/2;
mypopwnd = window.open(url, name, winSet);
mypopwnd.focus();
disableSurvey=true;
}

function launchpopunder(url, name, width, height) {
winSet = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes, resizable=yes";
winSet += ",width="+width +",height="+height+",left="+(screen.availWidth-width)/2+",top="+(screen.availHeight-height)/2;
mypopwnd = window.open(url, name, winSet);
mypopwnd.focus();
disableSurvey=true;
}

function launchpopup(url, name, width, height) {
launchpopupscroll(url, name, width, height,"yes");
}

function launchsuccesspopup(url, name, width, height) {
 winSet = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,status=yes";
 winSet += ",width="+width +",height="+height+",left="+(screen.availWidth-width)/2+",top="+(screen.availHeight-height)/2;
 mypopwnd = window.open(url, name, winSet);
 mypopwnd.focus();
 disableSurvey=true;
}

function launchwindow(url) {
 winSet = "toolbar=yes,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes";
 mywnd = window.open(url, '', winSet);
 disableSurvey=true;
}

function launchFullWindow(url) {
 winSet = "toolbar,location,directories,status,scrollbars,menubar,resizable";
 mywnd = window.open(url, '', winSet);
 disableSurvey=true;
 }

function formatZip(zipcode)
{
var retzip = null;
if (zipcode != null)
{
zipcode.replace(" |-","");
retzip = zipcode.toUpperCase();
}
return retzip;
}
function validate(zipcode)
{
var re = new RegExp(/[a-zA-Z][0-9][a-zA-Z][0-9][a-zA-Z][0-9]/);
return  zipcode.match(re);
}
function setAdcode(form)
{
if (form.ptarget[0].checked && form.phunter[0].checked )
{
form.a.value="21380"; // manline
form.context.value="mdrr";
}
else if (form.ptarget[1].checked && form.phunter[1].checked)
{
form.a.value="21377"; // womanline
form.context.value="wdrr";
}
else if (form.ptarget[0].checked && form.phunter[1].checked)
{
form.a.value="21379"; // lavalife
form.context.value="adrr";
}
else if (form.ptarget[1].checked && form.phunter[0].checked)
{
form.a.value="21378"; // lavalife
form.context.value="adrr";
}
else
{
form.a.value="21381";
form.context.value="adrr";
}
form.id.value ="JQuickSearch";
}
function checkForm (form)
{
if (form.ptarget[0].checked || form.ptarget[1].checked){
if (!form.phunter[0].checked && !form.phunter[1].checked){
form.phunter[0].checked = form.ptarget[1].checked;
form.phunter[1].checked = form.ptarget[0].checked;
}
}else if (form.phunter[0].checked || form.phunter[1].checked){
if (!form.ptarget[0].checked && !form.ptarget[1].checked){
form.ptarget[0].checked = form.phunter[1].checked;
form.ptarget[1].checked = form.phunter[0].checked;
}
}
form.zip.value = formatZip(form.zip.value);
if (!validate(form.zip.value))
{
//alert(form.zip.value);
form.searchType.value="country";

}
else
{
form.searchType.value="zipcode";

}
setAdcode(form);
return true;
}

