
  // ----------------------------------------------------------------------------------------------------
  /**
  *  Name:     validateUrl()
  *  Function: The function is used to validate the url
  *  @param:   urlString - url string
  *  @return:  Boolean
  */
  // ----------------------------------------------------------------------------------------------------
  function validateUrl(urlString)
  {
    var urlregex = new RegExp("^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&amp;%\$#\=~])*$");
  
    if (urlregex.test(urlString))
    {
      return(true);
    }

    return(false);
  }

  // ----------------------------------------------------------------------------------------------------
  /**
  *  Name:     validateFileFormat()
  *  Function: The function is used validate file format type whether it is gif, jpg or png.
  *  @param:   fileName - file name
  *  @return:  Boolean
  */
  // ----------------------------------------------------------------------------------------------------
  function validateFileFormat(fileName)
  {
    var fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);
  
    if (fileExtension == "gif" || fileExtension == "GIF" || fileExtension == "JPEG" || fileExtension == "jpeg" || 
        fileExtension == "jpg" || fileExtension == "JPG" || fileExtension == "PNG" || fileExtension == "png")
    {
      return true;
    }
    else
    {
      return false;
    }
  }
  
  // ----------------------------------------------------------------------------------------------------
  /**
  *  Name:     validateRadio()
  *  Function: The function is used to check whether any option is selected or not for given radio button.
  *  @param:   htmlObject - radio button type html object
  *  @return:  Boolean
  */
  // ----------------------------------------------------------------------------------------------------
  function validateRadio(htmlObject)
  { 
    for (var i = 0; i < htmlObject.length; i++)
    {
  	  if (htmlObject[i].checked == true)
  	  {
  	    return true;
  	  }
    } 
    return false; 
  }

  // ----------------------------------------------------------------------------------------------------
  /**
  *  Name:     adRotatorTopLeft()
  *  Function: The function is used for ad rotator for top - left position. 
  *  @param:   None
  *  @return:  None
  */
  // ----------------------------------------------------------------------------------------------------
  function adRotatorTopLeft()
  {
    if (currentAdTopLeft == (totalImagesTopLeft - 1) )
    {
      currentAdTopLeft = 0;
    }
    else
    {
      currentAdTopLeft ++;
    }
    
    document.getElementById('adRotator_top_left').src = imageArrayTopLeft[currentAdTopLeft];
    document.getElementById('adRotator_top_left').alt = altArrayTopLeft[currentAdTopLeft];
    document.getElementById('adRotator_top_left').title = altArrayTopLeft[currentAdTopLeft];
    document.getElementById('adLink_top_left').href  = 'javascript:recordClick(' + adIdArrayTopLeft[currentAdTopLeft] + ',"' + urlArrayTopLeft[currentAdTopLeft] + '");';
    setTimeout(adRotatorTopLeft, 5000);
  }

  function recordClick(adId, adUrl) {
	var ajax = null;
	var url = "/record_click.php?adId="+adId;

	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer")

	{
	  ajax = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
	  ajax = new XMLHttpRequest();
	}
	if(!ajax) alert("Not ajax");
	ajax.open('get', url,'true'); 
	ajax.send(null);	
	if (adUrl && adUrl != ''&& adUrl != 'undefined')
	{
	  window.open(adUrl);
	}
  }
 
  // ----------------------------------------------------------------------------------------------------
  /**
  *  Name:     adRotatorTopRight()
  *  Function: The function is used for ad rotator for top - right position. 
  *  @param:   None
  *  @return:  None
  */
  // ----------------------------------------------------------------------------------------------------
  function adRotatorTopRight()
  {
    if (currentAdTopRight == (totalImagesTopRight - 1) )
    {
      currentAdTopRight = 0;
    }
    else
    {
      currentAdTopRight ++;
    }
    
    document.getElementById('adRotator_top_right').src = imageArrayTopRight[currentAdTopRight];
    document.getElementById('adRotator_top_right').alt = altArrayTopRight[currentAdTopRight];
    document.getElementById('adRotator_top_right').title = altArrayTopRight[currentAdTopRight];
    document.getElementById('adLink_top_right').href  = 'javascript:recordClick(' + adIdArrayTopRight[currentAdTopRight] + ',"' + urlArrayTopRight[currentAdTopRight] + '");';
    setTimeout(adRotatorTopRight, 5000);
  }
