﻿var timelineHeader = new Object();
var dayObject = new Object();
if (!window.console || !console.firebug) {
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
    window.console = {};
    for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() { };
}

function padLeft(totalChars, padWith) {
    num = this + "";
    padWith = (padWith) ? padWith : "0";
    if (num.length < totalChars) {
        while (num.length < totalChars) {
            num = padWith + num;
        }
    }

    if (num.length > totalChars) {
        num = num.substring((num.length - totalChars), totalChars);
    }
    return num;

}

//javascript Number object ini manipule edip padLeft function ı nını ekliyoruz
Number.prototype.padLeft = padLeft;
//javascript String object ini manipule edip padLeft function ı nını ekliyoruz
String.prototype.padLeft = padLeft;



function llmov(obj) {
    obj.className = obj.className == 'mm-item' ? 'mm-item-s' : 'mm-item';
}

function showModal(modalType) {
    toggleDiv('modal-positioner');
    document.getElementById('modal-cover').style.height = document.getElementById('home-footer-container').offsetTop - 220 + 'px';
    toggleDiv('modal-cover');
    //	focusDiv('modal-positioner');
}

function toggleDiv(id, isBlock) {
    if (!document.getElementById(id))
        return;

    if (document.getElementById(id).style.display == 'none') {
        if (isBlock)
            document.getElementById(id).style.display = 'block';
        else
            document.getElementById(id).style.display = 'inline';
    }
    else {
        document.getElementById(id).style.display = 'none';
    }
}

function focusDiv(id) {
    if (!document.getElementById(id))
        return;
    if (document.getElementById(id).style.display == 'none')
        return;
    else {
        document.getElementById(id).focus();
    }
}

function selDay(param, obj) {
    var objects = $get('DvTimeline').childNodes;
    for (var i = 0; i < objects.length; i++) {
        if (objects[i].attributes != null) {
            if (objects[i].id.indexOf(param + '_') == 0) {
                objects[i].className = obj.className == 'head-ac' ? 'ps' : 'ac';
            }

            if (obj.className == 'head-ac' && objects[i].id.indexOf('Time') == 0) {
                objects[i].className = 'head-ps';
            }
        }
    }
    repaintHeader(0);
}

function isEmpty(obj) {
    for (i in obj) { return false; }
    return true;
}

function selDayForJob(param, obj) {
    if (obj.className == 'head-ac') {
        delete dayObject[param];
        obj.className = 'head-ac';
    }
    else {
        dayObject[param] = param;
        obj.className = 'head-ps';
    }
}


function selTime(param, obj) {

    var objects = $get('DvTimeline').childNodes;

    for (var i = 0; i < objects.length; i++) {
        if (objects[i].attributes != null) {
            if (objects[i].id.indexOf('_' + param) > 0) {
                objects[i].className = obj.className == 'head-ac' ? 'ps' : 'ac';
            }
        }
    }

    if (obj.className == 'head-ac') {
        var dayObjects = $get('DvDays').childNodes;
        for (var i = 0; i < dayObjects.length; i++) {
            if (dayObjects[i].attributes != null)
                dayObjects[i].className = 'head-ps';
        }
    }
    repaintHeader(1);
}

function ttmov(obj) {
    var dayIndex = obj.id.split('_')[0];
    var timeIndex = parseFloat(obj.id.split('_')[1]);
    var dayObj = $get('Day' + dayIndex);
    var timeObj = $get('Time' + timeIndex);
    if (obj.className == 'ac') {
        dayObj.className = 'head-ps';
        timeObj.className = 'head-ps';
        obj.className = 'ps';
    }
    else {
        obj.className = 'ac';
        repaintMatrix(dayObj, timeObj, dayIndex, timeIndex)
    }

}

