﻿String.prototype.trim = function()
{
    return this.replace(/(^\s+)|(\s+$)/g, ""); 
}

EmptyGUID = "00000000-0000-0000-0000-000000000000"


$(function() {
    //Turn off ajax cache in IE7-8
    $.ajaxSetup({
        cache: false
    }); 
    var html = document.documentElement.clientHeight;
    var container = document.getElementById("hgt100").offsetHeight;
    if (html > container)
        $(".pagebg-l").toggleClass("pagebg-l-height");

	$("a.homeManifsto").click(function() {
        if ($("div#contentLoadManifesto").is(":empty")) {
            $.ajax({
                url: "/ajaxcontents/manifesto.html",
                cache: false,
                success: function(html) { $("div#contentLoadManifesto").html(html) }
            });
        }
    })
});
$(function() {
    $("#openMgx, #openStpByStp, #openManifestoOvrlay, #openVatOverlay").overlay({ expose: '#555555', effect: 'apple', top: "center" });
    $("#blenderPlug, #rhinoPlug, #rhinoPlugBanner, #openDwnldPlugin, #googlePlug").overlay({ expose: '#555555', effect: 'default', top: "center" });
    $("#TabLoadMaterial, #TabLoadSurface, #TabLoadColor").overlay({ expose: '#555555', effect: 'apple', top: '10%' })

    $("a#openMgx").click(function() {
        $("div#contentLoad").load("/ajaxcontents/mgx.html");
    });

    $("a#openStpByStp").click(function() {
        $("div#contentLoadStpByStp").load("/ajaxcontents/step-by-step.html");
    });

    $("a#openDwnldPlugin, #blenderPlug, #rhinoPlug, #rhinoPlugBanner, #googlePlug").click(function() {
        var initIndex = $(this).attr("id")
        $("div#contentLoadDwnldPlugin").load("/ajaxcontents/download-plugin.html", function() {
            var a = $("#overlayDwnldPlugin a");
            for (var i = 0; i < a.length; i++) {//IE7 bug remove url before #
                if (a[i].href.indexOf('#') > 0)
                    a[i].href = a[i].href.substring(a[i].href.indexOf('#'));
            }
            if (initIndex == "openDwnldPlugin") {
                $("#tabPlugin").tabs("#panesPlugin > div", { initialIndex: 0 });
            } else if (initIndex == "blenderPlug") {
                $("#tabPlugin").tabs("#panesPlugin > div", { initialIndex: 1 });
            } else if (initIndex == "rhinoPlug" || initIndex == "rhinoPlugBanner") {
                $("#tabPlugin").tabs("#panesPlugin > div", { initialIndex: 2 });
            } else {
                $("#tabPlugin").tabs("#panesPlugin > div", { initialIndex: 2 });
            }
        });
    });
    $("#overlayDwnldPlugin div.close").click(function() {
        var url = location.href;
        if (url.indexOf("#") > 0) {
            var pos = url.indexOf("#");
            var newUrl = url.slice(0, pos);
            location.href = newUrl;

        }

    });
});
$(function() {

    $("#postUploadform").click(function(e) {
        document.frmCreateYourOwnLamp.submit();
    });

});
function redirectTo(to) {
    //debugger
    window.location = to
}

function getFileNameFromUrl(data) {
    return data.match(/(.*)[\/\\]([^\/\\]+)\.\w+$/)[2];
}
$(function(){
    function topMenuDropDown(){
	 	this.showDropDown = function(jElemTriger){
			if(jElemTriger.is(":hidden"))
				jElemTriger.show();
		 }
		this.closeDropDown = function(jElemTriger){
				jElemTriger.hide();
			}
	}
	var dropDownObj = new topMenuDropDown();
	$("#dropTrig1, #dropTrig2").mouseover(function(e){
			var elm = $(this).contents().filter(".subItemsBox");
			dropDownObj.showDropDown(elm);
			}).mouseout(function(){
				var elm1 = $(this).contents().filter(".subItemsBox");
				dropDownObj.closeDropDown(elm1);
				});
});
