// Carousel function
$.fn.infiniteCarousel = function (wrapperSelector){
	function repeat(str, num){
		return new Array(num + 1).join(str);
	}

	return this.each(function (){
			var $wrapper = $(wrapperSelector, this),
				$slider = $wrapper.find('> ul'),
				$items = $slider.find('> li'),
				$single = $items.filter(':first'),

				singleWidth = $single.outerWidth(true), //parseInt($single.width()) + parseInt($single.css('padding-left')) + parseInt($single.css('padding-right')),
				visible = Math.floor($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
				currentPage = 1,
				pages = Math.floor($items.length / visible);

		// 1. Pad so that 'visible' number will always be seen, otherwise create empty items
		if (($items.length % visible) != 0){
			$slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
			$items = $slider.find('> li');
		}

		// 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
		$items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
		$items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
		$items = $slider.find('> li'); // reselect

		// 3. Set the left position to the first 'real' item
		// $wrapper.css('scrollLeft', singleWidth * visible); // * -1
		$wrapper.get(0).scrollLeft = singleWidth * visible;

		// 4. Bind to the forward and back buttons
		$('a.back', this).click(function (){
			return gotoPage(currentPage - 1);
		});

		$('a.forward', this).click(function (){
			return gotoPage(currentPage + 1);
		});

		// 5. paging function
		function gotoPage(page){
			var dir = page < currentPage ? -1 : 1, // page < currentPage ? 1 : -1,
					n = Math.abs(currentPage - page),
					left = singleWidth * dir * visible * n;

			$wrapper.filter(':not(:animated)').animate({
				scrollLeft : '+=' + left
			}, 500, function (){
				if (page == 0){
					currentPage = pages;
					// $wrapper.css('scrollLeft', singleWidth * visible * pages); //  * -1
					this.scrollLeft = singleWidth * visible * pages;
				} else if (page > pages){
					currentPage = 1;
					this.scrollLeft = singleWidth * visible; //  * -1
					// $wrapper.css('scrollLeft', singleWidth * visible); //  * -1
					// reset back to start position
				} else {
					currentPage = page;
				}
			});

			return false;
		}

		// create a public interface to move to a specific page
		$(this).bind('goto', function (event, page){
			gotoPage(page);
		});
	});
};

// Friendly Input Box Function
function friendlyInput(s)
{
	var s = $(s)
	// Store the existing values of header and footer
	s.each(function(){ $(this).data("default", $(this).attr("value")); });
	s.focus(function(){ 
		// If the value is same as stored data then change it to blank
		if( $(this).attr("value") == $(this).data("default") )
			$(this).attr("value","");
	});
	s.blur(function(){ 
		// If the value is blank then make it back to default
		if( $(this).attr("value") == "" )
			$(this).attr("value",$(this).data("default") );
	});
}

// Source : http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
function getScrollXY(){
	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 [scrOfX, scrOfY];
}

// Random String generator
function randomString(string_length)
{
	var chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var randomstring = '';
	for (var i = 0; i < string_length; i++){
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum, rnum + 1);
	}
	return randomstring;
}

// Error message for input fields
function showError(field, message)
{
	if($(field).data('error') != true )
	{
		field = $(field);
		if(field.attr('type') == 'password'){
			var html ="<input type='text' value='"+message+"' class='"+ field.attr('class') +"' style='"+ field.attr('style') +"' />";

			field.hide();
			$(html).insertAfter(field).css({"border-color":"#a00", "color" : "#000" , "background" : "#fee" }).bind("focus", function(){
				$(this).remove();
				$(field).show().focus().data('error',false);
			}).data('error',true);
		}
		else{
			var elem = $(field).hide().data('error',true).clone().insertAfter(field).removeAttr("rel").show().css({"border-color":"#a00", "color" : "#000" , "background" : "#fee" }).bind("focus", function(){
				$(this).remove();
				$(field).show().focus().data('error',false);
			}).data('error',true);

			if (typeof message != 'undefined')
				elem.val(message);
		}
	}
}

// Show loading bar for container
function showMessage(container, message, type, style, timeout)
{
	if (typeof timeout != 'number'){ timeout = false}
	if (typeof style == 'undefined'){ style = null}
	if (typeof type == 'undefined'){ type = null}
	var scrollY = getScrollXY()[1] + 0;

	var app1 = '<img src="http://o.aolcdn.com/art/personals_redesign/loading.gif" alt="Loading..." style="display:inline; width:auto; height:auto; padding:0; margin:10px; border:0;"/>';

	if(type == 'message')
		app1 = '';

	$(container).find('.loading').show().html(app1 + '<span style="display:inline; width:auto; height:auto; padding:0; margin:10px; border:0; vertical-align:top; '+style+'">'+message+'</span>').css('padding-top', scrollY);

	if(timeout)
	{
		setTimeout(function(){ hideMessage(container); }, timeout);
	}
}

// Hide loading bar for container
function hideMessage(container)
{
	$(container).find('.loading').fadeOut('fast');
}

// Get a cookie
function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1){ c_end=document.cookie.length; }
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

// Store a cookie
function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires="+exdate.toGMTString());
}

// Dont let the user submit when a certain form is default
function stopDefaultSearch(form, input)
{
	var form = $(form);
	input = form.find(input);
	if( input.val() == input.data('default'))
	{
		showError(input);
		return false;
	}
	else 
		return true;
}

// Highlight Menu based on screen
function highlightMenu()
{
	var services = /get-matched|search-for-a-match|boutique|online-dating-reviews|gay-lesbian-love-dating|commitment-and-marriage/;
	var articles = /articles/;
	
	var url = window.location + "";
	
	if(url.search(services) != -1)
		$("li[rel=services]").attr("class","selected");
	else if(url.search(articles) != -1)
		$("li[rel=articles]").attr("class","selected");
	else
		$("li[rel=main]").attr("class","selected");
}

// getJS Cached Javascript
//function getJS(f,g){var e=document,c=e.getElementsByTagName("head")[0],b=e.createElement("script"),a=0;b.src=f;b.onload=b.onreadystatechange=function(){if(!a&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){a=1;if(typeof g==="function"){g()}b.onload=b.onreadystatechange=null;c.removeChild(b)}};c.appendChild(b);return undefined};

