function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_advOpenBrWindow(theURL,winName,features,orgName) {
  var remote = open(theURL, winName, features);
  if (remote.opener == null) // if something went wrong
    remote.opener = window;
  remote.opener.name = orgName;
  return remote;
}
//clearing input fields start
function ClearInput(value, id){
var input = document.getElementById(id);
	if(value == input.value){
		input.value = '';
	}
	else{
		input.value = input.value;
	}
}
//clearing input fields end
//popUp div start
var amID = "blank";
function showMe(containerId){
	if(amID != "blank"){
		hideMe(amID);	
	}
	amID = containerId;
	showContainer(containerId);
}
function showContainer(containerId){
	obj = MM_findObj(containerId);
	if (!obj) return;
	obj.style.display = 'block';
}
function hideMe(containerId){
	obj2 = MM_findObj(containerId)
	if (!obj2) return;
	obj2.style.display = 'none';
}
//popUp div end
//fake file picker start
function copyText(){
	copyText1('realFile1','fakeFile1');
}
function copyText1(orgin, destination){
	txt1 = MM_findObj(orgin);
	txt2 = MM_findObj(destination);
	txt2.value = txt1.value;
}
//fake file picker end
//change that class start
function changeClass(Id, className){
	obj = MM_findObj(Id);
	obj.className = className;
}
//change that class end

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


// ------------------------------------------------------------------------------------
function _showLightbox(vidId) {
    $('div.lightboxOverlay').css('display', 'block');
    $('div.lightboxContentWrap').css('display', 'block');

    var sVideoCode = ""
    sVideoCode = sVideoCode + "<object width='500' height='405'>";
    sVideoCode = sVideoCode + "<param name='movie' value='http://www.youtube.com/v/";
    sVideoCode = sVideoCode + vidId;
    sVideoCode = sVideoCode + "&hl=en&fs=1&rel=0'></param>";
	sVideoCode = sVideoCode + "<param name='allowFullScreen' value='true'></param>";
	sVideoCode = sVideoCode + "<param name='allowscriptaccess' value='always'></param>";
	sVideoCode = sVideoCode + "<embed src='http://www.youtube.com/v/";
    sVideoCode = sVideoCode + vidId;
	sVideoCode = sVideoCode + "&hl=en&fs=1&rel=0' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='500' height='405'></embed>";
	sVideoCode = sVideoCode + "</object>";

	$('#lightboxContent').append(sVideoCode);

	$('div.lightboxContentWrap').css('top', ($(window).height() - $('div.lightboxContentWrap').height()) / 2).css('position', 'fixed').css('-positio\n', 'absolute');
    
};
// ------------------------------------------------------------------------------------
function _destroyLightbox() {
    $('div.lightboxOverlay').css('display', 'none');
    $('div.lightboxContentWrap').css('display', 'none');

    $('#lightboxContent object, #lightboxContent embed').remove();
};
$(document).ready(function() {
    $('.fbShare').click(function() {
        var url = 'http://www.facebook.com/sharer.php?u=' + encodeURIComponent(window.location);
        if ($(this).attr('href') != '#')
            url = 'http://www.facebook.com/sharer.php?u=' + encodeURIComponent($(this).attr('href'));
        window.open(url, 'facebook', 'width=600,height=400,resizable=1');

        if ($(this).prev().hasClass('recipeId') &&
            $(this).prev().html() != '') {
            var recipeId = $(this).prev().html();
            $.post($('#hdSiteRoot').val() + "Handlers/ReportHandler.ashx", { recipeid: recipeId }, function(data) {
            });
        }

        return false;
    });
	
	$('a.tweet').click(function () {
        var url = 'http://twitter.com/share?url=' + encodeURIComponent(window.location);
        if ($(this).attr('href') != '#')
            url = 'http://twitter.com/share?url=' + encodeURIComponent($(this).attr('href'));
        window.open(url, 'twitter', 'width=500,height=300');
        return false;

        if ($(this).prev().hasClass('recipeId') &&
            $(this).prev().html() != '') {
            var recipeId = $(this).prev().html();
            $.post($('#hdSiteRoot').val() + "Handlers/ReportHandler.ashx", { recipeid: recipeId }, function(data) {
            });
        }
		
		return false;
    });
});