function repaintHeader(type) {
    var objects = $get('DvTimeline').childNodes;
    var timelineArray = new Array(7);
    var timelineStr = '';
    var index = 0;

    for (var i = 0; i < objects.length; i++) {
        if (objects[i].attributes != null) {
            if (objects[i].id.indexOf('_') > 0) {
                timelineStr += objects[i].className == 'ac' ? '1' : '0';
            }
        }
    }

    for (var i = 0; i < 7; i++) {
        timelineArray[i] = new Array(24);
        for (var j = 0; j < 24; j++) {
            timelineArray[i][j] = timelineStr[index];
            index++;
        }

    }
    var rowTotal = 0;
    if (type == 0) {
        for (var i = 0; i < 24; i++) {
            for (var j = 0; j < 7; j++) {
                rowTotal += parseInt(timelineArray[j][i]);
            }
            if (rowTotal == 7)
                $get('Time' + i).className = 'head-ac';
            rowTotal = 0;
        }
    }
    else if (type == 1) {
        for (var i = 0; i < 7; i++) {
            for (var j = 0; j < 24; j++) {
                rowTotal += parseInt(timelineArray[i][j]);
            }
            if (rowTotal == 24)
                $get('Day' + i).className = 'head-ac';
            rowTotal = 0;
        }
    }
}

function clearAll(obj) {
    for (var i = 0; i < 7; i++) {
        for (var j = 0; j < 24; j++) {
            $get(i + '_' + j.padLeft(2, '0')).className = 'ps';
            if (i == 0)
                $get('Time' + j).className = 'head-ps';
        }
        $get('Day' + i).className = 'head-ps';
    }
}

function changeAll(obj) {
    if (obj.className == 'head-ps') {
        obj.className = 'head-ac';
        for (var i = 0; i < 7; i++) {
            for (var j = 0; j < 24; j++) {
                $get(i + '_' + j.padLeft(2, '0')).className = 'ac';
                if (i == 0)
                    $get('Time' + j).className = 'head-ac';
            }
            $get('Day' + i).className = 'head-ac';
        }
    }
    else if (obj.className == 'head-ac') {
        obj.className = 'head-ps';
        for (var i = 0; i < 7; i++) {
            for (var j = 0; j < 24; j++) {
                $get(i + '_' + j.padLeft(2, '0')).className = 'ps';
                if (i == 0)
                    $get('Time' + j).className = 'head-ps';
            }
            $get('Day' + i).className = 'head-ps';
        }
    }
}

function repaintMatrix(dayObj, timeObj, dayIndex, timeIndex) {
    var dayTotal = 0;
    var timeTotal = 0;
    var objects = $get('DvTimeline').childNodes;
    var timelineArray = new Array(7);
    var index = 0;
    timelineStr = '';

    for (var i = 0; i < objects.length; i++) {
        if (objects[i].attributes != null) {
            if (objects[i].id.indexOf('_') > 0) {
                timelineStr += objects[i].className == 'ac' ? '1' : '0';
            }
        }
    }

    for (var i = 0; i < 7; i++) {
        timelineArray[i] = new Array(24);

        for (var j = 0; j < 24; j++) {
            timelineArray[i][j] = timelineStr[index];
            dayTotal += parseInt(timelineStr[index]);
            index++;
        }

        if (dayIndex == i) {
            dayObj.className = dayTotal == 24 ? 'head-ac' : 'head-ps';
        }
        dayTotal = 0;

    }

    for (var i = 0; i < 24; i++) {
        for (var j = 0; j < 7; j++) {
            timeTotal += parseInt(timelineArray[j][i]);
        }

        if (timeIndex == i)
            timeObj.className = timeTotal == 7 ? 'head-ac' : 'head-ps';

        timeTotal = 0;
    }

}
/* UPLOAD FUNCTIONS */

function startUpload() {
    var up = document.getElementById("flash_uploader");
    var upload_url = "/Photo/UploadHandler.aspx?upload=true";
    var append_vars = "";

    /*for (var i = 0; i < document.uploadData.length; i++) {
    current = document.uploadData.elements[i];
    var new_vars = "";
    if (current.type == "text" || current.type == "hidden") {
    new_vars = current.name + "=" + encodeURIComponent(current.value);
    }
    else if (current.type == "radio" || current.type == "checkbox") {
    if (current.checked) {
    new_vars = current.name + "=" + encodeURIComponent(current.value);
    }
    }*/

    var new_vars = document.getElementById('AlbumId').value;

    if (new_vars) {
        append_vars += "&AlbumId=" + new_vars.replace(/\./g, "%2E");
    }

    /* SET UPLOAD LIMIT */
    up.SetVariable("uploadURL", upload_url + append_vars);
}

