var base_href='http://www.tu.ro/';
var shirts_colors = Array("", "alb", "rosu", "orange", "albastru", "negru", "verde");
AC_FL_RunContent = 0;
var user_ip = "38.107.191.114";
var perf_flash_saved = false;
var last_flash_div_content;
var last_flash_div_id;
var request_id = "0";
var flash_array = new Array();
var ie_version = false;
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var working_flash = true;
function run_flash(source, width, height, el_id){
	flash_array[flash_array.length]=[source, width, height, el_id];
}
function run_flashes(){
	for (var i = 0; i < flash_array.length; i++)
		run_flash2(flash_array[i][0], flash_array[i][1], flash_array[i][2], flash_array[i][3]);
	}
var ie_version = navigator.appVersion.split("MSIE");
var ie_version = parseFloat(ie_version[1]);
if ((ie_version >= 5.5) && (ie_version < 7) && document.body && document.body.filters)
	ie_version = true;
else
	ie_version = false;

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}
// onDOMLoad
function DOMLoaded(){
	// quit if this function has already been called
	if (arguments.callee.done)
		return;
	// flag this function so we don't do the same thing twice
	arguments.callee.done = true;
	ie_version = navigator.appVersion.split("MSIE");
	ie_version = parseFloat(ie_version[1]);
	if ((ie_version >= 5.5) && (ie_version < 7) && document.body && document.body.filters)
		ie_version = true;
	else
		ie_version = false;
	working_flash = (GetSwfVer() != -1);
		run_flashes();
		//get_ym_status("ruxandra_turo");
	//resolve_ip();
}

function addListener(element, type, expression, bubbling)
{
	bubbling = bubbling || false;
	if (window.addEventListener)
	{
	    element.addEventListener(type, expression, bubbling);
	    return true;
	}
	else if (window.attachEvent)
	{ // IE
	    element.attachEvent('on' + type, expression);
	    return true;
	}
	else
	    return false;
}

function categs_go_left()
{
	if (document.getElementById("cado_categ_0_content").scrollLeft > 0)
		scrollIt(-5, 1);
}

function categs_go_right()
{
	scrollIt(5, 1);
}

function scrollIt(direction, times)
{
    if(times <= 50) 
    {
        document.getElementById("cado_categ_0_content").scrollLeft += direction;
        times++;
        var t = setTimeout('scrollIt(' + direction + ',' + times + ')', 1);
        if(document.getElementById("cado_categ_0_content").scrollLeft > categs_width - categs_cont_width)
        {
            document.getElementById("cado_categ_0_content").scrollLeft = categs_width - categs_cont_width;
            clearTimeout(t);
        }
    }
    else
    {
        clearTimeout(t);
    }
}

function categ_go_left(div_id)
{
    clearTimeout(categs_timers[div_id]);
	if (document.getElementById("cado_categ_" + div_id + "_container").scrollLeft > 0)
		scrollIt_div(-2, 1, div_id);
}

function categ_go_right(div_id)
{
    clearTimeout(categs_timers[div_id]);
	scrollIt_div(2, 1, div_id);
}

function categ_scroll_start_left(div_id){
	clearInterval(categs_intervals[div_id]);
	if (document.getElementById("cado_categ_" + div_id + "_container").scrollLeft > 0)
		categs_intervals[div_id] = setInterval('categ_go_left(' + div_id + ')', 500);
}

function categ_scroll_start_right(div_id){
	clearInterval(categs_intervals[div_id]);
	categs_intervals[div_id] = setInterval('categ_go_right(' + div_id + ')', 500);
}

function categ_scroll_stop(div_id){
	clearInterval(categs_intervals[div_id]);
}

function scrollIt_div(direction, times, div_id)
{
    if(times <= 157) 
    {
        document.getElementById("cado_categ_" + div_id + "_container").scrollLeft += direction;
        times++;
        categs_timers[div_id] = setTimeout('scrollIt_div(' + direction + ',' + times + ',' + div_id + ')', 1);
        if(document.getElementById("cado_categ_" + div_id + "_container").scrollLeft > categs_params[div_id] - categ_cont_width)
        {
            document.getElementById("cado_categ_" + div_id + "_container").scrollLeft = categs_params[div_id] - categ_cont_width;
            clearTimeout(categs_timers[div_id]);
        change_arrow_images(div_id);
        }
    }
    else
    {
        clearTimeout(categs_timers[div_id]);
        change_arrow_images(div_id);
    }
}

function change_arrow_images(div_id)
{
    if (document.getElementById("cado_categ_" + div_id + "_container").scrollLeft == 0)
    	document.getElementById("cado_categ_" + div_id + "_left").src = document.getElementById("cado_categ_" + div_id + "_left").src.replace("_en.", "_dis.");
    else
    	document.getElementById("cado_categ_" + div_id + "_left").src = document.getElementById("cado_categ_" + div_id + "_left").src.replace("_dis.", "_en.");
    if (document.getElementById("cado_categ_" + div_id + "_container").scrollLeft == categs_params[div_id] - categ_cont_width)
    	document.getElementById("cado_categ_" + div_id + "_right").src = document.getElementById("cado_categ_" + div_id + "_right").src.replace("_en.", "_dis.");
    else
    	document.getElementById("cado_categ_" + div_id + "_right").src = document.getElementById("cado_categ_" + div_id + "_right").src.replace("_dis.", "_en.");
}

function change_categs_widths()
{
	for (cid in categs_params)
		document.getElementById("cado_categ_" + cid + "_scroll").style.width = categs_params[cid] + "px";
}


/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */

this.imagePreview = function(){    
    /* CONFIG */
        
        xOffset = 10;
        yOffset = 30;
        
        // these 2 variable determine popup's distance from the cursor
        // you might want to adjust to get the right result
        
    /* END CONFIG */
    $jq("a.cado_new_link").hover(function(e){
        this.t = this.title;
        this.title = "";    
        var c = (this.getAttribute("desc") != "") ? "<br/><span class='cado_scurt'>" + this.getAttribute("desc") + "</span>" : "";
        $jq("body").append("<p id='preview'><img src='"+ this.rel +"' alt='"+ this.title +"' />"+ c +"</p>");                                 
        $jq("#preview")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px")
            .fadeIn("fast");                        
    },
    function(){
        this.title = this.t;    
        $jq("#preview").remove();
    });    
    $jq("a.cado_new_link").mousemove(function(e){
    	$jq("#preview")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px");
    });            
};