function IsEmpty(obj, obj_type)
{
	if (obj_type == "text" || obj_type == "password" || obj_type == "textarea" || obj_type == "file")	{
		var objValue;
		objValue = obj.value.replace(/\s+$/,"");
		if (objValue.length == 0) {
			return true;
		} else {
			return false;
		}
	} else if (obj_type == "select" || obj_type == "select-one") {
		for (i=0; i < obj.length; i++) {
			if (obj.options[i].selected) 
				{
					if(obj.options[i].value==" ") 
					{return true;obj.focus();} else {return false;}
					
					if(obj.options[i].value == "0") 
					{
						if(obj.options[i].seletedIndex == "0") 
						{return true;obj.focus();}
					} else {return false;}
				}
			
		}
		return true;	
	} else if (obj_type == "radio" || obj_type == "checkbox") {
		if (!obj[0] && obj) {
			if (obj.checked) {
				return false;
			} else {
				return true;	
			}
		} else {
			for (i=0; i < obj.length; i++) {
				if (obj[i].checked) {
					return false;
				}
			}
			return true;
		}
	} else {
		return false;
	}
}

function CompareValue( NumStr, pattern )
{
	for( var Idx = 0; Idx < NumStr.length; Idx ++ )
	{
		 var Char = NumStr.charAt( Idx );
		 var Match = false;

		for( var Idx1 = 0; Idx1 < pattern.length; Idx1 ++)
		{
		 if( Char == pattern.charAt( Idx1 ) )
		 Match = true;
		}
		if ( !Match )
		return false;
 	}
   	return true;
}


function ValidateEmail(Email)
{
	var funRegExp	      = new RegExp("^[A-Za-z0-9][A-Za-z0-9_\\.\-]*\\@[a-zA-Z0-9\-]+\\.[a-zA-Z]+[\\.]?[a-zA-Z]*$");
	if (!Email.match(funRegExp)) { return false; }//if
	return true;
}

function enterfiled(rowid)
{document.getElementById(rowid).className="rowcolor";}

function onexit(rowid)
{document.getElementById(rowid).className="normalrow";}

function ChkEmpty(obj,obj_type,rowid,spanname,msg)
{

	if (obj_type=="text" || obj_type=="password" || obj_type=="textarea" || obj_type=="file")
	{
		var objValue;
		objValue = obj.value.replace(/\s+$/,"");
		if (objValue.length == 0)
		{document.getElementById(rowid).className="normalrow";document.getElementById(spanname).innerHTML=msg;return true;} 
		else {document.getElementById(rowid).className="normalrow";document.getElementById(spanname).innerHTML=" ";return false;}
	} 
	
	if (obj_type == "select") 
	{
		if (obj.selectedIndex==0)
		{document.getElementById(rowid).className="normalrow";document.getElementById(spanname).innerHTML=msg;return true;} 
		else {document.getElementById(rowid).className="normalrow";document.getElementById(spanname).innerHTML="";return false;}
		return true;	
	} 
	
	if (obj_type == "radio" || obj_type == "checkbox") 
	{
		var objlength=obj.length
		var objcount=0;
		for (i=0;i<objlength;i++ )
		{
			if(obj[i].checked){objcount=1;break;}else{objcount=0;}
		}
		if(objcount==0)
		{document.getElementById(rowid).className="normalrow";document.getElementById(spanname).innerHTML=msg;}
		else{document.getElementById(rowid).className="normalrow";document.getElementById(spanname).innerHTML=" ";}
		
		return true;
	} 
	
		return false;
}


function ValidateNo( NumStr, String )
{
	for( var Idx = 0; Idx < NumStr.length; Idx ++ )
	{
		 var Char = NumStr.charAt( Idx );
		 var Match = false;

		for( var Idx1 = 0; Idx1 < String.length; Idx1 ++)
		{
		 if( Char == String.charAt( Idx1 ) )
		 Match = true;
		}

		if ( !Match )
		return false;
 	}
   	return true;
}

function replaceAlpha(strIn) {
	var strOut='';
	for(var i=0 ; i < strIn.length ; i++) {
		var cChar=strIn.charAt(i);
		if((cChar >= 'A' && cChar <= 'Z') || (cChar >= 'a' && cChar <= 'z') || (cChar >= '0' && cChar <= '9')) {
			strOut += cChar;
		} else {
			strOut += "_";
		}
	} return strOut;
}

var t_msgn;