function getJS(url)
{
	$("#getjsid").remove();
	$("head").append('<script id="getjsid" type="text/javascript" src="'+url+'"></script>');
}

$(document).ready(function(){
	// ----------------------------
	// Global Actions for ALL Pages
	// ----------------------------

	/* Auto Suggest On KeyUp
	$("#header input.srchinput, #footer input.srchinput").keyup(function(){
		var html ="", suggestions = "", container = $(this);
		
		// clear the previour timer is the user typed too fast
		clearTimeout($(this).data("timeout"));

		// function to set the ajax autosuggest timer after a delay of a few milliseconds to prevent multiple ajax calls for each key stroke
		$(this).data("timeout", setTimeout(function(){ 
			// do a JSON call here and return the array of suggestions in the array suggestions
			$.getJSON("http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=YahooDemo&output=json&callback=?",{ 'query' : container.val() },
				function(data){ 
					// Did any result really come ?
					if(data.ResultSet.Result)
					{
						// Auto suggest box exists ?
						if( !container.siblings().length)
							container.after("<div></div>");

						// sort the suggestions array inside
						suggestions = data.ResultSet.Result;
						for(var i=0; i<suggestions.length; i++)
						{
							html += '<a href="javascript:void(0);" rel="'+suggestions[i]+'"onclick="$(this).parent().siblings(\'input:first\').val($(this).attr(\'rel\')); $(this).parent().remove();">' + suggestions[i].replace(container.val(), '<strong>' + container.val() + '</strong>') + '</a>';
						}

						// Append the results in the div and show it
						container.siblings("div:first").html(html).fadeIn("fast");
					}
			}); },150));
	});

	// Remove auto suggest if user clicks outside
	$("#header input.srchinput, #footer input.srchinput").blur(function(){ var sibs = $(this).siblings(); setTimeout(function(){ sibs.remove() }, 500); });
	*/
	highlightMenu();
	var header = $("#header");

	// Menu functionality
	// Calculate the width of the menu based on it's children
	header.find(".menu .level1").each(function(){ 
		// find the total numbers of li's which are sublevels
		var num = $(this).find("> li.sublevel").length, 
			width=0,
			elem="";
		if(num > 0)
		{
			for(i=0; i<num; i++)
			{
				// Calculate the total outerwidth of the childern and the element itself and apply it to them
				elem = $(this).find("> li:eq(" + i + ")");
				width += elem.outerWidth(true);
				// This needs to be done for IE6
				elem.width(elem.outerWidth(true) - parseInt(elem.css('padding-left')) - parseInt(elem.css('padding-right')));
			}
			$(this).width(width + parseInt($(this).css('padding-left')) + parseInt($(this).css('padding-right')) );
		}
		// Elements needs to be invisible NOT display:none else it's width will calculate to zero, now reset it back
		$(this).css({"display":"none" ,"visibility" : "visible"});
	});

	header.find('ul li:last-child').addClass('lastUnit');
	header.find('ul li:first-child').addClass('firstUnit');

	// Dropdown Menu
	header.find(".menu > li:not(.feedback)").hover(
		function(){ $(this).find('> ul').fadeIn('fast'); },
		function(){ $(this).find('> ul').fadeOut('fast'); }
	);

	// Header More Dropdown Menu
	header.find(".usrinfo .inf1 span").hover(
		function(){ clearTimeout($(this).data("timeout")); $(this).find('ul').fadeIn('fast'); },
		function(){ var nxtul = $(this).find('ul');  $(this).data("timeout",setTimeout(function(){ nxtul.fadeOut('fast'); },500)); }
	);
});

