﻿function dumpObject(obj, details) {
    out = "";

    for (i in obj) {
        if (details) {
            out += i + ": " + obj[i] + ", ";
        }
        else
            out += i + ", ";
    }
    alert(out);
}

function getUrlParam(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}

function getCategory_(categoryId, collapse) {
    if (collapse)
        document.location = "StylesList.aspx?categoryId=" + categoryId + "&collapse=1";
    else
        document.location = "StylesList.aspx?categoryId=" + categoryId;
}

function getCategory(categoryId) {
    document.location = "StylesList.aspx?categoryId=" + categoryId;
}

function getStyle(categoryId, styleCode) {
    document.location = "ViewStyle.aspx?categoryId="+ categoryId +"&styleCode=" + styleCode;
}

function getProduct(categoryId, productId) {
    document.location = "ViewStyle.aspx?categoryId=" + categoryId + "&productId=" + productId;
}

function filterBy(categoryId, gender, page) {
    if (!isNaN(categoryId)) {
        field = "categoryId";
    }
    else {
        field = "search";
    }

    finalUrl = "/StylesList/" + field + "=" + categoryId + "&gender=" + gender;

    if (page == "showAll")
        finalUrl += "&page=showAll";

    document.location = finalUrl;
}

function styleFilterBy(categoryId, gender, styleCode) {
    finalUrl = "/ViewStyle/" + categoryId + "/" + styleCode + "/" + gender;
    document.location = finalUrl;
}

function submitSearch(eventCode, value) {
    if (eventCode == 13) {
        document.location = "/StylesList.aspx?search=" + value;
        return false;
    }
}

function searchOnFocus(obj) {
    if (obj.value == "search...")
        obj.value = "";
}

function searchOnBlur(obj) {
    if (obj.value == "")
        obj.value = "search...";
}

function subscribeNewletter() {

}

function collapseMainMenuItem(categoryId, styleName) {
    finalUrl = "http://"+ window.location.host + "/StylesList/" + categoryId + "/" + styleName;
    window.location = finalUrl;
}

function startWizard() {
    user_email = document.getElementById("user_email");
    if (user_email.value != "") {
        
    }
}

var count = 1;
var seconds = 10;

function changeTestimonials() {
	try {
		//alert("#testimonials" + count);
		var item = $("#testimonials" + count);
		
		if($("#ctl00_ctl00_MainMenu1_defaultTestimonial").length == 0)
			testmonialBox = $("#ctl00_MainMenu1_defaultTestimonial");
		else
			testmonialBox = $("#ctl00_ctl00_MainMenu1_defaultTestimonial");

		if (item.html() != null) {
			testmonialBox.delay(seconds * 1000).fadeOut("fast", function () {
				testmonialBox.html(item.html());
				testmonialBox.fadeIn("slow", function () {
					count++;
					changeTestimonials();
				});
			});
		}
		else {
			count = 1;
			changeTestimonials();
		}
	}
	catch (e)
	{
		alert("Error:" + e);
	}
}