function launchIC(userID,destinationUserID) 
{
	var dest_id=destinationUserID.split('_');

	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
	{ 
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
		{winwidth="500";winheight="361";}
		else 
		{winwidth="500";winheight="361";}
	}
	else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
	{winwidth="500";winheight="361";}
	else
	{winwidth="500";winheight="361";}
	var wintitle=userID+"vs"+dest_id[0];
	var winurl="http://"+DOMAINARRAY['domainmodule']+"/chat/chatwindow.php?myid="+userID+"&recpid="+dest_id[0];
	var popupWindowTest=null;
	popupWindowTest=window.open(winurl,wintitle,"width="+winwidth+",height="+winheight+",toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=0");
	if(popupWindowTest==null) 
	{
		var cl_win_id;
		if(GetCookie("closewin")==null || GetCookie("closewin")=="null"){setCookie("closewin",dest_id[0]);}
		else{cl_win_id=GetCookie("closewin")+"~"+dest_id[0];setCookie("closewin",cl_win_id);}
		alert("Your popup blocker stopped an InstantCommunicator window from opening. Please disable it.");
	}

}

function launch_auto(userID,destinationUserID,firstmsg) 
{
	//alert("auto");
	var dest_id=destinationUserID.split('_');	
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
	{ 
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
		{winwidth="500";winheight="361";}
		else 
		{winwidth="500";winheight="361";}
	}
	else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
	{winwidth="500";winheight="361";}
	else
	{winwidth="500";winheight="361";}
	var wintitle=userID+"vs"+dest_id[0];
	var winurl="http://"+DOMAINARRAY['domainmodule']+"/chat/chatwindow.php?myid="+userID+"&recpid="+dest_id[0]+"&firstmsg="+firstmsg;
	var popupWindowTest=null;
	popupWindowTest=window.open(winurl,wintitle,"width="+winwidth+",height="+winheight+",toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=0");
	if(popupWindowTest==null) 
	{
		var cl_win_id;
		if(GetCookie("closewin")==null || GetCookie("closewin")=="null"){setCookie("closewin",dest_id[0]);}
		else{cl_win_id=GetCookie("closewin")+"~"+dest_id[0];setCookie("closewin",cl_win_id);}
		alert("Your popup blocker stopped an InstantCommunicator window from opening. Please disable it.");
	}
}

var VideoCheckRequest= funVideoMakeObject();
function funProtectedPassword()
{
	var frmName	=	document.frmProtectedPassword;
	if ((frmName.password.value).replace(' /\s+/','') == ''){
		document.getElementById('protecterror').innerHTML='Enter Password';
		frmName.password.value = '';
		frmName.password.focus();
		return false;
	} else {
		document.getElementById('protecterror').innerHTML='&nbsp';
	}
	var arguments	= 'password='+frmName.password.value+'&frmPasswordSubmit='+frmName.frmProtectedPasswordSubmit.value+'&matriId='+frmName.matriId.value;
	var URL			=	'http://'+DOMAINARRAY["domainmodule"]+'/video/video-view.php';
	VideoCheckRequest = MakePostRequest(URL,arguments,'VideoAjaxCallBack');
	return true;
}//funProtectedPassword



function funDisplayPassword(){
	var frmname	=	this.document.frmPassworddisplay;
	var arguments	= 'matriId='+frmname.matriId.value;
	var URL			= 'http://'+DOMAINARRAY["domainmodule"]+'/video/video-view-password.php';
	VideoCheckRequest = MakePostRequest(URL,arguments,'VideoAjaxCallBack');
	return true;
}//funDisplayPassword

function funVideoSpeed(speed,oppositematriId,URL,width,height,password,name) {
	window.open( "http://"+DOMAINARRAY['domainmodule']+"/video/show-video.php?videospeed="+speed+"&matriId="+oppositematriId+"&password="+password+"&name="+name+"", "myWindow","status = 1, height ="+height+", width = "+width+", resizable = 0")
}

function VideoAjaxCallBack()
{
	if (VideoCheckRequest.readyState == 4) 
	{
		if (VideoCheckRequest.status == 200)
		 {
			 document.getElementById('video').innerHTML	 = VideoCheckRequest.responseText;

		 }
		 else alert('There was a problem with the request.'); 
	}
}//VideoAjaxCallBack

function funVideoMakeObject(){
	var response;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer")	{
		response = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		response = new XMLHttpRequest();
	}
	return response;
}

//savesearch
function savesearchsubmit(formid) {
	var js_randid=genNumbers();
	var frm=eval("document.frm_"+formid); 
	frm.randid.value=js_randid;
	document.forms[0].submit();
}

function formFocus(frmName) {eval('document.'+frmName+'.elements[0].focus();');}
window.status = "BharatMatrimony.com";