function createUploadBar(containerId, barId, fileName) {
    //alert("containerId:" + containerId + ", barId:" + barId + ", fileName:" + fileName);
    document.getElementById(containerId).innerHTML = document.getElementById(containerId).innerHTML.replace('<div class="clr-thin"></div>', '');
    document.getElementById(containerId).innerHTML = document.getElementById(containerId).innerHTML +
					'<div id="ub' + barId + '" class="ub-container">' +
					'<div class="ub-text">' + fileName + '</div>' +
                    '<div id="ub-pers-' + barId + '" class="ub-pers">%0</div>' +
					'<div class="ub-prgrs-cont">' +
					'<div id="ub-prgrs-' + barId + '" class="ub-prgrs-bar"></div></div></div><div class="clr-thin"></div>';
}

function setProgressBarLength(pbId, percentage) {
    document.getElementById('ub-prgrs-' + pbId).style.width = percentage + '%';
    document.getElementById('ub-pers-' + pbId).innerHTML = '%' + percentage;
}

function removeProgressBars(count) {
    for (i = 1; i <= count; i++)
        document.getElementById('hello').removeChild(document.getElementById('ub' + i));
}

function HMovOn(x, y) {
    $get('Day' + x).style.color = 'black';
    $get('Time' + y).style.color = 'black';
    $get('Day' + x).style.fontWeight = 'bold';
    $get('Time' + y).style.fontWeight = 'bold';
}

function HMovOut(x, y) {
    $get('Day' + x).style.color = '#4D4D4D';
    $get('Time' + y).style.color = '#4D4D4D';
    $get('Day' + x).style.fontWeight = 'normal';
    $get('Time' + y).style.fontWeight = 'normal';
}


function GetLocation(key, value) {
    if (arguments[2])
        PageMethods.GetLocation(arguments[0], arguments[1], OnSucceededMini, OnFailedMini);
    else
        PageMethods.GetLocation(arguments[0], arguments[1], OnSucceeded, OnFailed);
}

function SendActivationMail(key, value) {
    PageMethods.SendActivationMail(key, value, OnSucceededActivationMail, OnFailedActivationMail);
}

function OnSucceededActivationMail(result, userContext, methodName) {
    alert("Adresinize aktivasyon postası gönderildi");
}

function OnFailedActivationMail(error, userContext, methodName) {
    alert("Adresinize aktivasyon postası gönderilirken hata oluştu");
}

function showModalInline(locationQueryString) {
    document.getElementById("DvMap").innerHTML = ' <div style="text-align:center;width:100%;height:280px;padding-top:60px;"><img  src="/Assets/img/Layout/location-loading.gif" /><br /><br /><img src="/Assets/img/Layout/sorgulama.gif" /></div>';
    var modalPopup = $find('MapModalPopupBehavior');
    modalPopup.show();
}

function GetLocationInline(key, value) {
    $get('SpLocation_' + value).innerHTML = "<b>Konum Bilgisi Sorgulanıyor...</b>";
    $get('SpLocation_' + value).style.backgroundImage = "url(" + IMG_PATH + "icons/loading_mini.gif)";
    PageMethods.GetLocation(key, value, OnSucceededInline, OnFailedInline);
}

function OnSucceededInline(result, userContext, methodName) {
    var locationQuery = Sys.Serialization.JavaScriptSerializer.deserialize(result);
    ChangeUserCredit(locationQuery.QueryingUser.CreditAmount);
    $get('SpLocation_' + locationQuery.QueriedUser.Guid).style.backgroundImage = "url(" + IMG_PATH + "Search/compass-m.gif)";
    $get('SpLocation_' + locationQuery.QueriedUser.Guid).innerHTML = '<a href="#d;"  style="font-weight:normal !important"  onclick="showModalInline(); showMapWithUser(' + locationQuery.DecimalXCoordinate + ',' + locationQuery.DecimalYCoordinate + ',\'' + locationQuery.QueriedUser.FirstName + '\',\'' + locationQuery.QueriedUser.LastName + '\',\'' + (locationQuery.Street == null ? '' : locationQuery.Street + ',') + (locationQuery.District==null?'':locationQuery.District)  + '  ' + locationQuery.Date + '\')" >Son lokasyon : <b>' + (locationQuery.Street == null ? '' : locationQuery.Street + ', ') + (locationQuery.District == null ? '' : locationQuery.District) + '</b>  (' + locationQuery.Date + ')</a>';

}

