// JavaScript Document
$lavinclude = function(file,tag) {
	if(file){
		if(tag == null || tag == undefined){
			tag = "head";
		}
		var th = document.getElementsByTagName(tag)[0];
		var s = document.createElement('script');
		s.setAttribute('language','javascript');
		s.setAttribute('type','text/javascript');
		s.setAttribute('src',file);
		th.appendChild(s);	
	}
}
trace = $lavlog = function(msg){
	if(msg == null || msg == undefined) return;
	try{
		console.log(msg);
	}catch(err){
		//alert(msg);
	}
}
$lavdelegate = function(scope, method){
	if(method){
		return function() { 
       		return method.apply(scope,arguments); 
    	}
	}
}
$lavheight = function (element) {
    var myElement = element;
    if (element.height) {
        var myHeight = element.height();
    } else {
        var myHeight = $(myElement).height();
    }
    myHeight += parseInt($(myElement).css("marginTop"));
    myHeight += parseInt($(myElement).css("marginBottom"));
    myHeight += parseInt($(myElement).css("paddingTop"));
    myHeight += parseInt($(myElement).css("paddingBottom"));
    return myHeight;
}
$typetext = function (obj, on, text) {
    if (on == true) {
        if (obj.value == text) {
            obj.value = "";
        }
    } else {
        if (obj.value == "") {
            obj.value = text;
        }
    }
}

$printPage = function () {
    window.print();
}
$shareFB = function () {
    var myurl = "http://www.facebook.com/sharer/sharer.php?u=" + location.href;
    var regex = /(#)/gi;
    myurl = myurl.replace(regex, "%23");
    window.open(myurl);
}
$shareTW = function () {
    var myurl = "http://twitter.com/intent/tweet?text=&url=" + location.href + "&via=lavendersydney";
    var regex = /(#)/gi;
    myurl = myurl.replace(regex, "%23");
    window.open(myurl);
}
$isIDevice = function(){
	var ua = navigator.userAgent
	return /iPad/i.test(ua) || /iPhone OS 3_1_2/i.test(ua) || /iPhone OS 3_2_2/i.test(ua);
	
}

