/*
 * kajeet.js - site-wide scripts
 */
/* reassign jQuery's $() function to avoid conflicts with Prototype */
	var $jq = jQuery.noConflict();

/* configuration variables */
	// for search field
	var searchtext = 'Search kajeet.com';

/* reuseable functions */
// trim excess whitespace from strings
	function trim(str){
		str = this != window? this : str;
		return str.replace(/^\s+/g,'').replace(/\s+$/g,'');
	};

/* document manipulation */
$jq(document).ready(function(){
	/* for special offer highlights in product listings */
	$jq('ol.productlist div.deal').hover(
		function(){
			$jq(this).parents('li').addClass('open-deal');
		},
		function(){
			$jq(this).parents('li').removeClass('open-deal');
		}
	);
	/* for tab views */
	$jq('ol.tabcontrol li a').click(function(){
		// find open items
		$jq(this).parents('.tabbox').find('.active').removeClass('active');
		$jq(this).parents('.tabbox').find('.tabscreen-active').removeClass('tabscreen-active').addClass('tabscreen');
		// highlight selected items
		$jq(this).parents('li').addClass('active');
		$jq($jq(this).attr('href')).removeClass('tabscreen').addClass('tabscreen-active');
		this.blur();
		return false;
	});
	/* IE specific code goes within this IF statement */
	if($jq.browser.msie){
		// force top menu suckerfish behaviors
		$jq('#mainnav li[@id]').hover(
			function(){ // mouseover actions
				$jq(this).addClass('active-temp');
			},
			function(){ // mouseout actions
				$jq(this).removeClass('active-temp');
			}
		);
		/* for "help" items in activation/purchase flows */
		$jq('.help').hover(
			function(){
				$jq(this).addClass('open-help');
			},
			function(){
				$jq(this).removeClass('open-help');
			}
		);
	}
});

/* Drawer effect for Get the Good stuff pages */
function ggsDrawer(el) {
    var children = el.getElementsByTagName("OL");
    if (children.length > 0) {
        var child = children[0];
        if (child.style.display == "block")
        {
            child.style.display = "none";
			el.classname="active";
           }
        else
        {
            child.style.display = "block";
			el.classname="expanded";
		}
    }
}

/* This function is used to change the style class of an element */
function swapClass(obj, newStyle) {
    obj.className = newStyle;
}

// dynamic faq lists
function faq_show_answer(el) {
    // hide open children in this list?
    var children = el.getElementsByTagName("UL");
    if (children.length > 0) {
        var child = children[0];
        if (child.style.display == "block")
            child.style.display = "none";
        else
            child.style.display = "block";
    }
}