function OnFailedInline(error, userContext, methodName) {
    $get('SpLocation_' + error.get_message().split('|')[0]).style.backgroundImage = "url(" + IMG_PATH + "Search/compass-m.gif)";
    $get('SpLocation_' + error.get_message().split('|')[0]).innerHTML = error.get_message().split('|')[1].replace('.', '.');
}

function setJobStatus(key, value) {
    PageMethods.SetJobStatus(key, value, OnSucceeded, OnFailed);
    var modalPopup = $find('LQJModal');
    modalPopup.show();
}

function GetLocationHistory(key, value) {
    PageMethods.GetLocationHistory(arguments[0], arguments[1], OnSucceeded, OnFailed);
}

function ChangeUserCredit(creditAmount) {
    $get("LnkCredit").innerHTML = 'Yumurta: ' + creditAmount;
}

// Callback function invoked on successful 
// completion of the page method.
function OnSucceeded(result, userContext, methodName) {
    if (methodName == "GetLocation") {
        var locationQuery = Sys.Serialization.JavaScriptSerializer.deserialize(result);
        ChangeUserCredit(locationQuery.QueryingUser.CreditAmount);
        $get("DvLocTxt").innerHTML = (locationQuery.Street == null ? '' : locationQuery.Street + ', ') + (locationQuery.Locality==null?'':locationQuery.Locality  + ', ') + (locationQuery.District==null?'':locationQuery.District  + ', ') + (locationQuery.City==null?'' :locationQuery.City ) + '  ' + locationQuery.Date;
        showMap(locationQuery)
    }
//    else if (methodName == "SetJobStatus") {
//        alert('Succeeded');
//    }
}


// Callback function invoked on failure 
// of the page method.
function OnFailed(error, userContext, methodName) {

    if (error !== null) {
        var errorMessage = error.get_message().indexOf('|') > 0 ? error.get_message().split('|')[1] : error.get_message()
        $get("DvMap").innerHTML = '<h1>' + errorMessage + '</h1>';
    }
}

function OnSucceededMini(result, userContext, methodName) {
    if (methodName == "GetLocation") {
        var locationQuery = Sys.Serialization.JavaScriptSerializer.deserialize(result);
        ChangeUserCredit(locationQuery.QueryingUser.CreditAmount);
        $get("DvLocTxt").innerHTML = locationQuery.Street + ', ' + locationQuery.Locality + ', ' + locationQuery.District + ', ' + locationQuery.City + '  ' + locationQuery.Date ;
        showMap(locationQuery)
        eval('Isagretci_' + locationQuery.QueriedUser.Id).setLatLng(new GLatLng(locationQuery.DecimalXCoordinate, locationQuery.DecimalYCoordinate));
        map.panTo(new GLatLng(locationQuery.DecimalXCoordinate, locationQuery.DecimalYCoordinate), 16);
        document.getElementById('mtgt_' + locationQuery.QueriedUser.Id).style.zIndex = ++maxz;
        document.getElementById('set-center-' + locationQuery.QueriedUser.Id).onclick = function() { map.panTo(new GLatLng(locationQuery.DecimalXCoordinate, locationQuery.DecimalYCoordinate), 16); map.panTo(new GLatLng(locationQuery.DecimalXCoordinate, locationQuery.DecimalYCoordinate), 16); document.getElementById('mtgt_' + locationQuery.QueriedUser.Id).style.zIndex = ++maxz; };
    }
    else if (methodName == "SetJobStatus") {
        //alert('Failed');
    }
}

// Callback function invoked on failure 
// of the page method.
function OnFailedMini(error, userContext, methodName) {
    if (error !== null) {
        //alert("hata oluştu");
    }
}


function showModal(locationQueryString) {
    //    document.getElementById("DvMap").innerHTML = '<h1>Konum Bilgisi Sorgulanıyor ...</h1>';

    document.getElementById("DvMap").innerHTML = ' <div style="text-align:center;width:100%;height:280px;padding-top:60px;"><img  src="/Assets/img/Layout/location-loading.gif" /><br /><br /><img src="/Assets/img/Layout/sorgulama.gif" /></div>';

    var modalPopup = $find('MapModalPopupBehavior');
    modalPopup.show();
}


    
function hideModal(ev) {
    var modalPopup = $find('MapModalPopupBehavior');
    modalPopup.hide();
}