// Wait for the window load
$(window).load(function(){
	// Friendly input for header and footer
	friendlyInput("#header input.srchinput, #footer input.srchinput");

	// global form validation function
	$("form[rel=validate]").submit(function(e){
		var valid = true;
		// run the validator on each input field
		$(this).find("input, select").each(function(){
			// If an imput element with rel value and hidden css exists means the form still has errors
			if ($(this).attr("rel") && $(this).css("display") == "none")
			{
				valid = false;
			}
			// does it even have a rel attribute ?
			if ($(this).attr("rel") && $(this).css("display") != "none")
			{
				// get the JSON object in the rel attribute
				var opt = "";
				eval("opt = " + $(this).attr("rel"));
				var msg = opt.message;

				// switch between the various types of input methods
				switch (opt.type)
				{
					case 'name':
						if (!$(this).val().match(/^[a-zA-Z0-9\s]+$/)){
							showError(this, (typeof msg == 'undefined' ? 'Username Incorrect' : msg));
							valid = false;
						}
						break;

					case 'select':
						if ($(this).val() == $(this).find("option:first").val()){
							showError(this);
							valid = false;
						}
						break;

					case 'usazip':
						if (!$(this).val().match(/^[0-9]{5}$/)){
							showError(this, (typeof msg == 'undefined' ? 'Please enter correct ZIP': msg));
							valid = false;
						}
						break;

					case 'email':
						if (!$(this).val().match(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i)){
							showError(this, (typeof msg == 'undefined' ? 'Please enter correct Email ID': msg));
							valid = false;
						}
						break;

					case 'cmail':
						// This requires an element with the email rel to be present
						if ($(this).val() != $(this).parents("form").find("[rel*='email']").val() || $(this).val().length == 0){
							showError(this, (typeof msg == 'undefined' ? 'Please confirm your Email ID': msg));
							valid = false;
						}
						break;

					case 'password':
						if (typeof opt.minlength != 'undefined')
						{
							if ($(this).val().length < opt.minlength){
								showError(this,(typeof msg == 'undefined' ? 'Password Too Short' : msg));
								valid = false;
							}
						}
						else
							if ($(this).val().length < 5){
								showError(this,(typeof msg == 'undefined' ? 'Password Too Short' : msg));
								valid = false;
							}
						break;

					default:
						break;
				}
			}
		});
		return valid;
	});
});
// Personals Match API
var personalsAPI ={
	// Array storing all profiles and their details for sorting purposes
	singlesArray : [],
	url : "",
	container : "",
	callback : function(){ },

	populateGallery : function (arr, container){
		var finHtml = "";
		var galViewSize = 12;
		var detailedViewSize = 4;
		var arrLength = arr.length;
		var selectedGallery = true;

		finHtml = '<ul>';
		for (i = 0; i < arrLength; i++)
		{
			finHtml += '<li><a target="_blank" href="http://webcenter.match.love.aol.com/profile/showprofile.aspx?lid=1000005&TP=PRTBK&Handle=' + arr[i][5] + '&TrackingID=525516&BannerID=663937"><img src="' + arr[i][3] + '" /></a><h6><a href="http://webcenter.match.love.aol.com/profile/showprofile.aspx?lid=1000005&TP=PRTBK&Handle=' + arr[i][5] + '&TrackingID=525516&BannerID=663937">' + arr[i][5] + '<br/><span>' + arr[i][1] + ' - ' + arr[i][2] + '</a></h6></span></li>';
		}
		finHtml += '</ul>';
		$(container).html(finHtml);
	},

	call : function (data, container, callback){
		personalsAPI.url = "/partnerModule.js?f=json&" + data + "&callback=personalsAPI.readResponse";
		personalsAPI.preAjax();
		personalsAPI.container = container;
		personalsAPI.callback = callback;
		getJS(personalsAPI.url);
	},

	readResponse : function(response){
		var profiles = response.profiles;
		var fields = response.fields;
		if (profiles.length)
		{
			for (var i = 0; i < profiles.length; i++)
			{
				var thisProfile = [];
				thisProfile[0] = i;
				thisProfile[1] = profiles[i].age;
				thisProfile[2] = profiles[i].city + ", " + profiles[i].state;
				thisProfile[3] = profiles[i].photouri;
				thisProfile[4] = profiles[i].photocount - 1;
				thisProfile[5] = profiles[i].handle;
				thisProfile[6] = profiles[i].eassaytext;
				thisProfile[7] = profiles[i].headline;
				personalsAPI.singlesArray[i] = thisProfile;
			}
			if(personalsAPI.container != "")
				personalsAPI.populateGallery(personalsAPI.singlesArray, personalsAPI.container);
			
			personalsAPI.postAjax();

			if(typeof personalsAPI.callback != "undefined")
				personalsAPI.callback.apply(this,new Array({ 'profiles' : new Array(profiles) , 'fields' : fields }));
		}
		else
		{
			personalsAPI.postAjax();
			personalsAPI.error();

			if(typeof personalsAPI.callback != "undefined")
				personalsAPI.callback.apply(this,new Array({ 'profiles' : profiles , 'fields' : fields }));
		}
	},

	postAjax : function(){
	},

	preAjax : function(){
	},

	error : function(){
	}
};


