var message="Copyright © Holidaylettings4you, Ltd. All rights reserved!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false")

$(document).ready(function() {

$('#tagbox').tagdragon({
	'field':'tags',
	'url':'/autoauggest.php',
	'charMin':1,
	onRenderItem: function(val,index,total,filter) { return val.tag; },
	onSelectItem: function(val) { },
	onLoadList: function(filter) { }
	});

/*	$('#tagbox2').tagdragon({'field':'tags2','url':'snakes.php','tagsep':' ','enclose':'"'});
*/
	$('#sp').click(function() {
	  //$('#sp').hide();
	  $('#soc_ddl').fadeIn('slow');
	});

	$('#sp_hide').click(function() {
		  $('#soc_ddl').fadeOut('slow');
		  $('#sp').fadeIn('slow');
	});	
		
	$('#sp_hide1').click(function() {
		  $('#soc_ddl').fadeOut('slow');
		  $('#sp').fadeIn('slow');
	});	
	
	$('#late_deal').change(function() {
		if($(this).val() == '1'){
			$('#late_deals_detail').show();
		}else{
			$('#late_deals_detail').hide();
		}
	});
	
	$('a.adbanner').click(function(event){
		event.preventDefault();
		url = this.href;
		var id = $(this).attr('id').replace("banner-","");
		$.ajax({
		  url: 'actions.php?QT=1&id='+id,
		  success: function(data) {
			if(data == 'ok'){
				if(url!=undefined && url!="")
					window.location = url;
				else	
					return false;
					
			}
		  }
		});
	});

	
});

function addToFavorite(title){
	if (window.sidebar) {
	// Mozilla Firefox Bookmark
	//alert("FIREFOX!");
	window.sidebar.addPanel(title, document.location,"");
	} else if( window.external ) {
	// IE Favorite
	//alert("YES IE");
	window.external.AddFavorite(document.location, title);
	}
	else if(window.opera && window.print) {
	// Opera Hotlist
	return true; }

	}

function showLastExpiryDate(val){
	$('#exp_1').hide();$('#exp_7').hide();$('#exp_14').hide();
	$('#exp_'+val).show();	
}


/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;

/**
 * enables highlight and marking of rows in data tables
 *
 */
function PMA_markRowsInit() {
    // for every table row ...
    var rows = document.getElementsByTagName('tr');
    for ( var i = 0; i < rows.length; i++ ) {
        // ... with the class 'odd' or 'even' ...
        if ( 'odd' != rows[i].className.substr(0,3) && 'even' != rows[i].className.substr(0,4) ) {
            continue;
        }
        // ... add event listeners ...
        // ... to highlight the row on mouseover ...
        if ( navigator.appName == 'Microsoft Internet Explorer' ) {
            // but only for IE, other browsers are handled by :hover in css
            rows[i].onmouseover = function() {
                this.className += ' hover';
            }
            rows[i].onmouseout = function() {
                this.className = this.className.replace( ' hover', '' );
            }
        }
        // Do not set click events if not wanted
        if (rows[i].className.search(/noclick/) != -1) {
            continue;
        }
        // ... and to mark the row on click ...
        rows[i].onmousedown = function() {
            var unique_id;
            var checkbox;

            checkbox = this.getElementsByTagName( 'input' )[0];
            if ( checkbox && checkbox.type == 'checkbox' ) {
                unique_id = checkbox.name + checkbox.value;
            } else if ( this.id.length > 0 ) {
                unique_id = this.id;
            } else {
                return;
            }

            if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                marked_row[unique_id] = true;
            } else {
                marked_row[unique_id] = false;
            }

            if ( marked_row[unique_id] ) {
                this.className += ' marked';
            } else {
                this.className = this.className.replace(' marked', '');
            }

            if ( checkbox && checkbox.disabled == false ) {
                checkbox.checked = marked_row[unique_id];
            }
        }

        // ... and disable label ...
        var labeltag = rows[i].getElementsByTagName('label')[0];
        if ( labeltag ) {
            labeltag.onclick = function() {
                return false;
            }
        }
        // .. and checkbox clicks
        var checkbox = rows[i].getElementsByTagName('input')[0];
        if ( checkbox ) {
            checkbox.onclick = function() {
                // opera does not recognize return false;
                this.checked = ! this.checked;
            }
        }
    }
}
window.onload=PMA_markRowsInit;

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 *
 * @param    container    DOM element
 */
function markAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
	var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                    rows[i].className += ' marked';
                    marked_row[unique_id] = true;
                }
            }
        }
    }

    return true;
}

/**
 * marks all rows and selects its first checkbox inside the given element
 * the given element is usaly a table or a div containing the table or tables
 *
 * @param    container    DOM element
 */
function unMarkAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;
            rows[i].className = rows[i].className.replace(' marked', '');
            marked_row[unique_id] = false;
        }
    }

    return true;
}

function markunMarkAllRows(container_id,el){
	if(el.value == 1){
		el.value = 0;
		el.checked = "";
		unMarkAllRows( container_id );
	}else{
		el.value = 1;
		el.checked = "checked";
		markAllRows( container_id );
	}
	return true;
}

/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
 

