$(document).ready(function() {
	

	// download SM facebook overlay
	var location = String(window.location);
	if (
			location.indexOf('sync_mac_google.html') != -1 || 
			location.indexOf('sync_mac_nokia.html') != -1 || 
			location.indexOf('sync_mac_windows_mobile.html') != -1 || 
			location.indexOf('sync_mac_pc.html') != -1 || 
			location.indexOf('sync_several_macs.html') != -1 || 
			location.indexOf('sync_mac_google.html') != -1 || 
			location.indexOf('sync_mac_psp.html') != -1 || 
			location.indexOf('sync_mac_usb_drive.html') != -1 || 
			location.indexOf('backup_mac_online.html') != -1 || 
			location.indexOf('sync_mac_android.html') != -1 || 
			location.indexOf('htc_sync.html') != -1 || 
			location.indexOf('samsung_sync.html') != -1 || 
			location.indexOf('mac_synchronization.html') != -1 || location.indexOf('sync_mac_dropbox.html') != -1 || location.indexOf('sync_mac_ipod.html') != -1 || location.indexOf('iphone_sync.html') != -1 || location.indexOf('sync_mac_ipad.html') != -1 || location.indexOf('sync_mac_ios.html') != -1 || location.indexOf('sync_mac_ipod_touch.html') != -1 || location.indexOf('sync-mac.html')) {
	   /* $('a[href="http://sync-mac.com/download/syncmate.dmg"]').bind('click', function() {
	        activateOverlay();
	    });
	    $('a[href="http://mac.eltima.com/download/syncmate.dmg"]').bind('click', function() {
	        activateOverlay();
	    });
	    $('a[href="/download/syncmate.dmg"]').bind('click', function() {
	        activateOverlay();
	    });*/
	}
	function activateOverlay() {
	    //if (!getCookie('fcbOverlay')) // show one time
	    if ( true ) // always show
	    {
	    	var lang = $('html').attr('lang');
	    	
	    	if( lang != "en" )
	    	{
	    		lang = lang+'/';
	    	}
	    	else
	    	{
	    		lang = '';
	    	}	
	        setTimeout(function() {
	            $.fn.colorbox({
	                iframe: true,
	                innerWidth: '680px',
	                innerHeight: '394px',
	                speed: 200,
	                opacity: 0.8,
	                href: "http://mac.eltima.com/"+lang+"facebook-overlay",
	                });
	            setCookie('fcbOverlay', '1', 1);
	        }, 2000);
	        return true;
	    } else {
	        return this;
	    }
	}
	function setCookie(name, value, days) {
	    var location = String(window.location);
	    name = name + location.replace('http://mac.eltima.com/', '');
	    if (days) {
	        var date = new Date();
	        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
	        var expires = "; expires=" + date.toGMTString();
	    } else
	        var expires = "";
	    document.cookie = name + "=" + value + expires + "; path=/";
	}
	function getCookie(name) {
	    var location = String(window.location);
	    name = name + location.replace('http://mac.eltima.com/', '');
	    var nameEQ = name + "=";
	    var ca = document.cookie.split(';');
	    for (var i = 0; i < ca.length; i++) {
	        var c = ca[i];
	        while (c.charAt(0) == ' ')
	            c = c.substring(1, c.length);
	        if (c.indexOf(nameEQ) == 0)
	            return c.substring(nameEQ.length, c.length);
	    }
	    return null;
	}
	
	$.urlParam = function(name, url){
    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
    if (!results) { return 0; }
    return results[1] || 0;
  }; 

    $('.e-button').bind('click', function() {
        var link = $(this);
        link.removeClass('e-button-p');
        link.addClass('e-button');
    });

    $('.e-button').bind('mousedown', function() {
        var link = $(this);
        link.removeClass('e-button');
        link.addClass('e-button-p');
    });

    $('.e-button').bind('mouseup', function() {
        var link = $(this);
        link.removeClass('e-button-p');
        link.addClass('e-button');
    });

    $('.e-button').bind('mouseout', function() {
        var link = $(this);
        link.removeClass('e-button-p');
        link.addClass('e-button');
    });

    $('.eb-button').bind('click', function() {
        var link = $(this);
        link.removeClass('eb-button-p');
        link.addClass('eb-button');
    });

    $('.eb-button').bind('mousedown', function() {
        var link = $(this);
        link.removeClass('eb-button');
        link.addClass('eb-button-p');
    });

    $('.eb-button').bind('mouseup', function() {
        var link = $(this);
        link.removeClass('eb-button-p');
        link.addClass('eb-button');
    });

    $('.eb-button').bind('mouseout', function() {
        var link = $(this);
        link.removeClass('eb-button-p');
        link.addClass('eb-button');
    });
$('a').filter(function () { return (/\.(exe|dmg|apk|zip|rar|bz2)(?:\?([^#]*))?(?:#(\.*))?$/i.test($(this).attr('href'))) && ($(this).attr('notrack') == undefined); }).bind('click', function(){
			_gaq.push(['_trackPageview',$(this).attr('href')]);
				var href = String($(this).attr('href'));
				if (href.indexOf('syncmate.dmg')){
					activateOverlay();
				}
			});
	$(".colorbox").colorbox();
	$(".youtube").colorbox({iframe:true, innerWidth:'505px', innerHeight:'410px'});
	$(".er_contact").colorbox({iframe:true, innerWidth:'540px', innerHeight:'565px', speed:200,opacity:0.8});
	$("a.screenshot").colorbox({opacity:0.8});
//$(".try_link").colorbox({width:"50%", height:"250px", inline:true, href:"#download_overlay"});
$(".wiki_site").colorbox({width:"50%", height:"40%",inline:true, href:"#wiki_site"});
$(".suppDevLink").colorbox({iframe:true, innerWidth:605, innerHeight:512, transition:"none", speed: 0 }); 
//$("#try_link_sm, #try_link_sm2").colorbox({innerWidth:'865px', innerHeight:'690px', scrolling:false, inline:true, href:"#download_overlay"});			
//	$("#try_link_sm, #try_link_sm2").colorbox({iframe:true, innerWidth:'855px', innerHeight:'690px', scrolling:false, href: function(){ var url = $(this).attr('value'); return url;}});	
/*	$("#try_link_sm, #try_link_sm2").colorbox({innerWidth:function(){return $.urlParam('width', $(this).attr('value'));},
										innerHeight:function(){return $.urlParam('height', $(this).attr('value'));},
										iframe:true, scrolling:false, href: function(){return $.urlParam('href', $(this).attr('value'));}});	
*/

	$(document).bind('cbox_complete', function(){
        			   if (window.Cufon !== undefined)
						   	{
							 Cufon.replace(".ArialRoundedMTBold", { fontFamily: 'Arial Rounded MT Bold'});
							}

				$('#elmedia_do .download_button a, #folx_do .download_button a').bind('click', function(){$('#cboxClose').click()});
		});		

var licLinks = $(".wiki");
		$.each(licLinks, function()
		{
			this.href = this.href + '?ajax=true';
			$(this).colorbox({iframe:true, innerWidth:'80%', innerHeight:'70%'});
		});
});





