

var exclude=1;
var agt=navigator.userAgent.toLowerCase();
var win=0;var mac=0;var lin=1;
if(agt.indexOf('win')!=-1){win=1;lin=0;}
if(agt.indexOf('mac')!=-1){mac=1;lin=0;}
var lnx=0;if(lin){lnx=1;}
var ice=0;
var ie=0;var ie4=0;var ie5=0;var ie6=0;var com=0;var dcm;
var op5=0;var op6=0;var op7=0;
var ns4=0;var ns6=0;var ns7=0;var mz7=0;var kde=0;var saf=0;
if(typeof navigator.vendor!="undefined" && navigator.vendor=="KDE"){
	var thisKDE=agt;
	var splitKDE=thisKDE.split("konqueror/");
	var aKDE=splitKDE[1].split("; ");
	var KDEn=parseFloat(aKDE[0]);
	if(KDEn>=2.2){
		kde=1;
		ns6=1;
		exclude=0;
		}
	}
else if(agt.indexOf('webtv')!=-1){exclude=1;}
else if(typeof window.opera!="undefined"){
	exclude=0;
	if(/opera[\/ ][5]/.test(agt)){op5=1;}
	if(/opera[\/ ][6]/.test(agt)){op6=1;}
	if(/opera[\/ ][7-9]/.test(agt)){op7=1;}
	}
else if(typeof document.all!="undefined"&&!kde){
	exclude=0;
	ie=1;
	if(typeof document.getElementById!="undefined"){
		ie5=1;
		if(agt.indexOf("msie 6")!=-1){
			ie6=1;
			dcm=document.compatMode;
			if(dcm!="BackCompat"){com=1;}
			}
		}
	else{ie4=1;}
	}
else if(typeof document.getElementById!="undefined"){
	exclude=0;
	if(agt.indexOf("netscape/6")!=-1||agt.indexOf("netscape6")!=-1){ns6=1;}
	else if(agt.indexOf("netscape/7")!=-1||agt.indexOf("netscape7")!=-1){ns6=1;ns7=1;}
	else if(agt.indexOf("gecko")!=-1){ns6=1;mz7=1;}
	if(agt.indexOf("safari")!=-1 || (typeof document.childNodes!="undefined" && typeof document.all=="undefined" && typeof navigator.taintEnabled=="undefined")){mz7=0;ns6=1;saf=1;}
	}
else if((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)){
	exclude=0;
	ns4=1;
	if(typeof navigator.mimeTypes['*']=="undefined"){
		exclude=1;
		ns4=0;
		}
	}
if(agt.indexOf('escape')!=-1){exclude=1;ns4=0;}
if(typeof navigator.__ice_version!="undefined"){exclude=1;ie4=0;}




$(document).ready(function(){
	//changeActive();
	
	
	$(".Cursors").tooltip({
	track: true,
	delay: 0,
	showURL: false,
	fixPNG: false,
	showBody: " - ",
	top: 15,
	left: 15
});

	
	//rate_me_my_friend();
	mail_me_my_friend();
		
	jQuery("div#slider_inner").codaSlider();
	$('#slider_bottom li a').click(function(){
		changeActiveClick(this);
	});
	
	$('.stripNavR a').click(function(){
		changeActive();
	}).ifixpng();
	
	$('.stripNavL a').click(function(){
		changeActive();
	}).ifixpng();
	
	$('#tabs-1 > ul').tabs({ fx: [null, { height: 'show', opacity: 'show' }] });
	$('#tabs-2 > ul').tabs({ fx: [null, { height: 'show', opacity: 'show' }] });


	$('#search').click(function(){
		if($(this).val() == 'search reviews') $(this).val('');
	});
	
	$('#search').blur(function(){
		if($(this).val()=='')  $(this).val('search reviews');
	});
	
	$('#get_alerts #firstname').click(function(){
		if($(this).val() == 'first name') $(this).val('');
	});
	
	$('#get_alerts #firstname').blur(function(){
		if($(this).val()=='')  $(this).val('first name');
	});
	
	$('#get_alerts #lastname').click(function(){
		if($(this).val() == 'last name') $(this).val('');
	});
	
	$('#get_alerts #lastname').blur(function(){
		if($(this).val()=='')  $(this).val('last name');
	});
	
	$('#get_alerts #email').click(function(){
		if($(this).val() == 'e-mail address') $(this).val('');
	});
	
	$('#get_alerts #email').blur(function(){
		if($(this).val()=='')  $(this).val('e-mail address');
	});

/*
	if(!ie6)
	{
	$(".section_image").dropShadow({left: 0, top: 0, blur: 1, opacity:'0.5'});
	$(".review_image").dropShadow({left: 0, top: 0, blur: 1, opacity:'0.5'});
	//$(".section_inner_box").dropShadow({left: 0, top: 0, blur: 1, opacity:'0.5'});
	}
	else
	{
		$(".section_image").css('border','1px solid #eaeaea');
		$(".review_image").css('border','1px solid #eaeaea');
		$(".section_inner_box").css('border','1px solid #eaeaea');
	}
*/
	var lastclicked = '';
	
	$("#category_list a").click(function(){
		if(lastclicked == '') lastclicked = this;
		var clicked = this;
		if($(this).parent().parent().attr('class') != 'list_inner')
		{
			$("#category_list .list_inner").each(function(){
			
			if($(this).parent().attr('class')=='active')
			{
				$(this).parent().removeClass('active');
				$(this).slideUp('fast');
			}
			
			});
			
			
			if(lastclicked!=clicked)
			{
			$(clicked).next().slideDown();
			$(clicked).parent().addClass('active');
			lastclicked = clicked;
			}
			else lastclicked = null;
				
		return false;

		}
		
	});
	enable_sitelist();
	enable_sitelist2();
		
});

