var pop1_opened = false;
var pop1;
function popup(text,title)
{
	if(pop1_opened)
	{
		pop1.close();
	}
	pop1=window.open('','pop','width=250,height=250,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes');
	pop1_opened=true;
	html ='<html>';
	html+='	<header>';
	html+='		<title>'+title+'</title>';
	html+='	</header>';
	html+='	<body>';
	html+='		<div>'+text+'</div>';
	html+='<br/>';
	html+='		<div align="center"><a href="javascript:;" onClick="opener.pop1_opened=false;window.close()">close</a></div>';
	html+='	</body>';
	html+='</html>';
	pop1.document.write(html);
}

function popupPic(picURL)
{ 
	window.open( "scripts/pop.htm?"+picURL, "","scrollbars=yes, resizable=0, status=0,left=0, top=0,HEIGHT=200,WIDTH=200"); 				
}

function searchSwitch(obj, e, title)
{
	if(e=='focus')
	{
		if(obj.value == title)
		{
			obj.value = '';								
		}
	}
	else
	{
		if(obj.value == '')
		{
			obj.value = title;								
		}		
	}		
}	

function on_search(formObj, elmId, title)
{
	var f=formObj;
	var val=document.getElementById(elmId).value;
	if(trim(val) == '' || val == title)
		return false;	
	var url=f.action+val+'/';
	window.location=url;
	return false;
}

function do_search()
{		
	document.getElementById('search_submit').click();
}

function subscribeSwitch(obj, e, title)
{
	if(e=='focus')
	{
		if(obj.value == title)
		{
			obj.value = '';								
		}
	}
	else
	{
		if(obj.value == '')
		{
			obj.value = title;								
		}		
	}		
}

function do_subscribe()
{		
	document.getElementById('subscribe_submit').click();
}

function on_subscribe(elmId, lang, title)
{
	var val = document.getElementById(elmId).value;	
	if(trim(val) == '' || val == title)
	{
		return false;
	}
	
	var url = '?/'+lang+'/subscribe/add/' +  trim(val);	
	window.open(url , '', 'directories=no, height=180, width=350, left=200, top=200, location=no, menubar=no, resize=no, scrollbars=no, status=no, toolbar=no');	
	
	return false;
}

function trim(inputString)
{   
   if (typeof inputString != "string") return inputString;
   var retValue = inputString;
   var ch = retValue.substring(0, 1);	
   while (ch == " ") { 
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length - 1, retValue.length);
	
   while (ch == " ") { 
      retValue = retValue.substring(0, retValue.length - 1);
      ch = retValue.substring(retValue.length - 1, retValue.length);
   }
	
   while (retValue.indexOf("  ") != -1) {
	  retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ") + 1, retValue.length);
   }
   return retValue; 
}
/*  checks the validity of an email address entered 
	*   returns true or false 
	*/ 
function validateEmail(email)
{
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
	return false;
}

function TestInputType(objValue,strRegExp)
{
	var ret = false;
	//alert("1");
	
	var charpos = objValue.search(strRegExp); 
	if(objValue.length > 0 &&  charpos >= 0) 
	{
		//alert("1");
		ret = true; 
	}
	return ret;
}
function addFavorite()
{
	if(document.all) 
		window.external.AddFavorite(document.location.href,document.title);
}
