

	function showHideDeals(list,detail) {
		if (document.getElementById(list).style.display == 'none') {
	    	document.getElementById(list).style.display = '';
			document.getElementById(detail).style.display = 'none';
	  	}
	  	else{
			document.getElementById(detail).style.display = '';	
	    	document.getElementById(list).style.display = 'none';
	  	}
	}

	function dealsdummy() {
		return ;
	}
	
	// Show Comment block javascript 
	function showComment(val) {
		id = "comment"+val;
		if( document.getElementById(id).style.display == '' )
			document.getElementById(id).style.display = 'none';
		else	
			document.getElementById(id).style.display = '';
	}
	
	
	function funDayDeal(val) {
		//alert('deal id-'+val);
		document.fdeal.deal_day.value=val;
		document.fdeal.submit();
	}	
	
	function commProgress() {
	 	document.getElementById('pr'+progressVal).style.display = '';
	}
	
	function commResetProgress(val) {
	  	document.getElementById('pr'+progressVal).style.display = 'none';
	}

	var req;
	var progressVal = '';
	function funsendcomment(val){
		progressVal = '';
		var comment = document.getElementById("com"+val).value;
		if( comment == '' ) {
			alert('Please enter your Comment/Suggestion');
			document.getElementById("com"+val).focus();
			return;
		}
		progressVal = val;
		commProgress();
		var url = "comment.view?deals_id="+val+"&comment="+comment;
		funProcessAjex(url);
	}
		
	function funProcessAjex(url) {
	   	if (window.XMLHttpRequest) { // Non-IE browsers
      		req = new XMLHttpRequest();
		    req.onreadystatechange = getResponseState;
      		try {
		        req.open("GET", url, true);
      		} 
      		catch (e) {
      			commResetProgress();
		        alert(e);
      		}
		    req.send(null);
	    } 
	    else if (window.ActiveXObject) { // IE
      		req = new ActiveXObject("Microsoft.XMLHTTP");
      		if (req) {
        		req.onreadystatechange = getResponseState;
        		req.open("GET", url, true);
        		req.send();
      		}
    	}
	}
	
	function getResponseState(){
    	if (req.readyState == 4) {
        	if (req.status == 200) {
        		commResetProgress();
				var msg = req.responseText;
				if(msg.indexOf('Error') > -1){
					alert('Error in sending password.');
				}
				else {
					alert(msg);
					//alert(progressVal);
					document.getElementById("com"+progressVal).value = '';
					showComment(progressVal);
				}
        	}
    	}
	}	






	



    function trim(val) {
    	if( val != null && val != "") {
    		val = val.replace(/(^\s+)/,""); // for LTrim
    		val = val.replace(/(\s+$)/,""); // for RTrim
    	}
    	return val;
    }
    


    function checkEmail(emailaddress) {
        if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailaddress) ){
    		return (true);
        }
        alert("invalid email ! please re-enter.");
        return (false);
    }	
    
    function funbfsendemail() {
    		val = document.fbfemail.bfemail.value;
    		val = trim(val);
    		if(!validateEmail(val)) {
    			alert('Please enter valid email address');	
    			return;	
    		}
    		subBFEmail(val);
    }    
    
	    var url = 'http://'+window.location.host;     var title="Everyday Hot Deals in Electronics, Computers, Laptop, Mobile Phones and other Deals";
	function addToFavorites(val) {
	    if( val == '3' )
	        title = 'Everyday Hot Deals in Drink (Liquor, Beer and Wine)'; 	   //alert('ok');		if (window.sidebar) { // Mozilla Firefox Bookmark					window.sidebar.addPanel(title, url,"");			} 		else if( window.external ) { // IE Favorite					window.external.AddFavorite( url, title); 		}			else if(window.opera && window.print) { // Opera Hotlist				return true; 		}	}	


function validateInsert() {
	errorflag = false;
	errormsg = '\nplease select/enter following\n';
		val = document.form_detail.dp_deal_interested_in.value;
		val = trim(val);
		if( val == '' ) {
			errorflag = true;
			errormsg += '\n  Deal Interested In';		
		}

		val = document.form_detail.dp_email_address.value;
		val = trim(val);
		if(!validateEmail(val)) {
			errorflag = true;
			errormsg += '\n  Valid Email Address';		
		}
	if( errorflag ) {
		alert(errormsg);
		return false;
	}
	else{
		document.form_detail.submit();		
	}

}
	

	function editimage(arg){
		location.href="submitdeals.do?command=dealiddetail&dealid="+arg;
	}	

	function funStateDeals() {
		document.fdeal.deals_type.value = 'B';
		document.fdeal.mode.value = 'state';
		document.fdeal.action = 'deals.do';
		document.fdeal.submit();
	}
	
	function funStateInStore(deals_type) {
		document.fdeal.deals_type.value = deals_type;
		document.fdeal.mode.value = 'state';
		document.fdeal.action = 'deals.do';
		document.fdeal.submit();
	}
	
	function trim(val) {
		if( val != null && val != "") {
			val = val.replace(/(^\s+)/,""); // for LTrim
			val = val.replace(/(\s+$)/,""); // for RTrim
		}
		return val;
	}
	
	function funTag(tag) {
		document.fsearch.action = 'tags.do?tag='+tag;
		document.fsearch.submit();
	}	
	
	function funSpecial(search_text) {
        //alert('here');
		search_text = trim(search_text);
		document.fsearch.search_txt.value = search_text;
		document.fsearch.mode.value = 'search';
		document.fsearch.action = 'searchdeals.do';
		document.fsearch.submit();
	}
	
	
	function funSearch() {
//        alert('here');
        tempVal = '';
		val = document.fsearch.search_txt.value;
		val = trim(val);
		tempVal = val;
		if( val == 'Search Drinks Deals' )
		    val = '';
		document.fsearch.search_txt.value = val;
		document.fsearch.mode.value = 'search';
		document.fsearch.action = 'searchdeals.do';
		if ( val == '' ) {
			alert('Enter search term');
			document.fsearch.search_txt.value = tempVal;
			return false;
		}
		
		return true;
		//document.fdeal.submit();
		
	}
	function funDealsDate(date) {
		document.fdate.deal_date.value = date;
		document.fdate.submit();
	}	
	 
	function funDealsView(view) {
		document.fsearch.viewmode.value = view;
		document.fsearch.submit();
	}	


	function funShow(id) {
	}
	function funNoShow(id) {
	}
	
	
	

	function dealsdummy() {
		return ;
	}
	
	// Show Comment block javascript 
	function showComment(val) {
		id = "comment"+val;
		if( document.getElementById(id).style.display == '' )
			document.getElementById(id).style.display = 'none';
		else	
			document.getElementById(id).style.display = '';
	}
	
	
	function funDayDeal(val) {
		//alert('deal id-'+val);
		document.fdeal.deal_day.value=val;
		document.fdeal.submit();
	}	
	
	function commProgress() {
	    //  alert(progressVal);
	 	document.getElementById('pr'+progressVal).style.display = '';
	}
	
	function commResetProgress(val) {
	  	document.getElementById('pr'+progressVal).style.display = 'none';
	}

	var req;
	var progressVal = '';
	
    function subBFEmail(email_id) {
        progressVal = 'bf';
        var url = "ajbfsub.view?mode=ajax&emailaddress="+email_id;
        commProgress();
        funProcessAjex(url);
    }
    
    function subBFContact(email_id,message) {
        //alert('inside='+message);
        progressVal = 'cn';
        var url = "ajbfsub.view?mode=ajax&emailaddress="+email_id+"&message="+message;
        commProgress();
        funProcessAjex(url);
    }    
    
	
	function funsendcomment(val){
		progressVal = '';
		var comment = document.getElementById("com"+val).value;
		if( comment == '' ) {
			alert('Please enter your Comment/Suggestion');
			document.getElementById("com"+val).focus();
			return;
		}
		progressVal = val;
		commProgress();
		var url = "comment.view?deals_id="+val+"&comment="+comment;
		funProcessAjex(url);
	}
		
	function funProcessAjex(url) {
	  //  alert(url);
	   	if (window.XMLHttpRequest) { // Non-IE browsers
      		req = new XMLHttpRequest();
      		//alert(url);
		    req.onreadystatechange = getResponseState;
		    
      		try {
		        req.open("GET", url, true);
      		} 
      		catch (e) {
      			commResetProgress();
		        alert(e);
      		}
		    req.send(null);
	    } 
	    else if (window.ActiveXObject) { // IE
      		req = new ActiveXObject("Microsoft.XMLHTTP");
      		if (req) {
      		//alert(url);
        		req.onreadystatechange = getResponseState;
        		req.open("GET", url, true);
        		req.send();
      		}
    	}
	}
	
	function getResponseState(){
    	if (req.readyState == 4) {
        	if (req.status == 200) {
        		commResetProgress();
				var msg = req.responseText;
				if(msg.indexOf('Error') > -1){
					alert('Error in sending password.');
				}
				else {
					alert(msg);
					//alert(progressVal);
					document.getElementById("com"+progressVal).value = '';
					showComment(progressVal);
				}
        	}
    	}
	}	
	
function rateViewUpdate(recipe_id,rate) {
    progressVal = recipe_id;
    var url = "ajrate.view?recipe_id="+recipe_id+"&curr_rate="+rate;
    commProgress();
    funProcessReviewAjex(url);
    return false;
}	
	
function startViewUpdate(review_id,helpful) {
    progressVal = review_id;
    var url = "ajreview.view?mode=ajax&review_id="+review_id+"&helpful="+helpful;
    //alert(progressVal);
    commProgress();
    funProcessReviewAjex(url);
    return false;
}

	function funProcessReviewAjex(url) {
	    //alert(url);
	   	if (window.XMLHttpRequest) { // Non-IE browsers
      		req = new XMLHttpRequest();
		    req.onreadystatechange = getResReviewState;
      		try {
		        req.open("GET", url, true);
      		} 
      		catch (e) {
      			commResetProgress();
		        alert(e);
      		}
		    req.send(null);
	    } 
	    else if (window.ActiveXObject) { // IE
      		req = new ActiveXObject("Microsoft.XMLHTTP");
      		if (req) {
      		//alert(url);
        		req.onreadystatechange = getResReviewState;
        		req.open("GET", url, true);
        		req.send();
      		}
    	}
	}
	
	function getResReviewState(){
    	if (req.readyState == 4) {
        	if (req.status == 200) {
        		commResetProgress();
				var msg = req.responseText;
				hideHelpfullink(progressVal,msg);
				if(msg.indexOf('Error') > -1){
					alert('Error in sending password.');
				}
				else {
					//alert(msg);
				}
        	}
    	}
	}
	
	function hideHelpfullink(progressVal,msg) {
	    document.getElementById('helpful'+progressVal).style.display = 'none';
	   // document.getElementById('helpfulcount'+progressVal).value = msg;
	    document.getElementById('helpfulcount'+progressVal).innerHTML  = msg;
	    
	}
	
	
		