$(document).ready(function(){
    $('.boxy').boxy();
    
    $('a.add-new-site').qtip({
	content: "This is the url which is placed as link at the partner's sites.",
	style: {
	    tip: 'bottomLeft',
	    name: 'cream',
	    border: {
		width: 7,
		radius: 5
	    }
	},
	position: {
	    corner: {
	        target: 'topRight',
	        tooltip: 'bottomLeft'
	    }
	}
    })
    
    $('a.add-partner-site').qtip({
	content: "This is the url where your link is placed. Bear in mind that if you insert a domain, but the link is in a sub page, the status will be MISSING!",
	style: {
	    tip: 'bottomLeft',
	    name: 'cream',
	    border: {
		width: 7,
		radius: 5
	    }
	},
	position: {
	    corner: {
	        target: 'topRight',
	        tooltip: 'bottomLeft'
	    }
	}
    })
    
    
    //Menu select active
    $('#menu a').each(function(){
	if($(this).attr('href') == whereami){
	    $(this).addClass('active')
	}
    })
    
    $('input#DemoSite').qtip(
	{
	    show: {when: {event: 'focus'}, effect: {type: 'fade', length: 500}},
            hide: {when: {event: 'blur'}},

	    content: 'Enter the address of your site. Bear in mind that this should be the link url in your partner\'s site. <br/>Example: <u>http://my-site.com</u>',
	    style: { 
		fontSize: '100%',
		width: 300,
		padding: 5,
		/*background: '#A2D959',*/
		color: 'black',
		textAlign: 'left',
		border: {
		    width: 7,
		    radius: 5
		    /*color: '#A2D959'*/
		},
		tip: 'bottomLeft',
		name: 'cream' // Inherit the rest of the attributes from the preset dark style
	    },
	    position: {
		corner: {
		    target: 'topRight',
		    tooltip: 'bottomLeft'
		}
	    }
	}
    )
    
    $('input#DemoPartner').qtip(
	{
	    show: {when: {event: 'focus'}, effect: {type: 'fade', length: 500}},
            hide: {when: {event: 'blur'}},

	    content: 'This is the address of the site, which contains the link to your site. <br/>Example: <u>http://my-partner.com</u>',
	    style: { 
		fontSize: '100%',
		width: 300,
		padding: 5,
		/*background: '#A2D959',*/
		color: 'black',
		textAlign: 'left',
		border: {
		    width: 7,
		    radius: 5
		    /*color: '#A2D959'*/
		},
		tip: 'bottomLeft',
		name: 'cream' // Inherit the rest of the attributes from the preset dark style
	    },
	    position: {
		corner: {
		    target: 'topRight',
		    tooltip: 'bottomLeft'
		}
	    }
	}
    )
    
    $('#demoForm .submit input').live('click', function(){
	$('#demoForm div.submit').html('<div class="demo-loading"></div>');
	$.post('/demo', $('#demoForm').serialize(), function(resp){$('#content').html(resp)});
	return false;
    })
});
function check_link(element){
    $(element).parent().prev().html('<img src="/img/3-0.gif" alt="loading" />');
    
    $.get($(element).attr('href'), null, function(responceText){
	result = responceText.split('^');
	$(element).parent().prev().prev().html(result[1]);
	$(element).parent().prev().html(result[0]);
    });
    return false;
}