function changeActive()
{
	var url = window.location.href;
	var s_split = url.split('#');
	var id = s_split[1];
	
	if(id==null) id = 1;
	
	$("#slider_bottom li").removeClass('active');
	$("#p"+id).addClass('active');
}

function changeActiveClick(which)
{
	$("#slider_bottom li").removeClass('active');
	$(which).parent().addClass('active');
}

function rate_me_my_friend()
{
	$(".a_rate").click(function(){
		var position = $(this).offset();
		var id = $(this).attr('id');
		var id_split = id.split('_');
		var reviewID = id_split[1];
		
				
		var html='<div class="addrating" id="addrating_'+ reviewID +'"><div class="addrating_top"><h4 class="left">Please rate this review</h4> <a href="#" class="rating_close right">X</a></div><div class="addrating_content"><form name="form1" method="post" action="MemberRating.aspx?SURID='+reviewID+'"><table><tr><td><select name="ddMemRating" id="ddMemRating"><option value="0">Not rated yet</option><option value="1">I Agree Completely</option><option value="2">Helpful</option><option value="3">Seems Biased</option><option value="4">Just A Flame</option></select></td><td><input type="submit" name="Button1" value="Submit" /></td></tr></table></form></div></div>';
		
		if($("#addrating_"+reviewID).html() == null)
		{
			$("body").append(html); 
		}
		
		
		
		$("#addrating_"+reviewID).css({top:position.top+'px',left:position.left+'px'}).fadeIn();
		$("#addrating_"+reviewID+" .rating_close").click(function(){
			$("#addrating_"+reviewID).fadeOut();
			return false;
		});		
		return false;
	});
}

function mail_me_my_friend()
{
	$(".a_email").click(function(){
		var position = $(this).offset();
		var id = $(this).attr('id');
		var id_split = id.split('_');
		var reviewID = id_split[1];
		
		
				
		var html='<div class="addrating" id="popupemail_'+ reviewID +'"><div class="addrating_top"><h4 class="left" style="width:80%">E-mail this review to a friend</h4> <a href="#" class="rating_close right">X</a></div><div class="addrating_content"><form name="form1" method="post" action="EmailFriend.aspx?SURID='+reviewID+'"><table><tr><td>Your Name</td><td><input name="txtFromName" type="text" id="txtFromName" /></td></tr><tr><td>Your E-mail Address</td><td><input name="txtFromEmail" type="text" id="txtFromEmail" /></td></tr><tr><td>Friend\'s E-mail Address</td><td><input name="txtToEmail" type="text" id="txtToEmail" /></td></tr><tr><td colspan="2" style="text-align:right"><input type="submit" name="Button1" value="Submit"  /></td></tr></table></form></div></div>';
		
		if($("#popupemail_"+reviewID).html() == null)
		{
			$("body").append(html); 
		}
		
		
		$("#popupemail_"+reviewID).css({top:position.top+'px',left:position.left+'px'}).fadeIn();
		$("#popupemail_"+reviewID+" .rating_close").click(function(){
			$("#popupemail_"+reviewID).fadeOut();
			return false;
		});		
		return false;
	});
}

