function getBrowserType()
{
	if (document.all)
		var version=/MSIE \d+.\d+/

	if (!document.all){
		return "ff";
	}
	else
	{
		return 'ie';
	}
}

function OpenWin(Num)
{
  var div_obj = document.getElementById(Num)
  if (div_obj.style.display=='') 
  {
   div_obj.style.display='none'; 
  }
  else
  {
   div_obj.style.display=''; 
  }  
}

function DoUrl(GetUrl)
{
	window.location = GetUrl;
}

function DoUrlAlert(GetUrl,GetMessage)
{
	var statusmessage;
		statusmessage = confirm(GetMessage);
		if(statusmessage){
			window.location = GetUrl;
		}
}

function DoAlert(GetMessage)
{
	alert(GetMessage);
}


function if_equal(GetObj1,GetObj2,message){
	if(GetObj1.value != GetObj2.value){
		GetObj2.focus();
		GetObj2.select();
		DoAlert(message);
		return false;
	}
	return true;
}


function if_lenght(GetObj,GetNum,message){
	var InnerValue = GetObj.value;
	if(InnerValue.length < GetNum){
		GetObj.focus();
		GetObj.select();
		DoAlert(message);
		return false;
	}
	return true;
}


function if_checked_box(GetObj,message){
	var z = GetObj;
	for (i=0;i<z.length;i++){
		if(z[i].checked == true ){
			return true;
		}
	}
	DoAlert(message);
	return false;
}


function if_empty_text(GetObj,message){
	if(GetObj.value == ""){
		GetObj.focus();
		GetObj.select();
		DoAlert(message);
		return false;
	}
	return true;
}


function if_checked(GetObj,message){
	if(!GetObj.checked){
		DoAlert(message);
		return false;
	}
	return true;
}

function if_empty_select(GetObj,message){
	if(GetObj.value == ""){
		GetObj.focus();
		DoAlert(message);
		return false;
	}
	return true;
}


function if_email(GetObj,message){
	var reEmail = /^[-\w\d\.]+@[-\w\d\.]+\.[-\w\d\.]+$/;
	if(!(reEmail.test(GetObj.value))){
		GetObj.focus();
		GetObj.select();
		DoAlert(message);
		return false;
	}
	return true;
}

function if_email_exist_on_db_by_ajax(GetObj,message)
{
	var SentToPage="forms/user_registration_if_email_exist.php";
	var browsertype = getBrowserType();
		xmlStr="?email="+GetObj.value;
		SentToPageInner = SentToPage+xmlStr;
		if(browsertype=='ff'){
			xmlObj = new XMLHttpRequest();
		} else {
			xmlObj = new ActiveXObject("Msxml2.XMLHTTP");
			
		}

		xmlObj.open ("POST", SentToPageInner ,false);
		xmlObj.send(null);	
		
		var responseText = xmlObj.responseText;
		xmlObj.Close;
		xmlObj = null; 
		switch(responseText)
		{
			case "exist":
				GetObj.focus();
				GetObj.select();
				DoAlert(message);
				return false;
				break;
			/*
			default:
				DoAlert(responseText);
			*/
		}
	return true;
}


function LoadAjaxContent(getfile,getelement)
{
	var browsertype = getBrowserType();
	if(browsertype=='ff'){
		xmlObj = new XMLHttpRequest();
	} else {
		xmlObj = new ActiveXObject("Msxml2.XMLHTTP");
		
	}

	xmlObj.open ("POST", getfile,false);
	xmlObj.send(null);	
	
	var responseText = xmlObj.responseText;
	xmlObj.Close;
	xmlObj = null; 
	
	document.getElementById(getelement).innerHTML = responseText;
	return true;
}

function add_smile(get_field , get_icon)
{
	 var FldObj = document.getElementById(get_field);
	 FldObj.value+=get_icon;
	 FldObj.focus();
}

function PrintPage(get_url)
{
	//alert(get_url);
	window.open(get_url,"_blank","height=600 , width=770");
}

function WriteAntispam(getId,msg)
{
	document.getElementById(getId).innerHTML = msg;
}
