/* agenzy directory browse box */
function catClosure(id, area) {
	return (function() {
		var focus_id = id.substring(6); //strip "focus-"
		$('#whitebox').fadeOut(300, function() {
			$("#loadingwhitebox").show();

		  	$(this).load('/index/index.php?id='+focus_id, 
		  				function() { 
					
				$(this).fadeIn(300);
							if (focus_id=='10000')
							{
								$('#whiteboxtabs').animate({
								height:"865px"
								},1500);
								$("#whitebox-container").animate({
								height:"865px"
								},1500);
								$("#bluebox").animate({
								height:"865px"
								},1500);
							} else {
								$('#whiteboxtabs').animate({
								height:"420px"
								},1500);
								$("#whitebox-container").animate({
								height:"420px"
								},1500);
								$("#bluebox").animate({
								height:"420px"
								},1500);
							};
				
				});
		  	});
		$('#whiteboxtabs .tab').attr('class', 'tab');
		$('#' + id).attr('class', 'tab on');
	});
}

function areaClosure(name) {
	return (function() {
		$('#tabtop .tab').attr('class', 'tab');
		$('#' + name + '-tab').attr('class', 'tab on');
		
		$('#whitebox').fadeOut(300);
		$('#whiteboxtabs').fadeOut(300, function(){
			$("#loadingwhitebox").show();
			$(this).html('');
			$('#'+name+'-tabs .tab').clone(true).appendTo('#whiteboxtabs');
			$('#'+name+'-tabs p.link').clone(true).appendTo('#whiteboxtabs');
			$('#whiteboxtabs').fadeIn(300);
			$('#whiteboxtabs .on').click();
			
		  });
	});
}


var Obj;
function ToolTip(obj,con,x,y,t){
	if (!con) return false;
	if (!t) t='750';
 Obj=$('#Pop');
 Obj.html("<div class='loading' id='loadingcontent' style='display:inline;'><img src='/images/loading-snake.gif'></div><div id='contenttooltip' style='display:none;'>"+con+"</div>");
 Obj.show();
$('#Pop').css("left",(zxcPos(obj)[0]+x)+'px');
$('#Pop').css("top",(zxcPos(obj)[1]+y)+'px');
 setTimeout("populatediv()",t);
}
function populatediv(){

try{ 
Objloading=$('#loadingcontent');
Objcontent=$('#contenttooltip');
Objloading.hide();
Objcontent.show();
}catch(err){}

}

function Hide(){
 Obj=$('#Pop');
 Obj.hide();
 Obj.html("<div class='loading' id='loadingcontent'><img src='/images/loading-snake.gif'></div>");
}

function zxcPos(zxcobj){
 zxclft=zxcobj.offsetLeft;
 zxctop=zxcobj.offsetTop;
 while(zxcobj.offsetParent!=null){
  zxcpar=zxcobj.offsetParent;
  zxclft+=zxcpar.offsetLeft;
  zxctop+=zxcpar.offsetTop;
  zxcobj=zxcpar;
 }
 return [zxclft,zxctop];
}


//////////////// YOUTUBE VIDEO BAR \\\\\\\\\\\\\\\\\\\\\\\\\

function LoadVideoBar(title,id) {

    var videoBar;
    var options = {
        largeResultSet : !true,
        horizontal : true,
		string_allDone : "-- Close video window --",
        autoExecuteList : {
          cycleTime : GSvideoBar.CYCLE_TIME_MEDIUM,
          cycleMode : GSvideoBar.CYCLE_MODE_LINEAR,
			executeList : [title]
			  }
      }
	  var vidbar="videoBar-bar-"+id;
//	  alert(vidbar);
    videoBar = new GSvideoBar(document.getElementById(vidbar),
                              GSvideoBar.PLAYER_ROOT_FLOATING,
                              options,id);

if ($(".floatingPlayer_gsvb").length>0){
 	$(".floatingPlayer_gsvb")
		.draggable({ containment: 'parent' })
		.hover(function(){$(this).css("cursor","move")});
		
	$(".floatingPlayerBox_gsvb").hide();
}
   }



function ActivateVideoBar(obj,xx){
var vidbar=$("#videoBar-"+xx);
var vidbarbar=$("#videoBar-bar-"+xx);
if (vidbar.css("display")=="none"){		
	vidbar.css("left",(zxcPos(obj)[0]-150)+"px");
	vidbar.css("top",(zxcPos(obj)[1]+20)+"px");
	vidbar.show("slow");
	vidbarbar.show("slow");
	}else{
	vidbar.hide("slow");
	vidbarbar.hide("slow");
	};


}


	function start()  {	
	/* offer browse box */
	$('#retail-tab').click(areaClosure('retail'));
	$('#category-tab').click(areaClosure('category'));
	$('#coupon-tab').click(areaClosure('coupon'));
	
	$('#category-tabs .tab').each(function(i) {
		$(this).click(catClosure(this.id, 'category'));
	});
	$('#retail-tabs .tab').each(function() {
		$(this).click(catClosure(this.id, 'retail'));
	});
	$('#coupon-tabs .tab').each(function() {
		$(this).click(catClosure(this.id, 'coupon'));
	});
	$('#tabtop .on').click();	

}
$(function(){
$("#loadingwhitebox").show();
setTimeout("start()",500);
});