var d= document;

function track(path,merchant,button_type) {

    path_arr = path.split("?");
    path = path_arr[0];

    var track = path + '?outgoing=' + merchant + '|' + button_type;
    pageTracker._trackPageview(track);
    //alert(track);
}


function compare(urls,urls_s) {
    windows = new Array();
    url_array = urls.split(",");


    for(i = 0; i < url_array.length; i++) {

        var new_window = window.open(url_array[i]);
        windows[i] = new_window;

        if(!new_window) {

            for(j=0;j<windows.length;j++) {
                if(windows[j]) {
                    windows[j].close();
                }
            }

            window.location.href="http://www.easyfindadate.com/browse/comparedatingsites/"+urls_s;
            break;
        }


    }
    self.focus();


}

function visited(id) {
    cross_img = d.getElementById(id+"-not-visited");
    tick_img = d.getElementById(id+"-visited");
    
    cross_img.style.display="none";
    tick_img.style.display="inline";
    
    
}

var current_index = 0;

function want_to_compare() {
    
    if(current_index < sites.length) {
        var current_site = sites[current_index++];
        show_div(current_site['id'],current_site['name'],current_site['link'],current_site['thumbnail_url']);
    }
    else {
        var search_elem = d.getElementById("search_notify");
        search_elem.style.display="none";  
    }

}

function show_div(id,name,link,thumbnail_url) {
    var div = d.getElementById("display_div");
    div.innerHTML = "<strong>Do you want to compare " + name + "?</strong><br/><br/>";    

    div.innerHTML += "<img src='"+thumbnail_url+"' width='120px' style='float:left' />"; 

    div.innerHTML += "<a href='#' onclick='gocompare(\""+id+"\",\""+link+"\");'><img src='"+compare_image_url+"' style='margin-left: 50px' /></a><br/><br/>";
    div.innerHTML += "<a href='#' onclick='nocompare();'><img src='"+skip_image_url+"' style='margin-left: 50px' /></a>";

    div.style.display="";
}

function gocompare(id,link) {

	
    /* for firefox --> var new_window = window.open(link,link,'width=undefined,height=undefined');*/
    new_window = window.open(link,'_blank', 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width=1,height=1');
	new_window.blur();
	new_window.blur();
	new_window.blur();
	new_window.blur();	
	self.focus();		
	self.focus();		
	self.focus();		
	self.focus();		

    var tr = d.getElementById("row-"+id);
    tr.style.display="";


    

    nocompare();
}

function nocompare() {
    var div = d.getElementById("display_div");
    div.style.display="none";
    
    want_to_compare();
}