function bookmark_url(url, description)
{
netscape="Please Hit CTRL+D to add a bookmark to this site."
if (navigator.appName=='Microsoft Internet Explorer')
{
window.external.AddFavorite(url, description);
}
else if (navigator.appName=='Netscape')
{
alert(netscape);
}
}

function validateconsign()
{
	if (document.con_sign_form.cnt_name.value == "")
	{
		alert("Please enter your Name");
		document.con_sign_form.cnt_name.focus();
		return false;
	}
	if (document.con_sign_form.email.value == "")
	{
		alert("Please enter your Email Address");
		document.con_sign_form.email.focus();
		return false;
	}	
	var res = checkbae("con_sign_form","email");
	if (res == true)
	{
		if (document.con_sign_form.user.value == "")
		{
			alert("Please enter the user ID");
			document.con_sign_form.user.focus();
			return false;
		}
		if (document.con_sign_form.pass.value == "")
		{
			alert("Please enter the Password");
			document.con_sign_form.pass.focus();
			return false;
		}
		if (document.con_sign_form.security_code.value == "")
		{
			alert("Please enter the Security Code");
			document.con_sign_form.security_code.focus();
			return false;
		}	
		return true;	
	}
	else
	{
		return false;
	}

}


var testresults
function checkemail(formname,inputname){

var a="document.";
var b=".value";
var str = eval(a+formname+"."+inputname+b);
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
alert("Please enter a valid email address!")
eval(a+formname+"."+inputname+".focus()");
testresults=false
}
return (testresults)
}

function checkbae(formname,inputname){
if (document.layers||document.getElementById||document.all)
return checkemail(formname,inputname)
else
return true
}


function validatebusisign()
{
	if (document.busi_sign_form.cnt_name.value == "")
	{
		alert("Please enter your Name");
		document.busi_sign_form.cnt_name.focus();
		return false;
	}
	if (document.busi_sign_form.email.value == "")
	{
		alert("Please enter your Email Address");
		document.busi_sign_form.email.focus();
		return false;
	}	
	var res = checkbae("busi_sign_form","email");
	if (res == true)
	{

		if (document.busi_sign_form.cmp_name.value == "")
		{
			alert("Please enter the Company Name");
			document.busi_sign_form.cmp_name.focus();
			return false;
		}		
		if (document.busi_sign_form.cmp_city.value == "")
		{
			alert("Please enter the City");
			document.busi_sign_form.cmp_city.focus();
			return false;
		}				
		if (document.busi_sign_form.cmp_state.value == "")
		{
			alert("Please enter the State");
			document.busi_sign_form.cmp_state.focus();
			return false;
		}				
		if (document.busi_sign_form.cmp_zipcode.value == "")
		{
			alert("Please enter the Zipcode");
			document.busi_sign_form.cmp_zipcode.focus();
			return false;
		}				
		if (document.busi_sign_form.user.value == "")
		{
			alert("Please enter the user ID");
			document.busi_sign_form.user.focus();
			return false;
		}
		if (document.busi_sign_form.pass.value == "")
		{
			alert("Please enter the Password");
			document.busi_sign_form.pass.focus();
			return false;
		}
		if (document.busi_sign_form.security_code.value == "")
		{
			alert("Please enter the Security Code");
			document.busi_sign_form.security_code.focus();
			return false;
		}	
		return true;	
	}
	else
	{
		return false;
	}

}


function validateconlogin()
{
	if (document.con_login_form.user.value == "")
	{
		alert("Please enter a User ID");
		document.con_login_form.user.focus();
		return false;
	}
	if (document.con_login_form.pass.value == "")
	{
		alert("Please enter the password");
		document.con_login_form.pass.focus();
		return false;
	}	
	return true;
}

function validatebusilogin()
{
	if (document.busi_login_form.user.value == "")
	{
		alert("Please enter a User ID");
		document.busi_login_form.user.focus();
		return false;
	}
	if (document.busi_login_form.pass.value == "")
	{
		alert("Please enter the password");
		document.busi_login_form.pass.focus();
		return false;
	}	
	return true;
}


