function check_add_comment(frm)
{
	if(isNull(frm.gal_comment_content.value))
	{
		Sexy.alert("Please insert comments.");
		return false;
	}
}
function check_link_submit(frm)
{
	var error=false;
	var errormsg="Following error(s) found:";
	var email=frm.link_author_email.value;
	var url=frm.link_url.value;
	var validURL=isValidURL(url.trim());
	var br=new_line();
	if(isNull(frm.link_addedby.value))
	{
		errormsg+= br+"Please enter your name.";
		error=true;
	}
	if(isNull(email))
	{
		errormsg+= br+"Please enter your email-ID.";
		error=true;
	}
	if(!isNull(email) && (!email_check(email)))
	{
		errormsg+= br+"Please enter valid email-ID.";
		error=true;
	}
	if(isNull(url))
	{
		errormsg+= br+"Please enter URL.";
		error=true;
	}
	if(!isNull(url) && validURL!=true)
	{
		errormsg+= br+validURL;
		error=true;
	}
	if(isNull(frm.link_title.value))
	{
		errormsg+= br+"Please enter title.";
		error=true;
	}
	if(isNull(frm.link_description.value))
	{
		errormsg+= br+"Please enter your description.";
		error=true;
	}
	
	if(error)
	{
		Sexy.alert(errormsg);
		return false;
	}
	return true;
}
function new_line()
{
	return "<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}
// Change the value of the outputText field
      
	  function setBanner()
	  {
		 
		 if(httpObject.readyState == 4)
		  {
			  //alert(httpObject.responseText);
			  document.getElementById('banners').innerHTML = httpObject.responseText;
			  
		  }
      }
	 
	  // Implement business logic
      function set_banner_by_countries_id(search_countries_id, search_countries_name)
	  {
      	
		httpObject = getHTTPObject();
		if (httpObject != null) 
		{
			httpObject.open("GET", "ajaxindexconnection.php?set_banner=set_banner&search_countries_id="+search_countries_id, true);
			httpObject.send(null);
			httpObject.onreadystatechange = setBanner;
		}
     }
	 /////////
	 
	 

function showAdsense()
{
 
 if(httpObject.readyState == 4)
  {
	  //alert(httpObject.responseText);
	  document.getElementById('adsense').innerHTML = httpObject.responseText;
	  alert(document.getElementById('adsense').innerHTML);
	  
  }
}
// Implement business logic
function setAdsense(search_countries_id, search_countries_name)
{
	httpObject = getHTTPObject();
	if (httpObject != null) 
	{
		httpObject.open("GET", "ajaxindexconnection.php?set_adsense=set_adsense&search_countries_id="+search_countries_id, true);
		httpObject.send(null);
		httpObject.onreadystatechange = showAdsense;
	}
}
function setByCountryId(search_countries_id, search_countries_name)
{
	set_banner_by_countries_id(search_countries_id, search_countries_name);
	setAdsense(search_countries_id, search_countries_name);
}
function setJobTitle(jobTitle)
{
	document.getElementById('txttitle').value=jobTitle;
	document.formname_search.submit();
}
function increase_view(aff_banner_id)
{
	
	httpObject = getHTTPObject();
	if (httpObject != null) 
	{
		httpObject.open("GET", "include/ajaxindexconnection.php?increase_view=increase_view&aff_banner_id="+aff_banner_id, true);
		httpObject.send(null);
		//alert(aff_banner_id);
	}
}
function gotoSignUp(member_type)
{
	window.location.href='option.php?component=com_user&task=signup&member_type='+member_type;
}
function gotoCompare()
{
	window.location.href='option.php?component=com_cms&task=compare';
}

/**
////
	@function to add products to 
	@shopping cart
*/
function add_to_cart(frm)
{
	//alert(frm);
	/// getting values of form.
	var cart_item_qty=frm.cart_item_qty.value;
	var cart_item_id=frm.cart_item_id.value;
	
	var cart_item_type=frm.cart_item_type.value;
	var cart_item_min_qty=frm.cart_item_min_qty.value;
	var site_url=frm.site_url.value;
	
	var errormsg="";
	var error=false;
	var br='<br>';
	//alert(cart_item_id);
	if(isNaN(cart_item_qty))
	{
		errormsg+=br+"Please enter a valid value.";
		error=true;
	}
	if(cart_item_qty<cart_item_min_qty)
	{
		errormsg+=br+"Please enter atleast "+cart_item_min_qty+" Qty.";
		error=true;
	}
	if(cart_item_id<0)
	{
		errormsg+=br+"Sorry there is an error.";
		error=true;
	}
	if(error)
	{
		Sexy.alert(errormsg);
		return false;
	}
	else
	{
		document.getElementById('divProcess').style.display='block';
		document.getElementById('btn_add_to_cart').disabled=true;
		document.getElementById('btn_add_to_cart').value='Wait...';
		frm.cart_item_qty.value=cart_item_min_qty;
		
	}
	
	
	/// generating url
	var url=site_url+'include/ajaxindexconnection.php?add_to_cart=add_to_cart';
	url+='&cart_item_qty='+cart_item_qty+'';
	url+='&cart_item_id='+cart_item_id+''
	url+='&cart_item_type='+cart_item_type+'';
	url+='&cart_item_min_qty=';
	callAjax(frm.cart_item_min_qty, url, 'divProcess');
	
	// setting total products in shopping cart
	var url1=site_url+'include/ajaxindexconnection.php?get_total_cart_item=get_total_cart_item&cart_item_min_qty=';
	setInterval(function()
						 {
							 callAjax(frm.cart_item_min_qty, url1, 'spanTotalItem');
						 },2000
			 	);
	
	setTimeout("hide_error()", 4000);
	
}
function hide_error()
{
	if(document.getElementById('btn_add_to_cart'))
	{
		//document.getElementById('btn_add_to_cart').disabled=false;
		document.getElementById('btn_add_to_cart').value='Add to Cart';
	}
	if(document.getElementById('divProcess'))
	{
		document.getElementById('divProcess').style.display='none';
	}
}
function processing()
{
	document.getElementById('divProcessing').style.display='block';
	
}
function check_qty(obj, min_qty)
{
	//alert(id);
	var cart_products_qty=obj.value;
	if(isNaN(cart_products_qty) || parseInt(cart_products_qty)<parseInt(min_qty) || cart_products_qty=="" ||cart_products_qty==null || parseInt(cart_products_qty)<1 || cart_products_qty.indexOf(".")>0)
	{
		Sexy.alert("Invalid Qty.");
		obj.value=min_qty;
	}
}
function check_user_login(frm)
{
	var errormsg="";
	var error=false;
	var br="<br>";
	if(isNull(frm.member_login_id.value))
	{
		errormsg+=br+"Please enter your login ID";
		error=true;
	}
	var validMailId=isValidLoginId(frm.member_login_id.value);
	if(!isNull(frm.member_login_id.value) && validMailId!=true)
	{
		errormsg+=br+"Please enter a valid login ID";
		error=true;
	}
	if(isNull(frm.member_password.value))
	{
		errormsg+=br+"Please enter your password.";
		error=true;
	}
	var validPwd=isValidPassword(frm.member_password.value);
	if(!isNull(frm.member_password.value) && validPwd!=true)
	{
		errormsg+=br+validPwd;
		error=true;
	}
	if(error)
	{
		Sexy.alert(errormsg);
		return false;
	}
	return true;
}
function showTip()
{
	if(document.getElementById('showimage'))
	{
		document.getElementById('showimage').style.display='block';
	}
}
function dateTime()
{
	
	var currentDate = new Date()
	var day = currentDate.getDate()
	var month = currentDate.getMonth()
	var year = currentDate.getFullYear()
	var fullDate="<b>" + day + "/" + month + "/" + year + "</b>";

	
	
	// time
	var currentTime = new Date()
	var hours = currentTime.getHours()
	var minutes = currentTime.getMinutes()
	
	var suffix = "AM";
	if (hours >= 12) {
	suffix = "PM";
	hours = hours - 12;
	}
	if (hours == 0) {
	hours = 12;
	}
	
	if (minutes < 10)
	minutes = "0" + minutes
	
	var fullTime="<b>" + hours + ":" + minutes + " " + suffix + "</b>";
	
	document.write(fullDate+" "+fullTime);

}
