// JavaScript Document
var url='http://www.aaaromance.com';
//var url='http://kpk';

function checkAll()
	{
		var checks,i;
		checks=document.getElementsByName('sel[]');
		for (i=0;i<checks.length;i++)
			checks[i].checked=true;
	}
function uncheckAll()
	{
		var checks,i;
		checks=document.getElementsByName('sel[]');
		for (i=0;i<checks.length;i++)
			checks[i].checked=false;
	}
function g_byID(id)
{
	return document.getElementById(id);
}

function show(id)
{
	g_byID(id).style.display='';
}

function hide(id)
{
	g_byID(id).style.display='none';
}

function show_hide(id)
{
	if (g_byID(id).style.display=='none')	
		show(id);
	else hide(id);
}

function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  //strEmail = document.forms[0].email.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      alert('A valid e-mail address is required.\nPlease amend and retry');
      return false;
    } 
    return true; 
}

function isEmpty(str,field)
{
	if (str=="" || str==" " || str==null)
		{alert('Fill all mandatory fields! "'+field+'" is mandatory !');
		return true;
		}
	return false;
}

function isSelected(str,field)
{
	if (str=="" || str=="0")
		{alert('Fill all mandatory fields! "'+field+'" is mandatory !');
		return false;
		}
	return true;
}

	function validate_form()
	{		
		if (!isValidEmail(g_byID('email').value)) return false;
	//	if (isEmpty(g_byID('nick').value,'Nickname')) return false;
		if (isEmpty(g_byID('city').value,'City')) return false;		
		if (isEmpty(g_byID('phone').value,'Phone')) return false;
		if (isEmpty(g_byID('rates').value,'Rates')) return false;
	//	if (isEmpty(g_byID('description').value,'Description')) return false;		
		if (!isSelected(g_byID('country').value)) return false;
		return true;
	}

	function openBig(src,title)
					{
						window.open('/preview.php?img='+src+'&title='+title,'mywindows','status=0, toolbar=0, menubar=0, location=0, resizeable=1, width=470, height=350, focus=1, directories=0');
					}
	
	function openProfile(id,ordinal)
	{
			window.open('/profile.php?id='+id+'&layout=1&ordinal='+ordinal,'profile','status=0, toolbar=0, menubar=0, location=0, resizable=1, width=615, height=550, focus=1, scrollbars=1, directories=0');
	}
	
	function openSendMail(id)
	{
			window.open('/send_message.php?id='+id+'&layout=1','send_message','status=0, toolbar=0, menubar=0, location=0, resizable=1, width=615, height=550, focus=1, scrollbars=1, directories=0');
	}
	
	function openViewMail(id)
	{
			window.open('/view_mail.php?id='+id+'&layout=1','view_message','status=0, toolbar=0, menubar=0, location=0, resizable=1, width=615, height=550, focus=1, scrollbars=1, directories=0');
	}
	
	function replyMail(user,mail)
	{
			window.open('/send_message.php?id='+user+'&replyMailId='+mail+'&layout=1','send_message','status=0, toolbar=0, menubar=0, location=0, resizable=1, width=615, height=550, focus=1, scrollbars=1, directories=0');
	}
	
	function openPopup(popURL){

	var popLeft = (screen.width - 370) / 2;

	var popTop = (screen.height - 590) / 2;

	passPop=window.open(popURL,"","width=370,height=590,top="+popTop+",left="+popLeft+",")

}

function openAdvertise(popURL){

	passPop=window.open ('http://www.girls4arabians.com/advertising/?url='+popURL,'w','width=1024, height=768, toolbar=1, resizable=1, menubar=1, location=1, status=1, scrollbars=1,').blur(); 
	window.focus();

}

function checkall(formname,checkname,thestate){
  var   el_collection=eval("document.forms."+formname+"."+checkname)
  for (c=0;c<el_collection.length;c++){
      el_collection[c].checked=thestate;
    }
} 

function doBlink() {
  // Blink, Blink, Blink...
  var blink = document.all.tags("BLINK")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

var catched=false;
function set_catched()
{
	if(catched)
		catched=false;
	else catched=true;	
}

function resizeCutter(plus,value)
{
	var w;
	
	w=document.getElementById('cutter').offsetWidth+(plus*value);
	document.getElementById('cutter').style.width=w;
	document.getElementById('cutter').style.height=w*1.3;
	
	g_byID('cutterWidth').value=w;
}

function chatch_onmousemove(ev)
{
	var picx;
	var pict;
	var IE = document.all?true:false
	
	if(!catched)
	{
	
	picx=g_byID('pic_x').value;
	pict=g_byID('pic_y').value;
	
	if(!IE)
	{
		g_byID('cutter').style.left=ev.pageX+'px';
		g_byID('cutter').style.top=ev.pageY+'px';
		g_byID('cornerLeft').value=(ev.pageX*1)-(picx*1);
		g_byID('cornerTop').value=(ev.pageY*1)-(pict*1);
	}
	else{
		g_byID('cutter').style.left=event.clientX - 2 + document.body.scrollLeft;
		g_byID('cutter').style.top=event.clientY -2 + document.body.scrollTop;
		g_byID('cornerLeft').value=g_byID('cutter').offsetLeft-(picx*1);
		g_byID('cornerTop').value=g_byID('cutter').offsetTop-(pict*1);
	}
	
	
	}
	
}

function change_sex(val)
{
	document.getElementById('sex_0').style.display='none';
	document.getElementById('sex_1').style.display='none'; 
	document.getElementById('sex_'+val).style.display='';
	
	if (val=='0')
		document.getElementById('sex_caut').value='1';
	else document.getElementById('sex_caut').value='0';
	
	document.getElementById('sex_looking_0').style.display='none';
	document.getElementById('sex_looking_1').style.display='none'; 
	document.getElementById('sex_looking_'+document.getElementById('sex_caut').value).style.display='';
}

function change_sex2(val)
{
	document.getElementById('sex_looking_0').style.display='none';
	document.getElementById('sex_looking_1').style.display='none'; 
	document.getElementById('sex_looking_'+val).style.display='';
	
	if (val=='0')
		document.getElementById('sex_eu').value='1';
	else document.getElementById('sex_eu').value='0';
	
	
	document.getElementById('sex_0').style.display='none';
	document.getElementById('sex_1').style.display='none'; 
	document.getElementById('sex_'+document.getElementById('sex_eu').value).style.display='';
	
	
}

function startBlink() {
  // Make sure it is IE4
  if (document.all)
    setInterval("doBlink()",500)
}
window.onload = startBlink;

function check_uncheck(check)
{
	if(g_byID('check_all').value==0)
	{
			checkAll();
			g_byID('check_all').value=1;
			g_byID('check_sus').checked=true;
			g_byID('check_jos').checked=true;
	}
	else{
		uncheckAll();
		g_byID('check_all').value=0;
		g_byID('check_sus').checked=false;
		g_byID('check_jos').checked=false;
	}
}