function enable_sitelist() {
    $('#header_nav').each(function() {
        // options
        var distance = 10;
        var time = 250;
        var hideDelay = 500;

        var hideDelayTimer = null;

        // tracker
        var beingShown = false;
        var shown = false;



        // $("#sitelist").bgiframe({opacity:false,top:-1,left:-1});

        var trigger = $('#a_sitelist', this);
        var popup = $('#sitelist').css('opacity', 0);



        // set the mouseover and mouseout on both element
        $([trigger.get(0), popup.get(0)]).mouseover(function() {


            var trigger_offset = $(this).offset();
            var trigger_height = $(this).height();

            var parent_offset = $(this).parent().offset();

            /*
            var parent_left = 0;
            var parent_top = 0;
            var last_parent_left = 0;
            var last_parent_top = 0;
            $(this).parents('div').each(function(){
            if($(this).css('position') =='relative')
            {
					
					var parent_offset = $(this).offset();
            console.log($(this).attr('id')+":"+$(this).attr('class')+":"+parent_offset['left']);
            if(parent_offset['left']!=last_parent_left) parent_left+= parent_offset['left'];
            if(parent_offset['top']!=last_parent_top)parent_top+= parent_offset['top'];
					
					last_parent_left = parent_offset['left'];
            last_parent_top = parent_offset['top'];
            }
            });
            */
            //console.log( parseInt(trigger_offset['left']) +'-'+ parseInt(trigger.width()) + '-' + parseInt(parent_offset['left']))
            var popup_right = parseInt($(window).width()) - parseInt(trigger_offset['left']) - parseInt(trigger.width());
            var popup_top = parseInt(trigger_offset['top']) - parseInt(parent_offset['top']) + parseInt(trigger_height) + 10;


            // stops the hide event if we move from the trigger to the popup element
            if (hideDelayTimer) clearTimeout(hideDelayTimer);

            // don't trigger the animation again if we're being shown, or already visible
            if (beingShown || shown) {
                return;
            } else {
                beingShown = true;

                // reset position of popup box
                popup.css({
                    top: popup_top,
                    right: popup_right,
                    zIndex: 100000,
                    display: 'block' // brings the popup back in to view
                })

                // (we're using chaining on the popup) now animate it's opacity and position
	        .animate({
	            top: '+=' + distance + 'px',
	            opacity: 1
	        }, time, 'swing', function() {
	            // once the animation is complete, set the tracker variables
	            beingShown = false;
	            shown = true;
	        });
            }
        }).mouseout(function() {
            // reset the timer if we get fired again - avoids double animations
            if (hideDelayTimer) clearTimeout(hideDelayTimer);

            // store the timer so that it can be cleared in the mouseover if required
            hideDelayTimer = setTimeout(function() {
                hideDelayTimer = null;
                popup.animate({
                    top: '+=' + distance + 'px',
                    opacity: 0
                }, time, 'swing', function() {
                    // once the animate is complete, set the tracker variables
                    shown = false;
                    // hide the popup entirely after the effect (opacity alone doesn't do the job)
                    popup.css('display', 'none');
                });
            }, hideDelay);
        });
    });

}


function enable_sitelist2() {
    $('#top_header_nav').each(function() {
        // options
        var distance = 10;
        var time = 250;
        var hideDelay = 500;

        var hideDelayTimer = null;

        // tracker
        var beingShown = false;
        var shown = false;



        // $("#sitelist").bgiframe({opacity:false,top:-1,left:-1});

        var trigger = $('#top_a_sitelist', this);
        var popup = $('#sitelist2').css('opacity', 0);



        // set the mouseover and mouseout on both element
        $([trigger.get(0), popup.get(0)]).mouseover(function() {


            var trigger_offset = $(this).offset();
            var trigger_height = $(this).height();

            var parent_offset = $(this).parent().offset();

            /*
            var parent_left = 0;
            var parent_top = 0;
            var last_parent_left = 0;
            var last_parent_top = 0;
            $(this).parents('div').each(function(){
            if($(this).css('position') =='relative')
            {
					
					var parent_offset = $(this).offset();
            console.log($(this).attr('id')+":"+$(this).attr('class')+":"+parent_offset['left']);
            if(parent_offset['left']!=last_parent_left) parent_left+= parent_offset['left'];
            if(parent_offset['top']!=last_parent_top)parent_top+= parent_offset['top'];
					
					last_parent_left = parent_offset['left'];
            last_parent_top = parent_offset['top'];
            }
            });
            */
            //console.log( parseInt(trigger_offset['left']) +'-'+ parseInt(trigger.width()) + '-' + parseInt(parent_offset['left']))
            var popup_left = parseInt((parseInt($(window).width()) - parseInt(popup.width()))/2);
            var popup_top = parseInt(trigger_offset['top']) + parseInt(trigger_height);


            // stops the hide event if we move from the trigger to the popup element
            if (hideDelayTimer) clearTimeout(hideDelayTimer);

            // don't trigger the animation again if we're being shown, or already visible
            if (beingShown || shown) {
                return;
            } else {
                beingShown = true;

                // reset position of popup box
                popup.css({
                    top: popup_top,
                    left: popup_left,
                    zIndex: 100000,
                    display: 'block' // brings the popup back in to view
                })

                // (we're using chaining on the popup) now animate it's opacity and position
	        .animate({
	            top: '+=' + distance + 'px',
	            opacity: 1
	        }, time, 'swing', function() {
	            // once the animation is complete, set the tracker variables
	            beingShown = false;
	            shown = true;
	        });
            }
        }).mouseout(function() {
            // reset the timer if we get fired again - avoids double animations
            if (hideDelayTimer) clearTimeout(hideDelayTimer);

            // store the timer so that it can be cleared in the mouseover if required
            hideDelayTimer = setTimeout(function() {
                hideDelayTimer = null;
                popup.animate({
                    top: '+=' + distance + 'px',
                    opacity: 0
                }, time, 'swing', function() {
                    // once the animate is complete, set the tracker variables
                    shown = false;
                    // hide the popup entirely after the effect (opacity alone doesn't do the job)
                    popup.css('display', 'none');
                });
            }, hideDelay);
        });
    });

}