function showMapWithUser(DecimalXCoordinate, DecimalYCoordinate, FirstName, LastName, LocationString) {
    if (GBrowserIsCompatible()) {
        $get("DvLocTxt").innerHTML = LocationString;
        var mapGlobal = new GMap2($get("DvMap"));
        mapGlobal.setMapType(G_NORMAL_MAP);
        mapGlobal.addControl(new GLargeMapControl3D());
        mapGlobal.addControl(new GMapTypeControl());
        mapGlobal.setCenter(new GLatLng(DecimalXCoordinate, DecimalYCoordinate), 16);
        var Koordinat = new GLatLng(DecimalXCoordinate, DecimalYCoordinate);
        var baseIcon = new GIcon();
        baseIcon.iconSize = new GSize(100, 100);
        baseIcon.iconAnchor = new GPoint(50, 50);
        baseIcon.infoWindowAnchor = new GPoint(100, 55);
        baseIcon.image = IMG_PATH + "MapBg/loc-circle.png";
        markerGlobal = new GMarker(Koordinat, { icon: baseIcon, id: 'markerGlobal' });
        LastName = LastName == null ? '' : LastName;
        FirstName = FirstName == null ? '' : FirstName;

        GEvent.addListener(markerGlobal, 'click', function() {
            markerGlobal.openExtInfoWindow(
        				mapGlobal,
        				"extInfoWindow_coolBlues",
        				'<div id="loc-map-point"><div>' + FirstName + ' ' + LastName + '</div></div>',
        				 { beakOffset: 1 }
        				 );
        });

        try { mapGlobal.addOverlay(markerGlobal); } catch (err) { ; }

        try {
            markerGlobal.openExtInfoWindow(mapGlobal,
        			"extInfoWindow_coolBlues",
        			'<div id="loc-map-point"><div>' + FirstName + ' ' + LastName + '</div></div>',
        			 { beakOffset: 1 }
        			 );
        } catch (err) { ; }
        GEvent.addListener(mapGlobal, 'zoomend', function() { if (mapGlobal.getZoom() == 16) document.getElementById('mtgt_markerGlobal').style.visibility = 'visible'; else document.getElementById('mtgt_markerGlobal').style.visibility = 'hidden'; });
    }
}
function showMap(locationQuery) {
    if (GBrowserIsCompatible()) {

        var mapGlobal = new GMap2($get("DvMap"));
        mapGlobal.setMapType(G_NORMAL_MAP);
        mapGlobal.addControl(new GLargeMapControl3D());
        mapGlobal.addControl(new GMapTypeControl());
        mapGlobal.setCenter(new GLatLng(locationQuery.DecimalXCoordinate, locationQuery.DecimalYCoordinate), 16);
        var Koordinat = new GLatLng(locationQuery.DecimalXCoordinate, locationQuery.DecimalYCoordinate);
        var baseIcon = new GIcon();
        baseIcon.iconSize = new GSize(100, 100);
        baseIcon.iconAnchor = new GPoint(50, 50);
        baseIcon.infoWindowAnchor = new GPoint(100, 55);
        baseIcon.image = IMG_PATH + "MapBg/loc-circle.png";
        markerGlobal = new GMarker(Koordinat, { icon: baseIcon, id: 'markerGlobal' });
        locationQuery.QueriedUser.LastName = locationQuery.QueriedUser.LastName == null ? '' : locationQuery.QueriedUser.LastName;
        locationQuery.QueriedUser.FirstName = locationQuery.QueriedUser.FirstName == null ? '' : locationQuery.QueriedUser.FirstName;

        GEvent.addListener(markerGlobal, 'click', function() {
            markerGlobal.openExtInfoWindow(
        				mapGlobal,
        				"extInfoWindow_coolBlues",
        				'<div id="loc-map-point"><div>' + locationQuery.QueriedUser.FirstName + ' ' + locationQuery.QueriedUser.LastName + '  ' + locationQuery.Date + '</div></div>',
        				 { beakOffset: 1 }
        				 );
        });

        try { mapGlobal.addOverlay(markerGlobal); } catch (err) { ; }

        try {
            markerGlobal.openExtInfoWindow(mapGlobal,
        			"extInfoWindow_coolBlues",
        			'<div id="loc-map-point"><div>' + locationQuery.QueriedUser.FirstName + ' ' + locationQuery.QueriedUser.LastName + '</div></div>',
        			 { beakOffset: 1 }
        			 );
        } catch (err) { ; }
        GEvent.addListener(mapGlobal, 'zoomend', function() { if (mapGlobal.getZoom() == 16) document.getElementById('mtgt_markerGlobal').style.visibility = 'visible'; else document.getElementById('mtgt_markerGlobal').style.visibility = 'hidden'; });


        /* METHODS FOR MAP ON BACKGROUND */
        var avatarPath = '';
        if ($get('spn-loc-txt') != null) {
            $get('spn-loc-txt').innerHTML = locationQuery.Date + ' <br/> ' + locationQuery.Street + ',' + locationQuery.Locality + ', ' + locationQuery.District;
        }
        if (currentUserGuid == locationQuery.QueriedUser.Guid) {

            avatarPath = locationQuery.QueriedUser.UserAvatarGuid != null ? findFullPath(locationQuery.QueriedUser.UserAvatarGuid) + "_Thumbnail1.jpg" : IMG_PATH + "Layout/p-pict-m-50x50.gif";


            try {
                currentUserMarker.setLatLng(new GLatLng(locationQuery.DecimalXCoordinate, locationQuery.DecimalYCoordinate));
                currentUserMarker.openExtInfoWindow(map, "extInfoWindow_coolBlues", '<div id="loc-map-point"><img class="thmb" src="/Assets/img/Mail/spacer.gif" style="background-image: url(' + avatarPath + ');" /><div>' + locationQuery.QueriedUser.FirstName + ' ' + locationQuery.QueriedUser.LastName + '</div></div>', { beakOffset: 1 });
            }
            catch (err) {
            }

            try {
                marker5.setLatLng(new GLatLng(locationQuery.DecimalXCoordinate, locationQuery.DecimalYCoordinate));
                marker5.openExtInfoWindow(map, "extInfoWindow_coolBlues", '<div id="loc-map-point"><img class="thmb" src="/Assets/img/Mail/spacer.gif" style="background-image: url(' + avatarPath + ');" /><div>' + locationQuery.QueriedUser.FirstName + ' ' + locationQuery.QueriedUser.LastName + '</div></div>', { beakOffset: 1 });
            }
            catch (err) {
            }

            /* 1 kerede oturmuyo ondan iki kez yapıyoruz. */
            try {

                map.panTo(new GLatLng(locationQuery.DecimalXCoordinate, locationQuery.DecimalYCoordinate), 16);
                map.panTo(new GLatLng(locationQuery.DecimalXCoordinate, locationQuery.DecimalYCoordinate), 16);
            }
            catch (err) {
            }
        }
    }
}
    
    
    