// Singles Finder Object //
var singlesFinder ={
	
	// Used for storing the last succesfull JSON call
	lastCall : "",
	
	// List of selected users for comparison
	userList : [],

	// Total numbers of singles allowed to compare
	maxSingles : 4,

	// Ready to make another ajax call?
	ajax : true,

	// Set default values for gallery and detailed views
	view  : { 'detailed' : { 'ppage' : 4, 'currentPage' : 1 }, 'gallery' : { 'ppage' : 9, 'currentPage' : 1 } },
		
	// Total No of Profiles loaded
	totalProfiles : "",

	// Last change string for omniture
	lastChange : "Location",

	// Current view for omniture
	currentView : "sfdetailed",

	// Function to check if a user is added in the list and add/remvoe as required
	checkUser : function(element,handle){
		element = $(element);
		// Is element checked
		if(element.filter(':checked').length){
			if(singlesFinder.userList.length >=  singlesFinder.maxSingles){
				element.attr('checked', false);				
				showMessage('ul.result', 'You can select up to four profiles at a time for comparison','message','color:#2A231F; font-size:2em;',2000);
			}
			else{
				singlesFinder.userList.push(handle);
				$('input[rel="'+element.attr('rel')+'"]').attr('checked', true);
			}
		}
		else{
			var index = $.inArray(handle, singlesFinder.userList);
			singlesFinder.userList.splice(index,index+1);
		}
	},
	
	// Takes the user to the compare singles page
	compareSingles : function(){
		if(singlesFinder.userList.length < 2)
			showMessage('ul.result', 'Please select at least two profiles for comparison','message','color:#2A231F; font-size:2em;',2000);
		else
		{
			// submit a hidden form with the user selected profiles and their values in JSONP format
			var html =	'<form action="/compare-profiles/" method="post" id="csFormsf">'+
						'	<input type="hidden" value="" name="profiles"/>'+
						'</form>';
			// generate the value of the profile
			var t = singlesFinder.lastCall;
			var value = "";
			for(var i=0; i<t.length; i++){
				for(var k=0; k<singlesFinder.userList.length; k++){
					if( t[i].handle == singlesFinder.userList[k] ){
						value += t[i].handle.replace(/\'/g, "\\'") + "||" + t[i].marital.replace(/\'/g, "\\'") + "||" + t[i].kidshave.replace(/\'/g, "\\'") + "||" + t[i].kidswant.replace(/\'/g, "\\'") + "||" + t[i].ethnicity.replace(/\'/g, "\\'")+ "||" + t[i].height.replace(/\'/g, "\\'") + "||" + t[i].religion.replace(/\'/g, "\\'") + "||" + t[i].smoke.replace(/\'/g, "\\'") + "||" + t[i].drink.replace(/\'/g, "\\'") + "||" + t[i].essaytext.replace(/\'/g, "\\'").replace(/\?$/,'...') + "||" + t[i].photouri.replace(/\'/g, "\\'") +"|||";
					}
				}				
			}
			$('body').append(html).find("#csFormsf").find('input[name="profiles"]').val(value);
			$("#csFormsf").submit();
		}
	},

	// Remove the checked element on clicking of span
	removeChecked : function(element){
		var input = $("input[rel=" + $(element).attr('rel') + "]").attr('checked',false);
		singlesFinder.lastChange =  input.parent().parent().siblings('h4').text();
		input = input.parent().parent().siblings("input[type='hidden']");
		input.val(input.val().replace($(element).attr('rel') + '|',""));
		$(element).remove();
		if(!singlesFinder.ajax){ singlesFinder.populateSinglesFinder(); }
	},

	// Switch to page based on position or number
	switchPage : function(page, type){
		scroll(0,280);
		var container = $("div.rightColsf li."+type);
		var li =  container.find("ul li");
		var currentPage = singlesFinder.view[type].currentPage;
		var perPage = singlesFinder.view[type].ppage;

		if(page == 'next')
			page = currentPage+1;
		else if(page == 'previous')
			page = currentPage-1;

		if( (li.length - (page-1)*perPage ) <= 0 || page < 1)
			return false;
		
		singlesFinder.view[type].currentPage = page;

		// Implemented lazy loading so switch of page results in swapping the backgroundimage/src with the rel value
		if(page == 1)
		{
			li.hide().filter(':lt('+(page)*perPage+')').each(function(){ 
				if(type=='gallery')
				{ var elem=$(this).find('div'); elem.css('background-image','url(' + elem.attr('rel') + ')'); }
				else 
				{ var elem=$(this).find('img'); elem.attr('src',elem.attr('rel')); }
			}).fadeIn('fast');
		}
		else
		{
			li.hide().filter(':gt('+((page-1)*perPage - 1)+'):lt('+ perPage+')').each(function(){ 
				if(type=='gallery')
				{ var elem=$(this).find('div'); elem.css('background-image','url(' + elem.attr('rel') + ')'); }
				else 
				{ var elem=$(this).find('img'); elem.attr('src',elem.attr('rel')); }
			}).fadeIn('fast');
		}

		container.data('currentPage' ,page);
		var thisspan = container.find('div.pageof span');
		thisspan.html(thisspan.html().replace(/^(\d)+/, page));

		container.find('div.pagelnk span a').each(function(){ 
			if($(this).html() == page)
				$(this).css('font-weight','bold').siblings().css('font-weight','normal')
		});
		return true;
	},
		
	// Update pagination
	resetPagination : function(){
		$('ul.result > li[rel]').each(function(){
			var count = Math.ceil(singlesFinder.totalProfiles / singlesFinder.view[$(this).attr('class')].ppage);
			var html = "";
			var type = $(this).attr('class');

			if(count > 8){
				for(var i=0;i<6;i++){
					html+= '<a href="javascript:void(0)" onclick="singlesFinder.switchPage('+(i+1)+',\''+type+'\')">'+(i+1)+'</a> ';
				}
				html += '... <a href="javascript:void(0)" onclick="singlesFinder.switchPage('+count+',\''+type+'\')">'+count+'</a>';
			}				
			else{
				for(var i=0;i<count;i++){
					html+= '<a href="javascript:void(0)" onclick="singlesFinder.switchPage('+(i+1)+',\''+type+'\')">'+(i+1)+'</a> ';
				}
			}
			$(this).find('div.pageof span').html('1 of ' + count);
			$(this).find('div.pagelnk span').html(html);				
		});
		return false;
	},
	
	// Populate the singles finder
	populateSinglesFinder: function(){
		scroll(0,280);
		showMessage('ul.result', 'Loading ...','loading','font-size:2em;');
		var sf = $("#singlesFinder");

		// Reset the selected users list
		singlesFinder.userList = [];
		
		// Serialise
		var data = sf.serialize().replace(/%7C&/g,'&').replace(/%7C$/g,'');
		
		// Omniture parameters
		
		s_265.pageName=s_265.pfxID + " : " +"Singles Finder Search Results " + ( singlesFinder.currentView == 'sfgallery' ? "Gallery " : "" ) + "- " + singlesFinder.lastChange;
		var omnistr = sf.find('input.locat').val() + "|" ;
		sf.find("input[type=checkbox]").each(function(){ if($(this).attr('checked')){ omnistr += $(this).attr('rel') + "|"; }  });
		s_265.prop21 = omnistr;
		s_265.t();
		
		personalsAPI.call(data,'',function(data){
			var profiles = data.profiles[0];
			var fields = data.fields;
			if(typeof profiles != 'undefined')
			{
				singlesFinder.totalProfiles = profiles.length;
				var htmlgal = "<ul>",htmldet = "<ul>",htmlfield ="";
				for(i in profiles)
				{
					// Gallery HTML
					htmlgal +=	'<li>'+
								'	<div rel="'+profiles[i].photouri.replace(/sthumbnails/g,'pictures')+'" >'+
								'		<del>	'+
								'			<span id="matchsmall" class="plogo">&nbsp;</span>'+
								'			<span><h2><a href="http://webcenter.match.love.aol.com/profile/showprofile.aspx?lid=1000005&TP=PRTBK&Handle='+profiles[i].handle+'&TrackingID=525516&BannerID=663937">'+profiles[i].handle+'</a></h2></span>'+
								'			<span>'+profiles[i].age+' year old '+profiles[i].gender+'</span>'+
								'			<span>'+profiles[i].city+' '+profiles[i].state+'</span>'+
								'			<span><a href="http://webcenter.match.love.aol.com/profile/showprofile.aspx?lid=1000005&TP=PRTBK&Handle='+profiles[i].handle+'&TrackingID=525516&BannerID=663937" title="View Profile">View Profile</a></span>'+
								'		</del>'+
								'	</div>'+
								'	<label><input type="checkbox" rel="'+profiles[i].handle+'" onclick="singlesFinder.checkUser(this,\''+profiles[i].handle+'\')"/> Compare</label>'+
								'</li>';

					// Detail HTML
					htmldet +=	'<li><img src="" rel="'+profiles[i].photouri.replace(/sthumbnails/g,'pictures')+'" /><div class="info1"><a class="h1" href="http://webcenter.match.love.aol.com/profile/showprofile.aspx?lid=1000005&TP=PRTBK&Handle='+profiles[i].handle+'&TrackingID=525516&BannerID=663937">'+profiles[i].handle+'</a><span>'+profiles[i].age+' year old '+profiles[i].gender+' <br/> '+profiles[i].city+' '+profiles[i].state+', US</span>'+
								'<table><tbody>'+
								'	<tr><td><strong>Relationships:</strong></td><td>'+profiles[i].marital.replace(/^null$/i, 'Not Provided').replace(/([a-z])([A-Z])/g,"$1 $2") +'</td></tr>'+
								'	<tr><td><strong>Have Kids:</strong></td><td>'+profiles[i].kidshave.replace(/^null$/i, 'Not Provided').replace(/([a-z])([A-Z])/g,"$1 $2") +'</td></tr>'+
								'	<tr><td><strong>Want Kids:</strong></td><td>'+profiles[i].kidswant.replace(/^null$/i, 'Not Provided').replace(/([a-z])([A-Z])/g,"$1 $2") +'</td></tr>'+
								'	<tr><td><strong>Ethnicity:</strong></td><td>'+profiles[i].ethnicity.replace(/^null$/i, 'Not Provided') +'</td></tr>'+
								'	<tr><td><strong>Height:</strong></td><td>'+profiles[i].height.replace(/^null$/i, 'Not Provided') +'</td></tr>'+
								'	<tr><td><strong>Drink:</strong></td><td>'+profiles[i].drink.replace(/^null$/i, 'Not Provided').replace(/([a-z])([A-Z])/g,"$1 $2") +'</td></tr>'+
								'	</tbody></table></div><div class="info1 sfpartinfo">'+
								'	<a title="Match.com" class="matchlogo" href="http://webcenter.match.love.aol.com/profile/showprofile.aspx?lid=1000005&TP=PRTBK&Handle='+profiles[i].handle+'&TrackingID=525516&BannerID=663937">&nbsp;</a>'+
								'	<a title="View Profile" class="viewprof" href="http://webcenter.match.love.aol.com/profile/showprofile.aspx?lid=1000005&TP=PRTBK&Handle='+profiles[i].handle+'&TrackingID=525516&BannerID=663937"> </a>'+
								'</div><label><input type="checkbox" rel="'+profiles[i].handle+'" onclick="singlesFinder.checkUser(this,\''+profiles[i].handle+'\')"/> Compare</label></li>';
				}
	
				// Fields HTML
				htmlfield+= '<p><strong>' + fields.totalprofilesinpostalcode + '</strong> single '+(profiles[i].gender.match(/female/i) ? 'women' : 'men' )+' found in <strong>' + sf.find('input[name=zipCode]').val() + '</strong></p><div class="critcontain">';
				$("#singlesFinder input:checked").each(function(){ htmlfield+="<span onclick='singlesFinder.removeChecked(this)' rel='"+$(this).attr('rel') +"'>"+$(this).parent().parent().siblings('h4').text() + " : " +$(this).parent().text()+"</span>&nbsp;&nbsp;"; });
				htmlfield+= '</div>';

				// Populate all the fields
				$('li.gallery ul').replaceWith(htmlgal + "</ul>");
				$('li.detailed ul').replaceWith(htmldet + "</ul>");
				$('div.rightColsf div.crit').html(htmlfield);

				hideMessage('ul.result');

				singlesFinder.resetPagination();
				// Switch to first page
				singlesFinder.switchPage(1,'gallery');
				singlesFinder.switchPage(1,'detailed');
				// Store profiles for later usage
				singlesFinder.lastCall = profiles;
				// Update the detail text about users search
			}
			else
			{
				showMessage('ul.result', 'We were unable to find any singles for the given criteria, Please try changing the settings','message','color:#2A231F; font-size:2em;');
			}
		});
	}

};

// Global JS Object for AOL Personals
var personals ={
	// Intialization function based on various pages
	init : function(param){
		switch (param)
		{
			case 'main':

				var leftCol = $('div.leftCol');
				var minage = 25, maxage = 45;

				// Main Page man woman selection
				leftCol.find("a.clsGender").bind('click', function(){
					if ($(this).hasClass('clsMan')){
						$(this).addClass("selectedM").siblings().removeClass("selectedW");

						if ($(this).hasClass('seeker')){
							$(this).parents("form:eq(0)").find("input[name='sgender']").val("male");
						}
						else{
							$(this).parents("form:eq(0)").find("input[name='gender']").val("male");
						}
					}
					else{
						$(this).addClass("selectedW").siblings().removeClass("selectedM");

						if ($(this).hasClass('seeker')){
							$(this).parents("form:eq(0)").find("input[name='sgender']").val("female");
						}
						else{
							$(this).parents("form:eq(0)").find("input[name='gender']").val("female");
						}
					}
				});

				// Friendly Input for the text Box
				//leftCol.find("div.singles_search input.txtBox").val(userData.userLocation);
				friendlyInput("div.singles_search input.txtBox");

				// On form Submit go to singles finder
				leftCol.find("div.singles_search form").submit(function(){
					var obj = this;
					var userInput = $(obj).find('input.txtBox').val();
					
					// Is the user clicking without changing ?
					if($(obj).find('input.txtBox').val() == 'City, State Or Zip Code')
					{
						showError($(obj).find('input.txtBox'));
						return false;
					}

					// did we already find a location?
					if($(obj).data('done') == true)
						return true;
										
					// Call to get the correct location
					$.getJSON('/getLocation',{'where' : userInput}, function(response){						
						if(response.zip != '')
						{
							$(obj).find('input[name="zip"]').val(response.zip);
							$(obj).data('done',true); 
							setCookie('srchPrfs',$(obj).find('input[name="sgender"]').val() + '||'+$(obj).find('input[name="gender"]').val()+'||'+$(obj).find('input[name="minage"]').val()+'||'+$(obj).find('input[name="maxage"]').val()+'||'+ userInput ,7);
							obj.submit();			
						}
						else
						{
							showError($(obj).find('input.txtBox'),'Please Enter A Valid Location');
						}
					});

					return false;
				});

				//Initialize the page with the default value of location of the user
				personalsAPI.call('partner=match&minage=25&maxage=35&gender=female&sgender=male&num=20&zipCode=' + userData.userZip, "#singlesnear div.container", 
					function(){ $('#singlesnear').infiniteCarousel('> div').find('h4').html('Singles Near ' + userData.userLocation); });
				
				// Tab feature for tabbed modules
				leftCol.find('#datingsvcs ul.tabs li').click(function (){
					// remove selected classes from siblings
					$(this).siblings().removeClass('active activefirstcorner activelastcorner hover hoverfirstcorner');

					// add respective class, could be done in a simpler way but IE6 doesn't support joined css classes
					if ($(this).hasClass('firstcorner'))
						$(this).addClass('activefirstcorner active');
					else if ($(this).hasClass('lastcorner'))
						$(this).addClass('activelastcorner active');
					else
						$(this).attr('class', 'active');

					// Element with the suitable index is displayed
					var index = $(this).parent().children().index(this);
					leftCol.find("#datingsvcs div.tab_contents_container > div:eq(" + index + ")").addClass('tab_contents_active').siblings().removeClass('tab_contents_active');

				});

				//Bind the tab hover functions for dating services
				leftCol.find("#datingsvcs li").hover(function(){
					// remove selected classes from siblings
					$(this).siblings().removeClass('hover hoverfirstcorner');

					// add respective class, could be done in a simpler way but IE6 doesn't support joined css classes
					if ($(this).hasClass('firstcorner'))
						$(this).addClass('hoverfirstcorner');
					else
						$(this).addClass('hover');
				}, function(){
					// remove selected classes from siblings
					$(this).removeClass('hover hoverfirstcorner').siblings().removeClass('hover hoverfirstcorner');
				});

				// Set user preferences based on previous search settings
				var settings = getCookie('srchPrfs').split('||');
				if (settings == "")
				{
					settings = new Array("male","female","25","45","City, State Or Zip Code");
				}
				if(settings.length == 5)
				{
					if(settings[0] == 'male')
						leftCol.find('a.seeker.clsMan').click();
					else
						leftCol.find('a.seeker.clsWoman').click();
					
					if(settings[1] == 'male')
						leftCol.find('a.seeking.clsMan').click();
					else
						leftCol.find('a.seeking.clsWoman').click();

					minage = settings[2];
					maxage = settings[3];
					//leftCol.find('input.txtBox').val(settings[4]);
				}

				// Age Slider function to set the values of form fields based on the user input
				leftCol.find("div.singles_search input[name='minage']").val(minage);
				leftCol.find("div.singles_search input[name='maxage']").val(maxage);
				leftCol.find('h2.ageRange:eq(0)').html(minage);
				leftCol.find('h2.ageRange:eq(1)').html(maxage);

				// slider function on the slider
				$('#slider').slider({
					slide: function(event, ui){ 
						var values = $('#slider').slider('option', 'values');
						var elements = leftCol.find('h2.ageRange');

						// Change the age headings
						$(elements[0]).html(values[0]);
						$(elements[1]).html(values[1]);
						
						// Set the values in hiddne fields
						leftCol.find("div.singles_search input[name='minage']").val(values[0]);
						leftCol.find("div.singles_search input[name='maxage']").val(values[1]);
					},
					max: 99,
					min:18,
					range: true,
					values: [minage, maxage]
				});

			break;

			case 'cchart':

				var tempchart = $("ul.cchart");

				// Autofix cell heights on same columns for entire chart
				tempchart.find("ul.ccindex li").each(function(i){
					var thisheight = $(this).outerHeight() - parseInt($(this).css('padding-top')) - parseInt($(this).css('padding-bottom'));
					// IE6 fix
					$(this).height(thisheight);
					tempchart.find("li.ccitem li:nth-child("+(i+1)+")").each(function(){ 
						$(this).height(thisheight);
					});  
				});

				// Make the chart sortable
				tempchart.find("ul.ccpart").sortable({
						axis: 'x', 
						containment: 'parent', 
						cursor: 'move', 
						handle: '.cchandle',
						forcePlaceholderSize: true,
						forceHelperSize: true,											
						tolerance: 'pointer',
						start : function(event, ui){ $(ui.item[0]).addClass('ccitemh');	 },
						stop : function(event, ui){ $(ui.item[0]).removeClass('ccitemh'); }
				});
				
				// Remove function
				tempchart.find("li.ccitem li.ccmenu span").live("click",function(){
					$(this).parents('.ccitem:last').attr('rel','collapsed').addClass('cchidden').fadeOut('fast',function(){
						var ccpart = $(this).parents('.ccpart');
						var tli = ccpart.find('> li');
						var li = tli.filter(':not([rel])');
						var width = Math.floor(ccpart.width() / li.length);
						li.each(function(){ $(this).width(width).addClass('cchidden'); });
						// IE6 is a buggy browser
						if($.browser.msie && $.browser.version === '6.0')
							li.filter(":last-child").width(width-3);
						if(li.length <= Math.ceil(tli.length/2))
						{
							ccpart.find('li.ccmenu span').css('visibility','hidden').addClass('cchidden');
						}
					});
				});

				// Reset function
				$("a.ccreset").click(function(){ tempchart.find(".cchidden").show().removeClass('cchidden ccheadingh').css({'display':'','visibility':'','width':''}).removeAttr('rel'); });

				// Collapse functionality
				tempchart.find(".ccheading").toggle(function(){
					$(this).addClass('ccheadingh cchidden');
					var hideclass = $(this).next().attr('class').split(' ')[0];
					tempchart.find('.' + hideclass).hide().addClass('cchidden');
				}, function(){
					$(this).removeClass('ccheadingh cchidden');
					var showclass = $(this).next().attr('class').split(' ')[0];
					tempchart.find('.' + showclass).show();
				});

				// Hand Hover functionality
				tempchart.find("li.cchandle").hover(function(){
					$(this).addClass('cchandleh');
				}, function(){
					$(this).removeClass('cchandleh');
				});

			break;

			case 'singlesFinder':
				
				var sf = $("#singlesFinder");
		

				// Main Page man woman selection
				$("a.clsGender").bind('click', function(){
					if ($(this).hasClass('clsMan')){
						$(this).addClass("selectedM").siblings().removeClass("selectedW");
						if ($(this).hasClass('seeker')){
							$(this).parents("form:eq(0)").find("input[name='sgender']").val("male");
						}
						else{
							$(this).parents("form:eq(0)").find("input[name='gender']").val("male");
						}
					}
					else{
						$(this).addClass("selectedW").siblings().removeClass("selectedM");
						if ($(this).hasClass('seeker')){
							$(this).parents("form:eq(0)").find("input[name='sgender']").val("female");
						}
						else{
							$(this).parents("form:eq(0)").find("input[name='gender']").val("female");
						}
					}
					if(!singlesFinder.ajax){ singlesFinder.populateSinglesFinder(); }
				});
				
				// Set the value of sliders
				function fnSetValues(event, ui){
					var values = $('#slider').slider('option', 'values');
					var elements = $('h2.ageRange');

					// Change the age headings
					$(elements[0]).html(values[0]);
					$(elements[1]).html(values[1]);

					// Set the values in hiddne fields
					sf.find("input[name='minage']").val(values[0]);
					sf.find("input[name='maxage']").val(values[1]);
				}

				// slider function on the slider
				$('#slider').slider({
					slide: function(event, ui){ fnSetValues(event, ui); },
					max:99,
					min:18,
					range: true,
					values: [userData.minage, userData.maxage],
					stop: function(event, ui){ singlesFinder.populateSinglesFinder(); }
				});
				
				fnSetValues();

				// checkbox preview functionality
				$("div.leftColsf div.crit input[type='checkbox']").click(function(){
					var input = $(this).parent().parent().siblings("input[type='hidden']");	
					singlesFinder.lastChange =  $(this).parent().parent().siblings('h4').text();
					if($(this).attr('checked') == false)
					{
						$("span[rel="+ $(this).attr('rel') + "]").remove();
						input.val(input.val().replace($(this).attr('rel') + '|',""));
					}
					else
					{
						var html="<span onclick='singlesFinder.removeChecked(this)' rel='"+$(this).attr('rel') +"'>"+$(this).parent().parent().siblings('h4').text() + " : " +$(this).parent().text()+"</span>&nbsp;&nbsp;";
						$("div.rightColsf .crit div.critcontain").append(html);
						input.val(input.val() + $(this).attr('rel') + '|');
					}
					if(!singlesFinder.ajax){ singlesFinder.populateSinglesFinder(); }
				 });

				// Slide open the containers for checkboxes
				$("div.leftColsf div.crit h4").toggle(function(){ 
					$(this).addClass('opened').next('ul').slideDown('fast');
				},function(){ 
					$(this).removeClass('opened').next('ul').slideUp('fast');
				});

				// Tabs for gallery and detailed view
				$("div.rightColsf ul.sftabs li").click(function(){ 
					$(this).addClass('selected').siblings().removeClass('selected');
					var thisIndex = $(this).parent().find('li').index(this);
					singlesFinder.currentView =  $(this).attr('rel');
					$('div.rightColsf .result li[rel="' + $(this).attr('rel') + '"]').show().siblings('[rel]').hide();
				});
				
				// Validation for input types
				sf.submit(function(){
					var userInput = $(this).find('input.locat').val();
					var obj = this;
					if(userInput.length > 0)
					{
						$.getJSON('/getLocation',{'where' : userInput}, function(response){ 
							if(response.zip != '')
							{
								$(obj).find('input[name="zipCode"]').val(response.zip);
								singlesFinder.lastChange = "Location";
								singlesFinder.populateSinglesFinder();
							}
							else
								showError($(obj).find('input.locat'),'Please check your input');
						});
					}
					else
						showError($(obj).find('input.locat'),'Please check your input');
				});

				// Populating the select boxes
				sf.find('select[name=minheight],select[name=maxheight]').each(function(){ 
					var html = '<select name="'+ $(this).attr('name') +'">';
					for( var i=10; i<=300; i+=5){
						html+='<option '+( ($(this).attr('name') == 'minheight' && i==10) ? 'selected=""' : (($(this).attr('name') == 'maxheight' && i==300) ? 'selected=""' : '' ))+' value="'+i+'">'+i+' cm</option>';
					}
					html += '</select>';
					$(this).replaceWith(html);
				});

				// Fill singles finder with previous values
				sf.find('input[name="zipCode"]').val(userData.zip);
				sf.find('input[name="minage"]').val(userData.minage);
				sf.find('input.locat').val(userData.search);
				sf.find('input[name="maxage"]').val(userData.maxage);
				sf.find('input[name="gender"]').val(userData.gender);
				sf.find('input[name="sgender"]').val(userData.sgender);
				if(userData.gender == 'male')
					$('a.seeking.clsMan').click();
				else
					$('a.seeking.clsWoman').click();

				if(userData.sgender == 'male')
					$('a.seeker.clsMan').click();
				else
					$('a.seeker.clsWoman').click();

				// Gallery view hovers to show hide user details
				$("li.gallery ul div").live('mouseover', function(){ $(this).addClass('hover'); });
				$("li.gallery ul div").live('mouseout', function(){ $(this).removeClass('hover'); });

				// Function on box change
				sf.find('select[name=minheight],select[name=maxheight]').change(function(){ 

					if($(this).attr('name') == 'minheight' && parseInt(sf.find('select[name=maxheight]').val()) < parseInt($(this).val()) )
					{
						var html = '<select name="maxheight">';
						html+='<option value="'+$(this).val()+'">'+$(this).val()+' cm</option>';
						for( var i=parseInt($(this).val())+5; i<=300; i+=5){
							html+='<option value="'+i+'">'+i+' cm</option>';
						}
						html += '</select>';
						sf.find('select[name=maxheight]').replaceWith(html);
					}
					else if($(this).attr('name') == 'maxheight' && parseInt(sf.find('select[name=minheight]').val()) > parseInt($(this).val()) )
					{
						var html = '<select name="minheight">';
						for( var i=10; i<=parseInt($(this).val())-5; i+=5){
							html+='<option value="'+i+'">'+i+' cm</option>';
						}
						html+='<option selected="" value="'+i+'">'+i+' cm</option>';
						html += '</select>';
						sf.find('select[name=minheight]').replaceWith(html);
					}
					if(!singlesFinder.ajax){ singlesFinder.populateSinglesFinder(); }
				});

				singlesFinder.ajax = false;
				
				singlesFinder.populateSinglesFinder();

			break;
			
			// Compare Singles Page
			case 'cProfiles':
				// Has to be defined beforehand
				if( typeof cS == 'string')
				{
					// Profile Spliy
					cS = cS.split('|||');
					var html = '<ul class="ccpart">';

					for(var i=0; i<cS.length-1; i++)
					{
						// Field Split
						var tmp = cS[i].split('||');
						
						// Dirty Code to generate the html
						html += '<li class="ccitem"><ul>'+
								'	<li class="ccmenu"><span class="remove">Remove</span></li>'+
								'<li onmouseout="personals.cchart.highlight(\'ccrow1\',false)" onmouseover="personals.cchart.highlight(\'ccrow1\',true)"class="ccrow1 hd2"><img src="'+tmp[10]+'" alt="Profile Image" /><a href="http://webcenter.match.love.aol.com/profile/showprofile.aspx?lid=1000005&TP=PRTBK&Handle='+tmp[0]+'&TrackingID=525516&BannerID=663937">'+tmp[0]+'<br />View Profile</a></li>';
						for(var k=1; k<9; k++)
						{
							html += '<li onmouseout="personals.cchart.highlight(\'ccrow'+(k+1)+'\',false)" onmouseover="personals.cchart.highlight(\'ccrow'+(k+1)+'\',true)"class="ccrow'+(k+1)+'">'+tmp[k].replace(/^null$/i, 'Not Provided').replace(/([a-z])([A-Z])/g,"$1 $2")+'</li>';
						}
						html += '<li onmouseout="personals.cchart.highlight(\'ccrow'+(k+1)+'\',false)" onmouseover="personals.cchart.highlight(\'ccrow'+(k+1)+'\',true)"class="ccrow'+(k+1)+' hd1">'+tmp[k]+'</li>';
						k++;
						html +=	'<li class="cchandle">&nbsp;</li><li onmouseout="personals.cchart.highlight(\'ccrow'+(k+1)+'\',false)" onmouseover="personals.cchart.highlight(\'ccrow'+(k+1)+'\',true)"class="ccrow'+(k+1)+'"><a title="match.com" class="matchlogo" href="/search-for-a-match">&nbsp;</a></li></ul></li>';
					}
					$("li.pprofiles").html(html + '</ul>');
				}

				var cchart = $('ul.cchart');
				// Fix the profile boxes
				$('.ccpart > li').width(cchart.find('.ccpart').width() / (cS.length-1));
				if(cS.length == 3)
				{
					cchart.find('.ccmenu span').css('visibility','hidden');
				}
			break;

			default:
			break;
		}
	},
	
	// Comparison chart functions
	cchart : { 
		// highlight function
		highlight : function(row, status)
		{
			if(status)
			{
				var obj = $('li.' + row);
				obj.height('');
				obj.addClass('hover');
				var h = obj.height();
				obj.height(h);
			}
			else
			{
				var obj = $('li.' + row);
				obj.height('');
				obj.removeClass('hover');
				var h = obj.height();
				obj.height(h);
			}
		},
		
		// delete row function
		deleterow : function(row)
		{
			$('li.' + row).hide('slow').addClass('cchidden');
		}
	}
};
// fbLink v1.0d

var _fBr=encodeURIComponent(window.location.href);
var _fBh=362;
var _fBw=452;
var _fByt=(((screen.height-_fBh)/2)-100);
var _fBxl=((screen.width-_fBw)/2);


function _fBsG () {
	var _chG = typeof 's_channel' == 'undefined'? s_channel : '' ;
	return _chG;
}

function _fBsH () {
	var _chH = 'channel' in s_265? s_265.channel : "";
	_chH = _chH=='undefined'?'':_chH;
	return _chH;
}

function fBch() {
	var _ch = typeof s_265 == 'undefined'?_fBsG():_fBsH();
	return _ch;
}


function fBo(_sid){
	var _fBhref = 'http://feedback.aol.com/rs/rs.php?sid='+_sid;
	window.open(_fBhref+'&referer='+_fBr+'&ch='+fBch(),'feedback','width='+_fBw+',height='+_fBh+',screenX='+_fBxl+',screenY='+_fByt+',top='+_fByt+',left='+_fBxl+',resizable=yes,copyhistory=yes,scrollbars=no');
	return false;
}

function fBo2(_sid){
	var _fBhref = 'http://feedback.aol.com/rs/rs.php?sid='+_sid;
	window.open(_fBhref+'&referer='+_fBr+'&ch='+fBch(),'feedback','width='+_fBw+',height='+_fBh+',screenX='+_fBxl+',screenY='+_fByt+',top='+_fByt+',left='+_fBxl+',resizable=yes,copyhistory=yes,scrollbars=no');
}

function openFBHelp(href) {
	var _fBHelph=520;
	var _fBHelpw=794;
	var _fBHelpyt=(((screen.height-_fBHelph)/2)-100);
	var _fBHelpxl=((screen.width-_fBHelpw)/2);
	var href2=(href.indexOf('?')==-1?href+'?':href+'&');
    
	window.open(href2+'referer='+_fBr+'&ch='+fBch(),'feedback_help','width='+_fBHelpw+',height='+_fBHelph+',screenX='+_fBHelpxl+',screenY='+_fBHelpyt+',top='+_fBHelpyt+',left='+_fBHelpxl+',resizable=yes,copyhistory=yes,scrollbars=no');
}

function openStandard(href) {
	window.open(href,'','screenX=0,screenY=0,top=0,left=0,location=yes,toolbar=yes,resizable=yes,copyhistory=yes,scrollbars=yes');
}
