﻿var MotoRAZR = { };




/*
    ※ 스크랩 관련..!
*/
(function($){

    var methods = {
        scrapToTwitter: function(){
            var msg = "아찔하게 얇다. RAZR THIN. 7.1mm 혁신적인 초슬림 스마트폰 모토로라 레이저를 확인하세요. http://" + document.domain;
            methods.openWithScroll("http://twitter.com/home?status=" + encodeURIComponent(msg), "TwitterScrap", 1000, 600);

            MotoRAZR.log("MotoRAZR.scrapToTwitter();");
        },

        scrapToFacebook: function(){
            var name = "아찔하게 얇다. RAZR THIN. 7.1mm 혁신적인 초슬림 스마트폰 모토로라 레이저를 확인하세요.";
            var caption = "http://" + document.domain;
            var description = "아찔하게 얇다. RAZR THIN. 7.1mm 혁신적인 초슬림 스마트폰 모토로라 레이저를 확인하세요. http://" + document.domain;
            var picture = "http://" + document.domain + "/images/motospyder.jpg";
            var redirectUrl = "http://www.razr.co.kr/FacebookCallback.ashx";
            var url = "http://www.facebook.com/dialog/feed?app_id=130031320406803&name=" + encodeURIComponent(name) + "&caption=" + encodeURIComponent(caption) + "&description=" + encodeURIComponent(description) + "&picture=" + picture + "&link=" + encodeURIComponent(redirectUrl) + "&redirect_uri=" + encodeURIComponent(redirectUrl);

            methods.openWithScroll(url, "FacebookShare", 1000, 600);

            MotoRAZR.log("MotoRAZR.scrapToFacebook();");
        },

        scrapToMe2DAY: function(){
            var msg = "아찔하게 얇다. RAZR THIN. 7.1mm 혁신적인 초슬림 스마트폰 모토로라 레이저를 확인하세요. http://" + document.domain;
            methods.openWithScroll("http://me2day.net/posts/new?new_post[body]=" + encodeURIComponent(msg), "Me2DAYScrap", 1000, 600);

            MotoRAZR.log("MotoRAZR.scrapToMe2DAY();");
        },

        scrapToYozm: function(){
            var msg = "아찔하게 얇다. RAZR THIN. 7.1mm 혁신적인 초슬림 스마트폰 모토로라 레이저를 확인하세요. http://" + document.domain;
            methods.openWithScroll("http://yozm.daum.net/home?m=" + encodeURIComponent(msg), "YozmShare", 1000, 600);

            MotoRAZR.log("MotoRAZR.scrapToYozm();");
        },


        openWithScroll: function(url, windowName, width, height){
            var left = Math.ceil((screen.width - width) / 2);
            var top = Math.ceil((screen.height - height) / 2);
            var params = "width=" + width + ", height=" + height + ", left=" + left + ", top=" + top + ", resizable=yes";

            var popup = window.open(url, windowName, params);

            if ( popup )
                popup.focus();
        }
    };


    $.extend(MotoRAZR, methods);

})( jQuery );



/*
    ※ 공통함수관련..!
*/
(function($){

    var methods = {
        log: function( msg ){
            try{
                console.log( "[" + (new Date()) + "] " + msg );

            } catch(e){ }

        },

        trace: function(code){
            $.ajax({ url: "/process/SaveTrace.ashx", type: "POST", async: false, data: ("code=" + code) });

            try{
                _gaq.push(['_trackEvent', code, '/']);
            } catch(e){ };
        }
    };


    $.extend(MotoRAZR, methods);

})( jQuery );
