﻿function playVimeoVideo(divid, videoid, width, height) {
	var videoobject = '<iframe src="http://player.vimeo.com/video/' + videoid + '?server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1&amp;autoplay=1" width="' + width + '" height="' + height + '" frameborder="0"></iframe>';
    $("#" + divid + " div").html(videoobject);
    $("#" + divid).modal({
		opacity: 60,
		overlayCss: {backgroundColor:"#000"},
		overlayClose: true
	});

    return false;
}

function playYoutubeVideo(divid, videoid, width, height) {
	var videoobject = '<iframe class="youtube-player" type="text/html" width="' + width + '" height="' + height + '" src="http://www.youtube.com/embed/' + videoid + '?hl=en&amp;fs=1&amp;autoplay=1" frameborder="0"></iframe>';
    $("#" + divid+" div").html(videoobject);
    $("#" + divid).modal({
		opacity: 60,
		overlayCss: {backgroundColor:"#000"},
		overlayClose: true
	});

    return false;
}

function searchForDomain(obj) {
    var searchstr = $(obj).parent().parent().children(".searchtext").val();
    var company = $(obj).parent().parent().children(".hidcompany").val();

    if (searchstr != "" && searchstr != "WWW." && searchstr!=undefined) {
        window.location = "http://www." + company + "/DomainSearch.aspx?q=" + searchstr + "&t=CA,COM,NET,ORG,MOBI,INFO,BIZ,NAME,ASIA,EU,US,CN,CO,COM.AU,NET.AU,ORG.AU,ASN.AU,ID.AU";
    }

    return false;
}

function searchKeyPress(e, obj) {
    var code = (e.keyCode ? e.keyCode : e.which);
    if (code == 13) {
        var searchstr = $(obj).val();
        var company = $(obj).parent().children(".hidcompany").val();

        if (searchstr != "" && searchstr != "WWW." && searchstr != undefined) {
            window.location = "http://www." + company + "/DomainSearch.aspx?q=" + searchstr + "&t=CA,COM,NET,ORG,MOBI,INFO,BIZ,NAME,ASIA,EU,US,CN,CO,COM.AU,NET.AU,ORG.AU,ASN.AU,ID.AU";
        }
    }
}


// expanded block view
var expandedContent, modalLeft, leftOffset, modalTop, topOffset, clonedBlock;
$(document).ready(function() {
	$('.block')
	.click(function() {
		if( ($(this).find('.more-content').length != 0) && !($('#content').hasClass('filtered')) && !($(this).hasClass('expanded-block')) ) {
			// remove expanded block (if open)
			$('.expanded-block').remove();
			
			topOffset = $('#content').offset().top;
			modalTop = $(this).offset().top - topOffset;

			clonedBlock = $(this).clone(true);
			$(clonedBlock).css('top',modalTop);
			$(clonedBlock).addClass('expanded-block');
			$(clonedBlock).insertAfter(this);
		}
	})
	.hover(
		function() {
			if( ($(this).find('.more-content').length != 0) && !($('#content').hasClass('filtered')) && !($(this).parent('blocks').hasClass('full-view')) && !($(this).hasClass('expanded-block')) ) {
				$(this).addClass('block-hover');
			}
		},
		function() { $(this).removeClass('block-hover'); }
	);
	
	// shut it down!
	$('.close').live('click', function(e) {
		e.preventDefault();
		$('.expanded-block').remove();
    });


	$('#clocks').addClass('show');
    $('#clocks .clock').each(function () {
        var offset = parseInt($(this).children(".utc").html());

        $(this).setclock(offset);
    });
});

