/* function for opening popup window */
function openpopup(url,popup_name,height,width,other_properties)
{
	var left		= parseInt((screen.width-350)/2);
	var top			= parseInt((screen.height-300)/2)	
	var win_options = 'height=550,width=580,resizable=yes,' 
	+ 'scrollbars=yes,left=' + left + ',top=' + top;
	window.open(url,popup_name,win_options);

}

function simplePreload()

{
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

function showhidetab(spanid)
{
i=0;
	while(true)
	{
		var span_id = document.getElementById(spanid+i);
		if(!span_id)
			break;
		else
		{
			if (span_id.style.display != '') {
				span_id.style.display='';
			} else {
				span_id.style.display='none';
			}	
			i++;
		}	    
	}	
}


function checksearch(msg)
{
	var obj = document.getElementById('searchtxt');
	var txt = obj.value;
	if(txt == '')
	{
		alert(msg);
		obj.focus();
		return false;
	}
	else
	{
		window.location.href="/search.php?searchtxt="+txt;
	}
	return true;
}
/// Tool Tips

function IsInt(sText)
{
   var ValidChars = "0123456789";
   var IsInt=true;
   var Char;
   var sText1 = sText.value;

   for (i = 0; i < sText1.length && IsInt == true; i++) 
   { 
      Char = sText1.charAt (i ); 
      if (ValidChars.indexOf(Char) == -1) 
      {
		 IsInt = false;
      }
   }

   return IsInt;
}
function validateEmail(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    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 ChkNLSignUp(){
	
	if(document.getElementById('nl_email').value==''){
	
		alert('Please enter valid email address');
		document.getElementById('nl_email').focus();
		return false;
		
	}else if(!validateEmail(document.getElementById('nl_email').value)){

		alert('Please enter valid email address');
		document.getElementById('nl_email').focus();
		return false;
	}
	
	var queryStr = "nl_email="+document.getElementById('nl_email').value;
	
	jQuery(document).ready(function($) {
		jQuery.ajax({
				type:	'get',
				cache: 	false,
				url:	'/newsletter_signup.php',
			    data:	 queryStr ,
			    success: function(msg){
					if(msg != ''){
						document.getElementById('newsletter-foot').innerHTML = msg;
					}
				}
			});
		});						
	return true;
}