function validatecontact()
{
	if (document.contact_form.cnt_name.value == "")
	{
		alert("Please enter your Name");
		document.contact_form.cnt_name.focus();
		return false;
	}
	if (document.contact_form.cnt_email.value == "")
	{
		alert("Please enter your Email Address");
		document.contact_form.cnt_email.focus();
		return false;
	}	
	var res = checkbae("contact_form","cnt_email");
	if (res == true)
	{
		if (document.contact_form.cnt_query.value == "")
		{
			alert("Please enter the contact Query");
			document.contact_form.cnt_query.focus();
			return false;
		}
		if (document.contact_form.security_code.value == "")
		{
			alert("Please enter the Security Code");
			document.contact_form.security_code.focus();
			return false;
		}	
		return true;	
	}
	else
	{
		return false;
	}

}


function validatecate()
{
	if (document.add_cateform.catname.value == "")
	{
		alert("Please enter a Category Name");
		document.add_cateform.catname.focus();
		return false;
	}
	if (document.add_cateform.catname.value != "")
	{
		var catename = document.add_cateform.catname.value;
		var len = catename.length;
		if (len > 50)
		{
			alert('Please enter a category with less than 50 characters');
			document.add_cateform.catname.focus();
			return false;
		}
	}
	return true;	
}

function validateecate()
{
	if (document.edit_cateform.edit_catname.value == "")
	{
		alert("Please enter a Category Name");
		document.edit_cateform.edit_catname.focus();
		return false;
	}
	if (document.edit_cateform.edit_catname.value != "")
	{
		var catename = document.edit_cateform.edit_catname.value;
		var len = catename.length;
		if (len > 50)
		{
			alert('Please enter a category with less than 50 characters');
			document.edit_cateform.edit_catname.focus();
			return false;
		}
	}
	return true;	
}