function showNotification(notHeader, notMesg) {

    $('#notification').jGrowl(notMesg, {
        theme: 'flora',
        header: notHeader,
        sticky: true,
        closer: false
    });

}

function doClick(buttonName, e) {
    var key;
    if (window.event)
        key = window.event.keyCode;
    else
        key = e.which;
    if (key == 13) {
        var btn = document.getElementById(buttonName);
        if (btn != null) {
            btn.click();
            event.keyCode = 0
        }
    }
}

function highLight(obj) {
    var HIGH_COLOR = "#AAE1A7";
    if (obj.style.backgroundColor == "") {
        obj.style.backgroundColor = HIGH_COLOR;
    } else {
        obj.style.backgroundColor = "";
    }
}
function findFullPath(photoGuid) 
{
    photoGuid = photoGuid == null ? "/Assets/img/Layout/photo-album.gif" : photoGuid;
    imgPath += photoGuid.substring(0, 2) + "/" + photoGuid.substring(2, 4) + "/" + photoGuid;
    return imgPath;
}

StringBuilder = function() {
    this._strings = [];
    this.append = function(s) { this._strings.push(s); };
    this.toString = function() { return this._strings.join(''); };
    this.appendFormat = function(pattern) {
        var args = arguments;
        var s = pattern.replace(/\{(\d+)\}/g,
                function(pattern, index) {
                    return args[parseInt(index) + 1].toString();
                });
        this._strings.push(s);
    };
    return this;
};