function delcate(cid)
{
	var confirmation = confirm("Are you sure you want to delete this Category?\nThis category can be deleted only if there are no coupons under this category.\nAll banners under this category will also get deleted.");
	if (confirmation == true)
	{
		var resdiv = document.getElementById('res');
		if(resdiv.style.display == 'none')
		{
			resdiv.style.display = 'block';
		}		
		var pars = "cid="+cid;
		var refreshurl = 'admin_categories.php';
		var myAjax = new Ajax.Updater( resdiv, 'admin_cat_del.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});	
	}
	else
	{
	}
}


function validatecateim()
{
	if (document.add_catemform.catmname.value == "")
	{
		alert("Please enter a Category Name");
		document.add_catemform.catmname.focus();
		return false;
	}
	if (document.add_catemform.catmname.value != "")
	{
		var catename = document.add_catemform.catmname.value;
		var len = catename.length;
		if (len > 50)
		{
			alert('Please enter a category with less than 50 characters');
			document.add_catemform.catmname.focus();
			return false;
		}
	}
	return true;	
}

function validateecateim()
{
	if (document.edit_catemform.edit_catmname.value == "")
	{
		alert("Please enter a Category Name");
		document.edit_catemform.edit_catmname.focus();
		return false;
	}
	if (document.edit_catemform.edit_catmname.value != "")
	{
		var catename = document.edit_catemform.edit_catmname.value;
		var len = catename.length;
		if (len > 50)
		{
			alert('Please enter a category with less than 50 characters');
			document.edit_catemform.edit_catmname.focus();
			return false;
		}
	}
	return true;	
}


function delcatem(cmid)
{
	var confirmation = confirm("Are you sure you want to delete this Category?\nThis category can be deleted only if there are no images under this category.");
	if (confirmation == true)
	{
		var resdiv = document.getElementById('res');
		if(resdiv.style.display == 'none')
		{
			resdiv.style.display = 'block';
		}		
		var pars = "cmid="+cmid;
		var refreshurl = 'admin_categoriesim.php';
		var myAjax = new Ajax.Updater( resdiv, 'admin_catm_del.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});	
	}
	else
	{
	}
}

function refreshpage(refreshurl)
{
	window.location.href=refreshurl;
}

function diffuseres(divId)
{
new Effect.Fade(divId, {duration: 5});
}

function select_catgoto()
{
	var cmid = document.selcatform.selcat.options[document.selcatform.selcat.selectedIndex].value;
	window.location.href = 'admin_cate_images.php?cmid='+cmid;
}

function validatecateimg()
{
	if (document.add_catimgform.cmid.options[document.add_catimgform.cmid.selectedIndex].value == 0)
	{
		alert("Please select a category and then submit");
		document.add_catimgform.cmid.focus();
		return false;
	}
	if (document.add_catimgform.catimg.value == "")
	{
		alert("Please select an image and then submit");
		document.add_catimgform.catimg.focus();
		return false;
	}
	return true;
}

function delcatimg(cimg_id,cmid,p)
{
	var confirmation = confirm("Are you sure you want to delete this Category Image?\nThis category Image can be deleted only if no coupons uses this image.");
	if (confirmation == true)
	{
		var resdiv = document.getElementById('res');
		if(resdiv.style.display == 'none')
		{
			resdiv.style.display = 'block';
		}		
		var pars = "cimgid="+cimg_id;
		var refreshurl = 'admin_cate_images.php?cmid='+cmid+'&p='+p;
		var myAjax = new Ajax.Updater( resdiv, 'admin_cat_img_del.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});	
	}
	else
	{
	}
}

function validatetemp()
{
	if (document.add_tempform.tempimg.value == "")
	{
		alert("Please select an image and then submit");
		document.add_tempform.tempimg.focus();
		return false;
	}
	if (document.add_tempform.pos_text_t.value == "")
	{
		alert("Please enter the top position of text to appear on template bg");
		document.add_tempform.pos_text_t.focus();
		return false;
	}	
	if (document.add_tempform.pos_text_l.value == "")
	{
		alert("Please enter the left position of text to appear on template bg");
		document.add_tempform.pos_text_l.focus();
		return false;
	}	
	if (document.add_tempform.pos_img_t.value == "")
	{
		alert("Please enter the top position of image to appear on template bg");
		document.add_tempform.pos_img_t.focus();
		return false;
	}	
	if (document.add_tempform.pos_img_l.value == "")
	{
		alert("Please enter the left position of image to appear on template bg");
		document.add_tempform.pos_img_l.focus();
		return false;
	}	
	if (document.add_tempform.pos_logo_t.value == "")
	{
		alert("Please enter the top position of logo to appear on template bg");
		document.add_tempform.pos_logo_t.focus();
		return false;
	}	
	if (document.add_tempform.pos_logo_l.value == "")
	{
		alert("Please enter the left position of logo to appear on template bg");
		document.add_tempform.pos_logo_l.focus();
		return false;
	}			
	return true;
}

function validateedittemp()
{
	if (document.edit_tempform.pos_text_t.value == "")
	{
		alert("Please enter the top position of text to appear on template bg");
		document.edit_tempform.pos_text_t.focus();
		return false;
	}	
	if (document.edit_tempform.pos_text_l.value == "")
	{
		alert("Please enter the left position of text to appear on template bg");
		document.edit_tempform.pos_text_l.focus();
		return false;
	}	
	if (document.edit_tempform.pos_img_t.value == "")
	{
		alert("Please enter the top position of image to appear on template bg");
		document.edit_tempform.pos_img_t.focus();
		return false;
	}	
	if (document.edit_tempform.pos_img_l.value == "")
	{
		alert("Please enter the left position of image to appear on template bg");
		document.edit_tempform.pos_img_l.focus();
		return false;
	}		
	if (document.edit_tempform.pos_logo_t.value == "")
	{
		alert("Please enter the top position of logo to appear on template bg");
		document.edit_tempform.pos_logo_t.focus();
		return false;
	}	
	if (document.edit_tempform.pos_logo_l.value == "")
	{
		alert("Please enter the left position of logo to appear on template bg");
		document.edit_tempform.pos_logo_l.focus();
		return false;
	}			
	return true;
}

function deltemp(tid,p)
{
	var confirmation = confirm("Are you sure you want to delete this Template?\nThis template can be deleted only if no coupons uses this image.");
	if (confirmation == true)
	{
		var resdiv = document.getElementById('res');
		if(resdiv.style.display == 'none')
		{
			resdiv.style.display = 'block';
		}		
		var pars = "tid="+tid;
		var refreshurl = 'admin_templates.php?p='+p;
		var myAjax = new Ajax.Updater( resdiv, 'admin_temp_del.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});	
	}
	else
	{
	}
}

function validatecoupimg()
{
	if (document.addcouponform.coup_title.value == "")
	{
		alert("Please enter the Coupon Title");
		document.addcouponform.coup_title.focus();
		return false;
	}	
	if (document.addcouponform.coup_desc.value == "")
	{
		alert("Please enter the Coupon Description");
		document.addcouponform.coup_desc.focus();
		return false;
	}	
	if (document.addcouponform.cat_id.options[document.addcouponform.cat_id.selectedIndex].value == "")
	{
		alert("Please select a Category");
		document.addcouponform.cat_id.focus();
		return false;
	}		
	if (document.addcouponform.exp_date.value == "YYYY-MM-DD")
	{
		alert("Please enter an expiry Date");
		document.addcouponform.exp_date.focus();
		return false;
	}	
	if (document.addcouponform.coup_img.value == "")
	{
		alert("Please upload an image");
		document.addcouponform.coup_img.focus();
		return false;
	}		
	return true;
}

function showcatimg(cmid)
{
	var resdiv = document.getElementById('catdiv');
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}		
//	alert(cid);
	var pars = "cmid="+cmid;
	var myAjax = new Ajax.Updater( resdiv, 'busi_cat_image.php', { method: 'get', parameters: pars });
}

function showcatimg_exist(cimgid)
{
	var resdiv = document.getElementById('catdiv');
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}		
//	alert(cid);
	var pars = "cimgid="+cimgid;
	var myAjax = new Ajax.Updater( resdiv, 'busi_cat_image_exist.php', { method: 'get', parameters: pars });
}

function showtemplate(tid)
{
Dialog.alert({url: "show_template.php?tid="+tid, options: {method: 'get'}}, {className: "alphacube", width:750, height:380, okLabel: "Close"});
}

function showpreview(page)
{
	var temp_exist = document.getElementById('temp_id');
//	alert(temp_exist);
	if (temp_exist == undefined || temp_exist == null)
	{
		alert("Unable to Create Coupon. No templates Found");
	}
	else
	{
		var temp_val = "";
		var temp_len = document.coupongalform.temp_id.length;
//		alert(temp_len);
		if (temp_len == undefined)
		{
			if (document.coupongalform.temp_id.checked)
			{
				var temp_val = document.coupongalform.temp_id.value;
			}		
		}
		else
		{
			for (var i=0; i < temp_len; i++)
			{
				if (document.coupongalform.temp_id[i].checked)
				{
					var temp_val = document.coupongalform.temp_id[i].value;
				}
			}
		}

		if (temp_val == "")
		{
			alert("Please select a Template");
		}
		else
		{


			var cimg_exist = document.getElementById('catimg');
//			alert(cimg_exist);
			if (cimg_exist == undefined || cimg_exist == null)
			{
				alert("Unable to Create Coupon. No Images Found");
			}
			else
			{
				var cimg_val = "";
				var cimg_len = document.coupongalform.catimg.length;
//				alert(cimg_len);
				if (cimg_len == undefined)
				{
					if (document.coupongalform.catimg.checked)
					{
						var cimg_val = document.coupongalform.catimg.value;
					}		
				}
				else
				{
					for (var i=0; i < cimg_len; i++)
					{
						if (document.coupongalform.catimg[i].checked)
						{
							var cimg_val = document.coupongalform.catimg[i].value;
						}
					}
				}

				if (cimg_val == "")
				{
					alert("Please select an Image");
				}
				else
				{
					if (document.coupongalform.coup_text.value == "")
					{
						alert("Please enter Coupon Text");
						document.coupongalform.coup_text.focus();
					}
					else
					{
						var ctext = document.coupongalform.coup_text.value;						
						if (page == 'admin')
						{
							if (document.coupongalform.busi_accnt.value == "")
							{
								alert("Please enter a Business Account Name");
								document.coupongalform.busi_accnt.focus();
							}
							else
							{
								var bname = document.coupongalform.busi_accnt.value;
								Dialog.alert({url: "show_template_preview.php?tid="+temp_val+"&cimg="+cimg_val+"&bname="+bname+"&text="+ctext, options: {method: 'get'}}, {className: "alphacube", width:750, height:380, okLabel: "Close"});
							}
						}
						else
						{
							Dialog.alert({url: "show_template_preview.php?tid="+temp_val+"&cimg="+cimg_val+"&text="+ctext, options: {method: 'get'}}, {className: "alphacube", width:750, height:380, okLabel: "Close"});
						}
					}
				}
			}

		}
	}	
}


function validatecoupgalimg()
{
	if (document.coupongalform.coup_title.value == "")
	{
		alert("Please enter a Coupon title");
		document.coupongalform.coup_title.focus();
		return false;
	}
	if (document.coupongalform.coup_desc.value == "")
	{
		alert("Please enter a Coupon Description");
		document.coupongalform.coup_desc.focus();
		return false;
	}
	if (document.coupongalform.cat_id.options[document.coupongalform.cat_id.selectedIndex].value == "")
	{
		alert("Please enter a Category");
		document.coupongalform.cat_id.focus();
		return false;
	}	
	if (document.coupongalform.exp_date.value == "YYYY-MM-DD")
	{
		alert("Please enter an Expiry Date");
		document.coupongalform.exp_date.focus();
		return false;
	}
	var temp_exist = document.getElementById('temp_id');
	if (temp_exist == undefined || temp_exist == null)
	{
		alert("Unable to Create Coupon. No templates Found");
		return false;
	}
	else
	{
		var temp_val = "";
		var temp_len = document.coupongalform.temp_id.length;
		if (temp_len == undefined)
		{
			if (document.coupongalform.temp_id.checked)
			{
				var temp_val = document.coupongalform.temp_id.value;
			}		
		}
		else
		{
			for (var i=0; i < temp_len; i++)
			{
				if (document.coupongalform.temp_id[i].checked)
				{
					var temp_val = document.coupongalform.temp_id[i].value;
				}
			}
		}

		if (temp_val == "")
		{
			alert("Please select a Template");
			return false;
		}
	}

	var cimg_exist = document.getElementById('catimg');
	if (cimg_exist == undefined || cimg_exist == null)
	{
		alert("Unable to Create Coupon. No Images Found");
		return false;
	}
	else
	{
		var cimg_val = "";
		var cimg_len = document.coupongalform.catimg.length;
		if (cimg_len == undefined)
		{
			if (document.coupongalform.catimg.checked)
			{
				var cimg_val = document.coupongalform.catimg.value;
			}		
		}
		else
		{
			for (var i=0; i < cimg_len; i++)
			{
				if (document.coupongalform.catimg[i].checked)
				{
					var cimg_val = document.coupongalform.catimg[i].value;
				}
			}
		}
		if (cimg_val == "")
		{
			alert("Please select an Image");
			return false;
		}
	}
	
	if (document.coupongalform.coup_text.value == "")
	{
		alert("Please enter Coupon Text");
		document.coupongalform.coup_text.focus();
		return false;
	}

	return true;
}

function showcoupon(coupid)
{
	Dialog.alert({url: "show_coupon.php?coupid="+coupid, options: {method: 'get'}}, {className: "alphacube", width:750, height:380, okLabel: "Close"});
}

function showtou()
{
	Dialog.alert({url: "tou.html", options: {method: 'get'}}, {className: "alphacube", width:750, height:380, okLabel: "Close"});
}

function showpp()
{
	Dialog.alert({url: "pp.html", options: {method: 'get'}}, {className: "alphacube", width:750, height:380, okLabel: "Close"});
}

function showcopy()
{
	Dialog.alert({url: "copyright.html", options: {method: 'get'}}, {className: "alphacube", width:750, height:380, okLabel: "Close"});
}

function delcoupon(cid,p,page,from)
{
	var confirmation = confirm("Are you sure you want to delete this Coupon?");
	if (confirmation == true)
	{
		var resdiv = document.getElementById('res');
		if(resdiv.style.display == 'none')
		{
			resdiv.style.display = 'block';
		}		
		var pars = "coupid="+cid;
		if (page == 'admin')
		{
			var refreshurl = 'admin_coupons.php?p='+p;
		}
		if (page == 'self')
		{
			if (from == 'admin')
			{
			var refreshurl = 'mem_index.php?p='+p+'&from=admin';				
			}
			else
			{
			var refreshurl = 'mem_index.php?p='+p;
			}
		}
		var myAjax = new Ajax.Updater( resdiv, 'busi_coup_del.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});	
	}
	else
	{
	}
}

function delcoupon_admin(cid,p,pageext)
{
	var confirmation = confirm("Are you sure you want to delete this Coupon?");
	if (confirmation == true)
	{
		var resdiv = document.getElementById('res');
		if(resdiv.style.display == 'none')
		{
			resdiv.style.display = 'block';
		}		
		var pars = "coupid="+cid;
		var refreshurl = 'admin_coupons_bymem.php?p='+p+'&'+pageext;
		var myAjax = new Ajax.Updater( resdiv, 'busi_coup_del.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});	
	}
	else
	{
	}
}


function showappdiv()
{
	var ctype = document.coupongalform.coup_type.options[document.coupongalform.coup_type.selectedIndex].value;
	if (ctype == 'image')
	{
		document.getElementById('imgdiv').style.display = 'block';
		document.getElementById('tempdiv').style.display = 'none';		
	}
	if (ctype == 'template')
	{
		document.getElementById('tempdiv').style.display = 'block';				
		document.getElementById('imgdiv').style.display = 'none';
	}	
}

function validatecoupedit()
{

	if (document.coupongalform.coup_title.value == "")
	{
		alert("Please enter a Coupon title");
		document.coupongalform.coup_title.focus();
		return false;
	}
	if (document.coupongalform.coup_desc.value == "")
	{
		alert("Please enter a Coupon Description");
		document.coupongalform.coup_desc.focus();
		return false;
	}
	if (document.coupongalform.cat_id.options[document.coupongalform.cat_id.selectedIndex].value == "")
	{
		alert("Please enter a Category");
		document.coupongalform.cat_id.focus();
		return false;
	}	
	if (document.coupongalform.exp_date.value == "YYYY-MM-DD")
	{
		alert("Please enter an Expiry Date");
		document.coupongalform.exp_date.focus();
		return false;
	}
	var ctype = document.coupongalform.coup_type.options[document.coupongalform.coup_type.selectedIndex].value;
	if (ctype == 'template')
	{


	var temp_exist = document.getElementById('temp_id');
	if (temp_exist == undefined || temp_exist == null)
	{
		alert("Unable to Create Coupon. No templates Found");
		return false;
	}
	else
	{
		var temp_val = "";
		var temp_len = document.coupongalform.temp_id.length;
		if (temp_len == undefined)
		{
			if (document.coupongalform.temp_id.checked)
			{
				var temp_val = document.coupongalform.temp_id.value;
			}		
		}
		else
		{
			for (var i=0; i < temp_len; i++)
			{
				if (document.coupongalform.temp_id[i].checked)
				{
					var temp_val = document.coupongalform.temp_id[i].value;
				}
			}
		}

		if (temp_val == "")
		{
			alert("Please select a Template");
			return false;
		}
	}

	var cimg_exist = document.getElementById('catimg');
	if (cimg_exist == undefined || cimg_exist == null)
	{
		alert("Unable to Create Coupon. No Images Found");
		return false;
	}
	else
	{
		var cimg_val = "";
		var cimg_len = document.coupongalform.catimg.length;
		if (cimg_len == undefined)
		{
			if (document.coupongalform.catimg.checked)
			{
				var cimg_val = document.coupongalform.catimg.value;
			}		
		}
		else
		{
			for (var i=0; i < cimg_len; i++)
			{
				if (document.coupongalform.catimg[i].checked)
				{
					var cimg_val = document.coupongalform.catimg[i].value;
				}
			}
		}
		if (cimg_val == "")
		{
			alert("Please select an Image");
			return false;
		}
	}
	
	if (document.coupongalform.coup_text.value == "")
	{
		alert("Please enter Coupon Text");
		document.coupongalform.coup_text.focus();
		return false;
	}






	}
	return true;
}

function validatesearch()
{
	if (document.searchform.coup_title.value == "" || document.searchform.coup_title.value == "Enter Text")
	{
		alert("Please enter a Coupon Title to Search");
		document.searchform.coup_title.focus();
		return false;
	}
	return true;
}

function validateadvsearch()
{
	if (document.advsearchform.coup_title.value == "" && document.advsearchform.cid.options[document.advsearchform.cid.selectedIndex].value == "" && document.advsearchform.comp_name.value == "" && document.advsearchform.exp_date.value == "YYYY-MM-DD" && document.advsearchform.comp_city.value == "" && document.advsearchform.comp_state.value == "" && document.advsearchform.comp_zip.value == "")
	{
		alert("Please enter a some details to Search");
		return false;
	}
	return true;
}

function addtocart(coupon_id)
{
	var resdivID = "resdiv"+coupon_id;
	var resdiv = document.getElementById(resdivID);
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}		
	var pars = "coupid="+coupon_id;
	var myAjax = new Ajax.Updater( resdiv, 'coup_addtocart.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv);}});
}

function removefromcart(coupon_id)
{
	var resdiv = document.getElementById('res');
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}		
	var pars = "coupid="+coupon_id;
	var refreshurl = 'mycart.php';
	var myAjax = new Ajax.Updater( resdiv, 'coup_remfromcart.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});
}

function bookmark(coupon_id)
{
	var resdivId = "resdiv"+coupon_id;
	var resdiv = document.getElementById(resdivId);
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}		
	var pars = "coupid="+coupon_id;
	var myAjax = new Ajax.Updater( resdiv, 'coup_bookmark.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv);}});
}

function rembookmark(bm_id)
{
	var confirmation = confirm("Are you sure you want to remove this bookmark?");
	if (confirmation == true)
	{
		var resdivId = "resdivbm"+bm_id;
		var resdiv = document.getElementById(resdivId);
		if(resdiv.style.display == 'none')
		{
			resdiv.style.display = 'block';
		}		
		var pars = "bmid="+bm_id;
		var refreshurl = 'mybookmarks.php';
		var myAjax = new Ajax.Updater( resdiv, 'coup_rembookmark.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});
	}
	else
	{
	}
}

function rateme(coupid,rate)
{
	var resdivId = "resdiv"+coupid;
	var resdiv = document.getElementById(resdivId);
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}		
	var pars = "coupid="+coupid+"&rate="+rate;
	var myAjax = new Ajax.Updater( resdiv, 'coup_rateme.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); updateratediv(coupid);}});
}

function updateratediv(coupid)
{
	var ratedivId = "ratediv"+coupid;
	var ratediv = document.getElementById(ratedivId);
	if(ratediv.style.display == 'none')
	{
		ratediv.style.display = 'block';
	}		
	var pars = "coupid="+coupid;
	var myAjax = new Ajax.Updater( ratediv, 'coup_rate.php', { method: 'get', parameters: pars});
}

function addtoplist(comp_username,p)
{
	var resdiv = document.getElementById('res');
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}		
	var pars = "cusername="+comp_username;
	var refreshurl = 'admin_add_topmerch.php?p='+p;
	var myAjax = new Ajax.Updater( resdiv, 'admin_addtm.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});
}

function addtoplist_sear(comp_username,p,compname)
{
	var resdiv = document.getElementById('res');
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}		
	var pars = "cusername="+comp_username;
	var refreshurl = 'admin_add_topmerch.php?p='+p+'&compname='+compname+'&search=1';
	var myAjax = new Ajax.Updater( resdiv, 'admin_addtm.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});
}

function remtoplist(tid)
{
	var confirmation = confirm("Are you sure you want to delete this From top list?");
	if (confirmation == true)
	{
		var resdiv = document.getElementById('res');
		if(resdiv.style.display == 'none')
		{
			resdiv.style.display = 'block';
		}		
		var pars = "tid="+tid;
		var refreshurl = 'admin_topmerch.php';
		var myAjax = new Ajax.Updater( resdiv, 'admin_remtm.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});
	}
	else
	{
	}
}

function gotopage(url)
{
	var cid = document.selcatform.cid.options[document.selcatform.cid.selectedIndex].value;
	window.location.href = url+'?cid='+cid;
}

function addtobanner(coupon_id,cid,p)
{
	var resdiv = document.getElementById('res');
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}		
	var pars = "coup_id="+coupon_id+"&cid="+cid;
	var refreshurl = 'admin_add_banners.php?cid='+cid+'&p='+p;
	var myAjax = new Ajax.Updater( resdiv, 'admin_addbanner.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});
}

function remfrombanner(cban_id,cid)
{
	var confirmation = confirm("Are you sure you want to delete this From banner list?");
	if (confirmation == true)
	{
		var resdiv = document.getElementById('res');
		if(resdiv.style.display == 'none')
		{
			resdiv.style.display = 'block';
		}		
		var pars = "cbanid="+cban_id;
		var refreshurl = 'admin_banners.php?cid='+cid;
		var myAjax = new Ajax.Updater( resdiv, 'admin_rembanner.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});
	}
	else
	{
	}	
}

function validatebulk()
{
tinyMCE.triggerSave();
	if (document.bulkmail.subject.value == "")
	{
		alert("Please enter a subject line");
		document.bulkmail.subject.focus();
		return false;
	}
	if (tinyMCE.getContent() == "" || tinyMCE.getContent() == null)
	{
		alert("Please enter the message");
		document.bulkmail.message.focus();
		return false;
	}
	if (document.bulkmail.from.value == "")
	{
		alert("Please enter the from id");
		document.bulkmail.from.focus();
		return false;
	}
	if (document.bulkmail.from.value != "")
	{
		return checkbae("bulkmail","from");
	}
}

function gotopagemem(url)
{
	var ul = document.selulform.ul.options[document.selulform.ul.selectedIndex].value;
	if (ul == "" || ul == "0")
	{
	}
	else
	{
		window.location.href=url+"?ul="+ul;
	}
}

function admin_chkactstatus(mem_username,ul,p)
{
	var resdiv = document.getElementById('res');
	if(resdiv.style.display == 'none')
	{
		resdiv.style.display = 'block';
	}		
	var pars = "uname="+mem_username;
	var refreshurl = 'admin_members.php?ul='+ul+'&p='+p;
	var myAjax = new Ajax.Updater( resdiv, 'admin_chkactstatus.php', { method: 'get', parameters: pars, onComplete:function(){diffuseres(resdiv); refreshpage(refreshurl);}});
}

function showdiv(subdivid)
{
	document.getElementById(subdivid).style.display = 'block';
}
