//jquery.json.js
/*
    based on
    http://www.JSON.org/json2.js
    2008-11-19
    
    jQuery plugin info:
    @author  Jim Dalton (jim.dalton@furrybrains.com)
    @date    1/15/2009
    @version 1.0
    
    Comments below were modified to reflect usage in the context of jQuery. Otherwise
    these comments are identical to the source library.

    Public Domain.

    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.

    See http://www.JSON.org/js.html

    This file creates a global JSON object containing two methods: jQuery.jSONToString
    and jQuery.toJSON.

        jQuery.jSONToString(value, replacer, space)
            value       any JavaScript value, usually an object or array.

            replacer    an optional parameter that determines how object
                        values are stringified for objects. It can be a
                        function or an array of strings.

            space       an optional parameter that specifies the indentation
                        of nested structures. If it is omitted, the text will
                        be packed without extra whitespace. If it is a number,
                        it will specify the number of spaces to indent at each
                        level. If it is a string (such as '\t' or '&nbsp;'),
                        it contains the characters used to indent at each level.
            
            This method produces a JSON text from a JavaScript value.

            When an object value is found, if the object contains a toJSON
            method, its toJSON method will be called and the result will be
            stringified. A toJSON method does not serialize: it returns the
            value represented by the name/value pair that should be serialized,
            or undefined if nothing should be serialized. The toJSON method
            will be passed the key associated with the value, and this will be
            bound to the object holding the key.

            For example, this would serialize Dates as ISO strings.

                Date.prototype.toJSON = function (key) {
                    function f(n) {
                        // Format integers to have at least two digits.
                        return n < 10 ? '0' + n : n;
                    }

                    return this.getUTCFullYear()   + '-' +
                         f(this.getUTCMonth() + 1) + '-' +
                         f(this.getUTCDate())      + 'T' +
                         f(this.getUTCHours())     + ':' +
                         f(this.getUTCMinutes())   + ':' +
                         f(this.getUTCSeconds())   + 'Z';
                };

            You can provide an optional replacer method. It will be passed the
            key and value of each member, with this bound to the containing
            object. The value that is returned from your method will be
            serialized. If your method returns undefined, then the member will
            be excluded from the serialization.

            If the replacer parameter is an array of strings, then it will be
            used to select the members to be serialized. It filters the results
            such that only members with keys listed in the replacer array are
            stringified.

            Values that do not have JSON representations, such as undefined or
            functions, will not be serialized. Such values in objects will be
            dropped; in arrays they will be replaced with null. You can use
            a replacer function to replace those with JSON values.
            JSON.stringify(undefined) returns undefined.

            The optional space parameter produces a stringification of the
            value that is filled with line breaks and indentation to make it
            easier to read.

            If the space parameter is a non-empty string, then that string will
            be used for indentation. If the space parameter is a number, then
            the indentation will be that many spaces.

            Example:

            text = jQuery.jSONToString(['e', {pluribus: 'unum'}]);
            // text is '["e",{"pluribus":"unum"}]'


            text = jQuery.jSONToString(['e', {pluribus: 'unum'}], null, '\t');
            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'

            text = jQuery.jSONToString([new Date()], function (key, value) {
                return this[key] instanceof Date ?
                    'Date(' + this[key] + ')' : value;
            });
            // text is '["Date(---current time---)"]'


        jQuery.toJSON(text, reviver)
            This method parses a JSON text to produce an object or array.
            It can throw a SyntaxError exception.

            The optional reviver parameter is a function that can filter and
            transform the results. It receives each of the keys and values,
            and its return value is used instead of the original value.
            If it returns what it received, then the structure is not modified.
            If it returns undefined then the member is deleted.

            Example:

            // Parse the text. Values that look like ISO date strings will
            // be converted to Date objects.

            myData = jQuery.toJSON(text, function (key, value) {
                var a;
                if (typeof value === 'string') {
                    a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
                    if (a) {
                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
                            +a[5], +a[6]));
                    }
                }
                return value;
            });

            myData = jQuery.toJSON('["Date(09/09/2001)"]', function (key, value) {
                var d;
                if (typeof value === 'string' &&
                        value.slice(0, 5) === 'Date(' &&
                        value.slice(-1) === ')') {
                    d = new Date(value.slice(5, -1));
                    if (d) {
                        return d;
                    }
                }
                return value;
            });


    This is a reference implementation. You are free to copy, modify, or
    redistribute.

    This code should be minified before deployment.
    See http://javascript.crockford.com/jsmin.html

    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
    NOT CONTROL.
*/
;(function($) {
    if (!this.JSON) {
        this.JSON = {};
    }
    /*
		    http://www.JSON.org/json2.js
		    2009-09-29
		
		    Public Domain.
		
		    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
		
		    See http://www.JSON.org/js.html
		
		
		    This code should be minified before deployment.
		    See http://javascript.crockford.com/jsmin.html
		
		    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
		    NOT CONTROL.
		
		
		    This file creates a global JSON object containing two methods: stringify
		    and parse.
		
		        JSON.stringify(value, replacer, space)
		            value       any JavaScript value, usually an object or array.
		
		            replacer    an optional parameter that determines how object
		                        values are stringified for objects. It can be a
		                        function or an array of strings.
		
		            space       an optional parameter that specifies the indentation
		                        of nested structures. If it is omitted, the text will
		                        be packed without extra whitespace. If it is a number,
		                        it will specify the number of spaces to indent at each
		                        level. If it is a string (such as '\t' or '&nbsp;'),
		                        it contains the characters used to indent at each level.
		
		            This method produces a JSON text from a JavaScript value.
		
		            When an object value is found, if the object contains a toJSON
		            method, its toJSON method will be called and the result will be
		            stringified. A toJSON method does not serialize: it returns the
		            value represented by the name/value pair that should be serialized,
		            or undefined if nothing should be serialized. The toJSON method
		            will be passed the key associated with the value, and this will be
		            bound to the value
		
		            For example, this would serialize Dates as ISO strings.
		
		                Date.prototype.toJSON = function (key) {
		                    function f(n) {
		                        // Format integers to have at least two digits.
		                        return n < 10 ? '0' + n : n;
		                    }
		
		                    return this.getUTCFullYear()   + '-' +
		                         f(this.getUTCMonth() + 1) + '-' +
		                         f(this.getUTCDate())      + 'T' +
		                         f(this.getUTCHours())     + ':' +
		                         f(this.getUTCMinutes())   + ':' +
		                         f(this.getUTCSeconds())   + 'Z';
		                };
		
		            You can provide an optional replacer method. It will be passed the
		            key and value of each member, with this bound to the containing
		            object. The value that is returned from your method will be
		            serialized. If your method returns undefined, then the member will
		            be excluded from the serialization.
		
		            If the replacer parameter is an array of strings, then it will be
		            used to select the members to be serialized. It filters the results
		            such that only members with keys listed in the replacer array are
		            stringified.
		
		            Values that do not have JSON representations, such as undefined or
		            functions, will not be serialized. Such values in objects will be
		            dropped; in arrays they will be replaced with null. You can use
		            a replacer function to replace those with JSON values.
		            JSON.stringify(undefined) returns undefined.
		
		            The optional space parameter produces a stringification of the
		            value that is filled with line breaks and indentation to make it
		            easier to read.
		
		            If the space parameter is a non-empty string, then that string will
		            be used for indentation. If the space parameter is a number, then
		            the indentation will be that many spaces.
		
		            Example:
		
		            text = JSON.stringify(['e', {pluribus: 'unum'}]);
		            // text is '["e",{"pluribus":"unum"}]'
		
		
		            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
		            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
		
		            text = JSON.stringify([new Date()], function (key, value) {
		                return this[key] instanceof Date ?
		                    'Date(' + this[key] + ')' : value;
		            });
		            // text is '["Date(---current time---)"]'
		
		
		        JSON.parse(text, reviver)
		            This method parses a JSON text to produce an object or array.
		            It can throw a SyntaxError exception.
		
		            The optional reviver parameter is a function that can filter and
		            transform the results. It receives each of the keys and values,
		            and its return value is used instead of the original value.
		            If it returns what it received, then the structure is not modified.
		            If it returns undefined then the member is deleted.
		
		            Example:
		
		            // Parse the text. Values that look like ISO date strings will
		            // be converted to Date objects.
		
		            myData = JSON.parse(text, function (key, value) {
		                var a;
		                if (typeof value === 'string') {
		                    a =
		/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
		                    if (a) {
		                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
		                            +a[5], +a[6]));
		                    }
		                }
		                return value;
		            });
		
		            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
		                var d;
		                if (typeof value === 'string' &&
		                        value.slice(0, 5) === 'Date(' &&
		                        value.slice(-1) === ')') {
		                    d = new Date(value.slice(5, -1));
		                    if (d) {
		                        return d;
		                    }
		                }
		                return value;
		            });
		
		
		    This is a reference implementation. You are free to copy, modify, or
		    redistribute.
		*/
		
		/*jslint evil: true, strict: false */
		
		/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
		    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
		    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
		    lastIndex, length, parse, prototype, push, replace, slice, stringify,
		    test, toJSON, toString, valueOf
		*/
		
		
		// Create a JSON object only if one does not already exist. We create the
		// methods in a closure to avoid creating global variables.
		
		if (!this.JSON) {
		    this.JSON = {};
		}
		
		(function () {
		
		    function f(n) {
		        // Format integers to have at least two digits.
		        return n < 10 ? '0' + n : n;
		    }
		
		    if (typeof Date.prototype.toJSON !== 'function') {
		
		        Date.prototype.toJSON = function (key) {
		
		            return isFinite(this.valueOf()) ?
		                   this.getUTCFullYear()   + '-' +
		                 f(this.getUTCMonth() + 1) + '-' +
		                 f(this.getUTCDate())      + 'T' +
		                 f(this.getUTCHours())     + ':' +
		                 f(this.getUTCMinutes())   + ':' +
		                 f(this.getUTCSeconds())   + 'Z' : null;
		        };
		
		        String.prototype.toJSON =
		        Number.prototype.toJSON =
		        Boolean.prototype.toJSON = function (key) {
		            return this.valueOf();
		        };
		    }
		
		    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
		        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
		        gap,
		        indent,
		        meta = {    // table of character substitutions
		            '\b': '\\b',
		            '\t': '\\t',
		            '\n': '\\n',
		            '\f': '\\f',
		            '\r': '\\r',
		            '"' : '\\"',
		            '\\': '\\\\'
		        },
		        rep;
		
		
		    function quote(string) {
		
		// If the string contains no control characters, no quote characters, and no
		// backslash characters, then we can safely slap some quotes around it.
		// Otherwise we must also replace the offending characters with safe escape
		// sequences.
		
		        escapable.lastIndex = 0;
		        return escapable.test(string) ?
		            '"' + string.replace(escapable, function (a) {
		                var c = meta[a];
		                return typeof c === 'string' ? c :
		                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
		            }) + '"' :
		            '"' + string + '"';
		    }
		
		
		    function str(key, holder) {
		
		// Produce a string from holder[key].
		
		        var i,          // The loop counter.
		            k,          // The member key.
		            v,          // The member value.
		            length,
		            mind = gap,
		            partial,
		            value = holder[key];
		
		// If the value has a toJSON method, call it to obtain a replacement value.
		
		        if (value && typeof value === 'object' &&
		                typeof value.toJSON === 'function') {
		            value = value.toJSON(key);
		        }
		
		// If we were called with a replacer function, then call the replacer to
		// obtain a replacement value.
		
		        if (typeof rep === 'function') {
		            value = rep.call(holder, key, value);
		        }
		
		// What happens next depends on the value's type.
		
		        switch (typeof value) {
		        case 'string':
		            return quote(value);
		
		        case 'number':
		
		// JSON numbers must be finite. Encode non-finite numbers as null.
		
		            return isFinite(value) ? String(value) : 'null';
		
		        case 'boolean':
		        case 'null':
		
		// If the value is a boolean or null, convert it to a string. Note:
		// typeof null does not produce 'null'. The case is included here in
		// the remote chance that this gets fixed someday.
		
		            return String(value);
		
		// If the type is 'object', we might be dealing with an object or an array or
		// null.
		
		        case 'object':
		
		// Due to a specification blunder in ECMAScript, typeof null is 'object',
		// so watch out for that case.
		
		            if (!value) {
		                return 'null';
		            }
		
		// Make an array to hold the partial results of stringifying this object value.
		
		            gap += indent;
		            partial = [];
		
		// Is the value an array?
		
		            if (Object.prototype.toString.apply(value) === '[object Array]') {
		
		// The value is an array. Stringify every element. Use null as a placeholder
		// for non-JSON values.
		
		                length = value.length;
		                for (i = 0; i < length; i += 1) {
		                    partial[i] = str(i, value) || 'null';
		                }
		
		// Join all of the elements together, separated with commas, and wrap them in
		// brackets.
		
		                v = partial.length === 0 ? '[]' :
		                    gap ? '[\n' + gap +
		                            partial.join(',\n' + gap) + '\n' +
		                                mind + ']' :
		                          '[' + partial.join(',') + ']';
		                gap = mind;
		                return v;
		            }
		
		// If the replacer is an array, use it to select the members to be stringified.
		
		            if (rep && typeof rep === 'object') {
		                length = rep.length;
		                for (i = 0; i < length; i += 1) {
		                    k = rep[i];
		                    if (typeof k === 'string') {
		                        v = str(k, value);
		                        if (v) {
		                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
		                        }
		                    }
		                }
		            } else {
		
		// Otherwise, iterate through all of the keys in the object.
		
		                for (k in value) {
		                    if (Object.hasOwnProperty.call(value, k)) {
		                        v = str(k, value);
		                        if (v) {
		                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
		                        }
		                    }
		                }
		            }
		
		// Join all of the member texts together, separated with commas,
		// and wrap them in braces.
		
		            v = partial.length === 0 ? '{}' :
		                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
		                        mind + '}' : '{' + partial.join(',') + '}';
		            gap = mind;
		            return v;
		        }
		    }
		
		// If the JSON object does not yet have a stringify method, give it one.
		
		    if (typeof JSON.stringify !== 'function') {
		        JSON.stringify = function (value, replacer, space) {
		
		// The stringify method takes a value and an optional replacer, and an optional
		// space parameter, and returns a JSON text. The replacer can be a function
		// that can replace values, or an array of strings that will select the keys.
		// A default replacer method can be provided. Use of the space parameter can
		// produce text that is more easily readable.
		
		            var i;
		            gap = '';
		            indent = '';
		
		// If the space parameter is a number, make an indent string containing that
		// many spaces.
		
		            if (typeof space === 'number') {
		                for (i = 0; i < space; i += 1) {
		                    indent += ' ';
		                }
		
		// If the space parameter is a string, it will be used as the indent string.
		
		            } else if (typeof space === 'string') {
		                indent = space;
		            }
		
		// If there is a replacer, it must be a function or an array.
		// Otherwise, throw an error.
		
		            rep = replacer;
		            if (replacer && typeof replacer !== 'function' &&
		                    (typeof replacer !== 'object' ||
		                     typeof replacer.length !== 'number')) {
		                throw new Error('JSON.stringify');
		            }
		
		// Make a fake root object containing our value under the key of ''.
		// Return the result of stringifying the value.
		
		            return str('', {'': value});
		        };
		    }
		
		
		// If the JSON object does not yet have a parse method, give it one.
		
		    if (typeof JSON.parse !== 'function') {
		        JSON.parse = function (text, reviver) {
		
		// The parse method takes a text and an optional reviver function, and returns
		// a JavaScript value if the text is a valid JSON text.
		
		            var j;
		
		            function walk(holder, key) {
		
		// The walk method is used to recursively walk the resulting structure so
		// that modifications can be made.
		
		                var k, v, value = holder[key];
		                if (value && typeof value === 'object') {
		                    for (k in value) {
		                        if (Object.hasOwnProperty.call(value, k)) {
		                            v = walk(value, k);
		                            if (v !== undefined) {
		                                value[k] = v;
		                            } else {
		                                delete value[k];
		                            }
		                        }
		                    }
		                }
		                return reviver.call(holder, key, value);
		            }
		
		
		// Parsing happens in four stages. In the first stage, we replace certain
		// Unicode characters with escape sequences. JavaScript handles many characters
		// incorrectly, either silently deleting them, or treating them as line endings.
		
		            cx.lastIndex = 0;
		            if (cx.test(text)) {
		                text = text.replace(cx, function (a) {
		                    return '\\u' +
		                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
		                });
		            }
		
		// In the second stage, we run the text against regular expressions that look
		// for non-JSON patterns. We are especially concerned with '()' and 'new'
		// because they can cause invocation, and '=' because it can cause mutation.
		// But just to be safe, we want to reject all unexpected forms.
		
		// We split the second stage into 4 regexp operations in order to work around
		// crippling inefficiencies in IE's and Safari's regexp engines. First we
		// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
		// replace all simple value tokens with ']' characters. Third, we delete all
		// open brackets that follow a colon or comma or that begin the text. Finally,
		// we look to see that the remaining characters are only whitespace or ']' or
		// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
		
		            if (/^[\],:{}\s]*$/.
		test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
		replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
		replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
		
		// In the third stage we use the eval function to compile the text into a
		// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
		// in JavaScript: it can begin a block or an object literal. We wrap the text
		// in parens to eliminate the ambiguity.
		
		                j = eval('(' + text + ')');
		
		// In the optional fourth stage, we recursively walk the new structure, passing
		// each name/value pair to a reviver function for possible transformation.
		
		                return typeof reviver === 'function' ?
		                    walk({'': j}, '') : j;
		            }
		
		// If the text is not JSON parseable, then a SyntaxError is thrown.
		
		            throw new SyntaxError('JSON.parse');
		        };
		    }
		}());

    $.toJSON = function(text, reviver) {
        if (typeof reviver == "undefined") {
            reviver = null;
        }
        return JSON.parse(text, reviver);
    };
    $.jSONToString = function(value, replacer, space) {
        if (typeof replacer == "undefined") {
            replacer = null;
        }
        if (typeof space == "undefined") {
            space = null;
        }
        return JSON.stringify(value, replacer, space);
    };
    
})(jQuery);//DropdownList.js
$(document).ready(function () {
    $('#wedding-navigation li').hover(function () {
        $(this).addClass('over');
    }, function () {
        $(this).removeClass('over');
    });
});//googlecse.js
$(function() {  
var q = $("#q");
var qSubmit = $("#qSubmit");
q.keypress(function (e) {  
	if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {  
            qSubmit.trigger("click");
		return false;  
	} else {
		return true;  
	}
});
    var qBlur = function () {
	if (q.val() == '') {
		q.addClass("search-watermark");
        }
};
    q.bind("focus", function () {
	q.removeClass("search-watermark");
});
    q.bind("blur", qBlur);
    qSubmit.bind("click", function (e) {
        location.href = "/search/index.aspx?q=" + q.val();
    });
    qBlur();
});/**
* --------------------------------------------------------------------
* jQuery-Plugin "pngFix"
* Version: 1.2, 09.03.2009
* by Andreas Eberhard, andreas.eberhard@gmail.com
*                      http://jquery.andreaseberhard.de/
*
* Copyright (c) 2007 Andreas Eberhard
* Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
*
* Changelog:
*    09.03.2009 Version 1.2
*    - Update for jQuery 1.3.x, removed @ from selectors
*    11.09.2007 Version 1.1
*    - removed noConflict
*    - added png-support for input type=image
*    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
*    31.05.2007 initial Version 1.0
* --------------------------------------------------------------------
* @example $(function(){$(document).pngFix();});
* @desc Fixes all PNG's in the document on document.ready
*
* jQuery(function(){jQuery(document).pngFix();});
* @desc Fixes all PNG's in the document on document.ready when using noConflict
*
* @example $(function(){$('div.examples').pngFix();});
* @desc Fixes all PNG's within div with class examples
*
* @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
* @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
* --------------------------------------------------------------------
*/

(function($) {

    jQuery.fn.pngFix = function(settings) {

        // Settings
        settings = jQuery.extend({
            blankgif: 'blank.gif'
        }, settings);

        var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
        var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

        if (jQuery.browser.msie && (ie55 || ie6)) {

            //fix images with png-source
            jQuery(this).find("img[src$=.png]").each(function() {

                jQuery(this).attr('width', jQuery(this).width());
                jQuery(this).attr('height', jQuery(this).height());

                var prevStyle = '';
                var strNewHTML = '';
                var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
                var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
                var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
                var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
                var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
                var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
                if (this.style.border) {
                    prevStyle += 'border:' + this.style.border + ';';
                    this.style.border = '';
                }
                if (this.style.padding) {
                    prevStyle += 'padding:' + this.style.padding + ';';
                    this.style.padding = '';
                }
                if (this.style.margin) {
                    prevStyle += 'margin:' + this.style.margin + ';';
                    this.style.margin = '';
                }
                var imgStyle = (this.style.cssText);

                strNewHTML += '<span ' + imgId + imgClass + imgTitle + imgAlt;
                strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;' + imgAlign + imgHand;
                strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
                strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
                strNewHTML += imgStyle + '"></span>';
                if (prevStyle != '') {
                    strNewHTML = '<span style="position:relative;display:inline-block;' + prevStyle + imgHand + 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;' + '">' + strNewHTML + '</span>';
                }

                jQuery(this).hide();
                jQuery(this).after(strNewHTML);

            });

            // fix css background pngs
            jQuery(this).find("*").each(function() {
                var bgIMG = jQuery(this).css('background-image');
                if (bgIMG.indexOf(".png") != -1) {
                    var iebg = bgIMG.split('url("')[1].split('")')[0];
                    jQuery(this).css('background-image', 'none');
                    jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
                }
            });

            //fix input with png-source
            jQuery(this).find("input[src$=.png]").each(function() {
                var bgIMG = jQuery(this).attr('src');
                jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
                jQuery(this).attr('src', settings.blankgif)
            });

        }

        return jQuery;

    };

})(jQuery);
$(function() { $(document).pngFix(); });
/*
* jQuery Expander plugin
* Version 0.5.1  (February 23, 2010)
* @requires jQuery v1.1.1+
* @author Karl Swedberg
* @author Adam Hall
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/


(function ($) {

    $.fn.expander = function (options) {

        var opts = $.extend({}, $.fn.expander.defaults, options),
            rSlash = /\//,
            delayedCollapse;

        this.each(function () {
            var thisEl = this,
                $this = $(this);
            var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
            var cleanedTag, startTags, endTags;
            var allText = $this.html();
            var startText = allText.slice(0, o.slicePoint).replace(/(&([^;]+;)?|\w+)$/, '');

            startTags = startText.match(/<\w[^>]*>/g);

            if (startTags) {
                startText = allText.slice(0, o.slicePoint + startTags.join('').length).replace(/(&([^;]+;)?|\w+)$/, '');
            }

            if (startText.lastIndexOf('<') > startText.lastIndexOf('>')) {
                startText = startText.slice(0, startText.lastIndexOf('<'));
            }

            var defined = {};
            $.each(['onSlice', 'beforeExpand', 'afterExpand', 'onCollapse'], function (index, val) {
                defined[val] = $.isFunction(o[val]);
            });

            var endText = allText.slice(startText.length);
            // create necessary expand/collapse elements if they don't already exist
            if (!$('span.details', this).length) {
                // end script if text length isn't long enough.
                if (endText.replace(/\s+$/, '').split(' ').length < o.widow) {
                    return;
                }
                // otherwise, continue...
                if (defined.onSlice) {
                    o.onSlice.call(thisEl);
                }
                if (endText.indexOf('</') > -1) {
                    endTags = endText.match(/<(\/)?[^>]*>/g);
                    for (var i = 0; i < endTags.length; i++) {

                        if (endTags[i].indexOf('</') > -1) {
                            var startTag, startTagExists = false;
                            for (var j = 0; j < i; j++) {
                                startTag = endTags[j].slice(0, endTags[j].indexOf(' ')).replace(/\w$/, '$1>');
                                if (startTag == endTags[i].replace(rSlash, '')) {
                                    startTagExists = true;
                                }
                            }
                            if (!startTagExists) {
                                startText = startText + endTags[i];
                                var matched = false;
                                for (var s = startTags.length - 1; s >= 0; s--) {
                                    if (startTags[s].slice(0, startTags[s].indexOf(' ')).replace(/(\w)$/, '$1>') == endTags[i].replace(rSlash, '') && matched == false) {
                                        cleanedTag = cleanedTag ? startTags[s] + cleanedTag : startTags[s];
                                        matched = true;
                                    }
                                };
                            }
                        }
                    }

                    endText = cleanedTag && cleanedTag + endText || endText;
                }
                $this.data("originalHTML", allText);
                $this.data("compressedHTML", [
                    startText,
                    '<span class="read-more">',
                      o.expandPrefix,
                      '<a href="#">',
                        o.expandText,
                      '</a>',
                    '</span>',
                    '<div class="details">',
                      endText,
                    '</div>'
                    ].join(''));
                $this.html($this.data("compressedHTML"));
                $this.bind("ReBindClicks", function () {
                    var $thisDetails = $('.details', this),
                        $readMore = $('span.read-more', this);

                    $thisDetails.hide();
                    $readMore.find('a').click(function () {
                        $readMore.hide();
                        if (o.expandEffect === 'show' && !o.expandSpeed) {
                            if (defined.beforeExpand) {
                                o.beforeExpand.call(thisEl);
                            }
                            $thisDetails.show();
                            if (defined.afterExpand) {
                                o.afterExpand.call(thisEl);
                            }
                            delayCollapse(o, $thisDetails, thisEl);
                            completedExpand();
                        } else {
                            if (defined.beforeExpand) {
                                o.beforeExpand.call(thisEl);
                            }
                            $thisDetails[o.expandEffect](o.expandSpeed, function () {
                                $thisDetails.css({
                                    zoom: ''
                                });
                                if (defined.beforeExpand) {
                                    o.afterExpand.call(thisEl);
                                }
                                delayCollapse(o, $thisDetails, thisEl);
                                if (o.userCollapse) {
                                    $this.html($this.data("originalHTML"));
                                    $this.append('<span class="re-collapse">' + o.userCollapsePrefix + '<a href="#">' + o.userCollapseText + '</a></span>');


                                    $this.find('span.re-collapse a').click(function () {

                                        clearTimeout(delayedCollapse);
                                        $para = $(this).parent().parent();
                                        $para.html($para.data("compressedHTML"));
                                        $para.trigger("ReBindClicks");
                                        //reCollapse($para);
                                        if (defined.onCollapse) {
                                            o.onCollapse.call(thisEl, true);
                                        }
                                        return false;
                                    });
                                }
                            });
                        }

                        return false;
                    });


                });
                $this.trigger("ReBindClicks");
            };

        });

        function delayCollapse(option, $collapseEl, thisEl) {
            if (option.collapseTimer) {
                delayedCollapse = setTimeout(function () {
                    reCollapse($collapseEl);
                    if ($.isFunction(option.onCollapse)) {
                        option.onCollapse.call(thisEl, false);
                    }
                }, option.collapseTimer);
            }
        }

        return this;
    };
    // plugin defaults
    $.fn.expander.defaults = {
        slicePoint: 100,
        // the number of characters at which the contents will be sliced into two parts.
        // Note: any tag names in the HTML that appear inside the sliced element before
        // the slicePoint will be counted along with the text characters.
        widow: 4,
        // a threshold of sorts for whether to initially hide/collapse part of the element's contents.
        // If after slicing the contents in two there are fewer words in the second part than
        // the value set by widow, we won't bother hiding/collapsing anything.
        expandText: '( read more... )',
        // text displayed in a link instead of the hidden part of the element.
        // clicking this will expand/show the hidden/collapsed text
        expandPrefix: '',
        collapseTimer: 0,
        // number of milliseconds after text has been expanded at which to collapse the text again
        expandEffect: 'slideDown',
        expandSpeed: '300',
        // speed in milliseconds of the animation effect for expanding the text
        userCollapse: true,
        // allow the user to re-collapse the expanded text.
        userCollapseText: '( ...less )',
        // text to use for the link to re-collapse the text
        userCollapsePrefix: ' ',

        /* CALLBACK FUNCTIONS
        ** all functions have the this keyword mapped to the element that called .expander()
        */
        onSlice: null,
        // function() {}
        beforeExpand: null,
        // function() {},
        afterExpand: null,
        // function() {},
        onCollapse: null // function(byUser) {}
    };
})(jQuery);// starting of FashionListing.js


var asmxFashionDesigners = "/API/Fashion/JSWSFashionDesigners.asmx/";
var asmxFashionListing = "/API/Fashion/JSWSFashionListing.asmx/";
var asmxWeddingDress = "/API/Fashion/JSWSSearchWeddingDress.asmx/";
var asmxFashionSearch = "/API/Fashion/JSWSSearchWeddingUrl.asmx/";
var asmxSuppliers = "/API/Suppliers/JSWSSuppliers.asmx/";

var $HitchedAjaxOptions = {
    type: "POST",
    contentType: "application/json; charset=utf-8",
    dataType: "text",dataFilter: function (data, type) {return $.parseJSON(data);},
    error: function(result) {
        if (this.console && typeof console.log != "undefined")
            console.log("Error in server:" + result.status + ' ' + result.statusText);
    }
};

var pageNo =1;
var loadingImage = false;
var totalRandomImagesPerCall;
var currentImageIndex = 1;
var getNextResult = false;
var sCallbackObj = { };
var sCallbackObjID = { };
var sLoadFashionSupplierList = { };
var sGetSupplierList = { };

var srchDesignerName,srchGownType,srchNeckline,srchFabric,srchTrain,srchColour,srchSleeveStyle;

function AdjustHeightForDesign() {
     
	 var myoldHeight = $("#divMainFashionIntro").height();
	 if (myoldHeight !== null && myoldHeight !== undefined) {	     
	     mydivHeight = $('#two-content').attr("offsetHeight");
			$('span.more-text-holder:eq(0)> span').hide();     
			$('span#moretext').hide();     
			$('label#dot').show(); 
			$('a#anchorMore').show();  

			var newHeight = $("#divMainFashionIntro").height();


			 // Adjust height of the left and content panel
			 $("two-content").css("height","auto");
			 $("two-left").css("height","auto");
			 ReAssignHieght('two-content', mydivHeight, newHeight - myoldHeight);
			 AdjustHeight();   

	 }
	 divHeight = $('#two-content').attr("offsetHeight");
	 oldHeight = $("span[id$='lblIntro']").height();

}
function AdjustSupplierListingHeight(oldHeight)
{
	var divHeight = $("#two-content").height();
	var newHeight = $("#divFashionSupplierListing").height();
	if(oldHeight > newHeight)
	{
		newHeight = newHeight + 10;
	}
	ReAssignHieght('two-content',divHeight,newHeight-oldHeight);
	AdjustHeight();
}
 
function LinkFashionSearch() {
    var q = $HitchedAjaxOptions;
    q.url = asmxFashionSearch + "GetFashionSearchUrl";
    q.data = "{designerName: '" + srchDesignerName + "', gownType: '" + srchGownType + "', neckline: '" + srchNeckline + "', fabric: '" + srchFabric + "', train: '" + srchTrain + "', color: '" + srchColour + "', sleeve: '" + srchSleeveStyle + "'}";
    q.success = CallbackGetFashionSearchUrl;
$.ajax(q);
}

function CallbackGetFashionSearchUrl(result)
{
    location.href = result.d;
}
function GetSearchValues()
{
    srchDesignerName = $("#hdnDesignerName").val();
    srchGownType = $("#hdnGownType").val();
    srchNeckline = $("#hdnNeckline").val();
    srchFabric = $("#hdnFabric").val();
    srchTrain = $("#hdnTrain").val();
    srchColour = $("#hdnColour").val();
		srchSleeveStyle = $("#hdnSleeve").val();
}


function CheckIsEmpty(designResult, text)
{
if(designResult === null || designResult === undefined)
{return true;}
if(text === null || text === undefined)
{return true;}
if(text === "")
{return true;}

return false;
}
 
 
function ToggleDesignDetails(designResult,clientID)
{
if(!CheckIsEmpty(designResult,designResult.DesignName))
{$(clientID + "liStyle").show();}
else{$(clientID + "liStyle").hide();}
    
if(!CheckIsEmpty(designResult,designResult.GownLength))
{$(clientID + "liGownLength").show();}
else
{$(clientID + "liGownLength").hide();}
    
if(!CheckIsEmpty(designResult,designResult.SleeveLength))
{$(clientID + "liSleeveLength").show();}
else
{$(clientID + "liSleeveLength").hide();}
   
if(!CheckIsEmpty(designResult,designResult.Silhouette))
{$(clientID + "liSilHouette").show();}
else
{$(clientID + "liSilHouette").hide();}
    
if(!CheckIsEmpty(designResult,designResult.Colors))
{$(clientID + "liColor").show();}
else
{$(clientID + "liColor").hide();}

if(!CheckIsEmpty(designResult,designResult.Fabric))
{$(clientID + "liFabric").show();}
else
{$(clientID + "liFabric").hide();}
    
if(!CheckIsEmpty(designResult,designResult.NeckLine))
{$(clientID + "liNeckLine").show();}
else
{$(clientID + "liNeckLine").hide();}
    
if(!CheckIsEmpty(designResult,designResult.SleeveType))
{$(clientID + "liSleeveStyle").show();}
else
{$(clientID + "liSleeveStyle").hide();}
    
if(!CheckIsEmpty(designResult,designResult.Description))
{$(clientID + "liDescription").show();}
else
{$(clientID + "liDescription").hide();}
}
 



$(document).ready(function()
  {
		var options={zoomWidth: 200,zoomHeight: 380,showPreload:false};
		$("a.jqzoom").jqzoom(options);			
  });
  var divHeight;
  var oldHeight;
  $(document).ready(function() {
      AdjustDesignHeight(0);

      AdjustHeightForDesign();
      $('span.more-text-holder:eq(0)> a').click(function() {

          var newHeight = $("span[id$='lblIntro']").height();
          // Adjust height of the left and content panel
          $("two-content").css("height", "auto");

          ReAssignHieght('two-content', divHeight, newHeight - oldHeight);
          AdjustHeight();

      });
      $('ul#advert').innerfade({
          speed: 1000,
          timeout: 5000,
          type: 'sequence',
          containerheight: '150px'
      });
      $("#ctl00_ctl00_ContentMain_ContentMain_hlkNext").attr({
          href: "#"
      });
      $("#ctl00_ctl00_ContentMain_ContentMain_hlkPrevious").attr({
          href: "#"
      });

      $(".SearchFashionSupplierImage").click(function() {
          $(this).removeAttr("click");
          return false;
      });

      $('ul#advert').show();
      $("#ancRemoveDesigner").click(function() {
          GetSearchValues();
          srchDesignerName = "";
          LinkFashionSearch();

      });

      $("#ancRemoveGownType").click(function() {
          GetSearchValues();
          srchGownType = "";
          LinkFashionSearch();
      });


      $("#ancRemoveNeckline").click(function() {
          GetSearchValues();
          srchNeckline = "";
          LinkFashionSearch();
      });

      $("#ancRemoveFabric").click(function() {
          GetSearchValues();
          srchFabric = "";
          LinkFashionSearch();
      });

      $("#ancRemoveTrain").click(function() {
          GetSearchValues();
          srchTrain = "";
          LinkFashionSearch();
      });

      $("#ancRemoveColour").click(function() {
          GetSearchValues();
          srchColour = "";
          LinkFashionSearch();
      });
      
			$("#ancRemoveSleeve").click(function() {
          GetSearchValues();
          srchSleeveStyle  = "";
          LinkFashionSearch();
      });
      var fashionSearchPrefixedID = $("#hdnFashionSearchClientID").val();

      $(fashionSearchPrefixedID + "imgSearch").click(function() {
          $(fashionSearchPrefixedID + "divFashionSearchError").css("display", "none");
          var designer = $(fashionSearchPrefixedID + "ddlDesigner").val();
          var gownType = $(fashionSearchPrefixedID + "ddlGownType").val();
          var neckLine = $(fashionSearchPrefixedID + "ddlNeckline").val();
          var fabric = $(fashionSearchPrefixedID + "ddlFabric").val();
          var train = $(fashionSearchPrefixedID + "ddlTrain").val();
          var color = $(fashionSearchPrefixedID + "ddlColour").val();
          var sleevelength = $(fashionSearchPrefixedID + "ddlSleeveStyle").val();
          if (designer === "" && gownType === "" && neckLine === "" && fabric === "" && train === "" && color === "") {
              $(fashionSearchPrefixedID + "divFashionSearchError").css("display", "inline");
              $(fashionSearchPrefixedID + "lblMessage").html("Please choose some search criteria");
              return false;
          }
          var q = $HitchedAjaxOptions;
          q.url = asmxWeddingDress + "BuildWeddingDress";
          q.data = "{designerName: '" + designer + "', gownType: '" + gownType + "', neckline: '" + neckLine + "', fabric: '" + fabric + "', train: '" + train + "', color: '" + color + "', sleevelength: '" + sleevelength + "'}";
          q.success = CallBackBuildWeddingDress;
$.ajax(q);
          return false;
      });
  }); 
  
function  CallBackBuildWeddingDress(result)
  {
  location.href = result.d;
  }
 function getFashionSupplierID(obj)
 {
 
  return obj.href.substring(obj.href.lastIndexOf('=')+1,obj.href.length);
   
 }
 
 
 function InsertFashionLog(obj)
 {
     
     var q = $HitchedAjaxOptions;
     q.url = asmxFashionListing + "InsertFashionLeadLog";
     q.data = "{supplierID: '" + getFashionSupplierID(obj) + "'}";
     $.ajax(q);
    return true;
 }
 
 

function isEven(num) {
  return !(num % 2);
}



function GetSerachResultHTMLCallback(result) {
	if  (result !== null && result !== undefined) {
		var ulSupplierStock =  $("#ulSupplierStock");
		ulSupplierStock.html(result.d); 
  }
}
function BuildSearchResultHTML(result,searchText)
{
   if  (result !== null && result !== undefined) {
    var supplierName = $('.lblSupplierName').text();
    
    var q = $HitchedAjaxOptions;
    q.url = asmxFashionListing + "GetSerachResultHTML";
    q.data = "{supplierName: '" + supplierName + "', searchString: '" + searchText + "', mappingList: '" + JSON.stringify(myJSONtext, replacer) + "'}";
    q.success = GetSerachResultHTMLCallback;
    $.ajax(q);
    
    //FashionListing.GetSerachResultHTML(supplierName,searchText,result,GetSerachResultHTMLCallback); 
  }
}


function EmailFriendCallback(result) {
	if  (result !== null && result !== undefined) {
	 var hlnkEmailFriend = $(sCallbackObj.clientID + "hlnkEmailFriend");
	hlnkEmailFriend.attr({href: result.d}); 
  }
}

function GetDesignURLCallback(result) {
	if  (result !== null && result !== undefined) {
	 var designLink = $(sCallbackObj.clientID + "hdnFashionDesignURL");
	designLink.val(result.d); 
  }
}


function GetSupplierURLCallback(result) {
	if  (result !== null && result !== undefined) {
	 var hlnkSupplier = $(sCallbackObjID.clientID + "hlnkShowCollection");
	hlnkSupplier.attr({href: result.d}); 
  }
}
function EmailAFriendCallback(result) {
	if  (result !== null && result !== undefined) {
	 var hlnkEmailFriend = $(sCallbackObjID.clientID + "hlnkEmailFriend");
	hlnkEmailFriend.attr({href: result.d}); 
  }
}

function GetBreadCrumbCallback(result) {
	if  (result !== null && result !== undefined) { 
		$("span[id$='lblBreadCrum']").html(result.d); 
  }
}
function GetSupplierStockHTMLCallback(result) {
	var ulSupplierStock = $("#ulSupplierStock");
	if  (result !== null && result !== undefined) {
	 ulSupplierStock.html(result.d); 
  }
}
function GetFashionUrlCallback(result) {
	if  (result !== null && result !== undefined) {
	 location.href = result.d; 
  }
}

function GetSupplierListByFashionSupplierIDCallback(result) {
	if (result !== null && result !== undefined) {
		if(result.d !== null && result.d !== undefined)
		{
			if(result.d !== "")
			{
					$(sGetSupplierList.SearchFashionSupplierClientID + "hdnSupplierList").val(result.d);
					$(sGetSupplierList.FashionSupplierListingClientID + "divFashionSupplierMap").css("display","inline");
			}else{
					$(sGetSupplierList.FashionSupplierListingClientID + "divFashionSupplierMap").css("display","none");
			}
		}else{
					$(sGetSupplierList.FashionSupplierListingClientID + "divFashionSupplierMap").css("display","none");
	 	}
	}
}

function GetSupplierList(fashionSupplierID,FashionSupplierListingClientID)
{
	
	 var SearchFashionSupplierClientID  = "#" + $("#hdnSearchFashionSupplierClientID").val() + "_"; 
	 $(SearchFashionSupplierClientID + "lblMsg").html("");
	 $("#divSupplierSearchListing").html("");
	 sGetSupplierList.SearchFashionSupplierClientID = SearchFashionSupplierClientID;
	 sGetSupplierList.FashionSupplierListingClientID = FashionSupplierListingClientID; 
	 
	 var q = $HitchedAjaxOptions;
     q.url = asmxFashionListing + "GetSupplierListByFashionSupplierID";
     q.data = "{_supplierID: " + fashionSupplierID + "}";
     q.success = GetSupplierListByFashionSupplierIDCallback;
     $.ajax(q);
}

function LoadFashionSupplierListingCallback (result) {
	var FashionSupplierListingClientID  = "#" + $("#hdnFashionSupplierListingClientID").val() + "_";
	$(FashionSupplierListingClientID + "lblSupplierErrorMsg").html(""); 
	if(result.d !== null && result.d !== undefined && result.d !== "") {
		$("#divFashionSupplierContent").html(result.d);
	} else {
		$(FashionSupplierListingClientID + "lblSupplierErrorMsg").html("This designer has no stockists registered with hitched.co.uk");
		$("#divFashionSupplierContent").html("");
	}
	$(FashionSupplierListingClientID + "lblDesignerName").html(sLoadFashionSupplierList.companyName);
	GetSupplierList(sLoadFashionSupplierList.fashionSupplierID,FashionSupplierListingClientID);
}

function LoadFashionSupplierList(fashionSupplierID,companyName) {

	sLoadFashionSupplierList.companyName = companyName;
	sLoadFashionSupplierList.fashionSupplierID = fashionSupplierID;	
	 var q = $HitchedAjaxOptions;
     q.url = asmxFashionListing + "LoadFashionSupplierListing";
     q.data = "{_supplierID: " + fashionSupplierID + "}";
     q.success = LoadFashionSupplierListingCallback;
     $.ajax(q);
}
 




function GetDesignDetailsByIDCallback(result) {
	if(result !== null && result !== undefined)
	{
	var designResult = result.d;
	var clientID = sCallbackObjID.clientID;
	var currentIndex = sCallbackObjID.currentIndex;

	if(designResult !== null && designResult !== undefined)
	{
		var lblStyleText = $(clientID + "lblStyleText");
		var lblSilHouetteText = $(clientID + "lblSilHouetteText");
		var lblNeckLineText = $(clientID + "lblNeckLineText");
		var lblGownLengthText = $(clientID + "lblGownLengthText");
		var lblSleeveLengthText = $(clientID + "lblSleeveLengthText");
		var lblSleeveStyleText = $(clientID + "lblSleeveStyleText");
		var lblDescriptionText = $(clientID + "lblDescriptionText");
		var lblFabricText = $(clientID + "lblFabricText");
		var lblColorText = $(clientID + "lblColorText");
		var imgSupplier = $(clientID + "imgSupplierLarge");
		var designID = $(clientID + "hdnFashionDesignID");
		var contactDesigner = $(clientID + "hlkDesignerName");
		var designLink = $(clientID + "hdnFashionDesignURL");
		var currentDesignName = $(clientID + "hdnCurrentDesignName");
		var lblCurrentIndex = $(clientID + "lblCurrentDesignIndex");
		var hlnkSupplier = $(clientID + "hlnkShowCollection");
		var supplierName = $(clientID + "lblDescSupplierName");
		var descSupplierName = $(clientID + "lblSupplierName");
		var hlnkEmailFriend = $(clientID + "hlnkEmailFriend");
		var designerImage = $(clientID + "imgDesigner");
		var hlkWebsite = $(clientID + "hlkWebsite");
		var liWebsite = $(clientID + "liWebsite");
		//var divRollOver = $(".liWebsite");
		//liWebsite.html().replace(loadedRolloverText,loadingRolloverText);
		
		designID.val(designResult.FashionDesignID);
		lblStyleText.html(designResult.DesignName);
		lblSilHouetteText.html(designResult.Silhouette);
		lblNeckLineText.html(designResult.NeckLine);
		lblGownLengthText.html(designResult.GownLength);
		lblSleeveLengthText.html(designResult.SleeveLength);
		lblSleeveStyleText.html(designResult.SleeveType);
		lblDescriptionText.html(designResult.Description);
		lblFabricText.html(designResult.Fabric);
		lblColorText.html(designResult.Colors);
		imgSupplier.attr({src: designResult.ImageURLThumb});
		imgSupplier.width(designResult.MainImageWidth);
		imgSupplier.height(designResult.MainImageHeight);
		//hlkWebsite.attr("href", "/f.asp?ct=" + designResult.Supplierid);
		//hlkWebsite.html(designResult.CompanyName);
		$('a.jqzoom').attr("href",designResult.ImageURLMedium);
		$('a.jqzoom').attr("title", designResult.DesignName);
		
		  if (designResult.ProductLink == null )
		     {		        
		          hlkWebsite.attr("href", "/f.aspx?ct=" +  designResult.Supplierid.toString());
		          hlkWebsite.html(designResult.CompanyName);		            
		     }      
		 else
		     {
		       if (designResult.ProductLink.indexOf('http://') > -1)		            
		          {
		             hlkWebsite.attr("href", designResult.ProductLink);
		             hlkWebsite.html(designResult.CompanyName);
		          }
		       else
		          {
		             hlkWebsite.attr("href", 'http://' + designResult.ProductLink);
		             hlkWebsite.html(designResult.CompanyName);
		          }
		     }		        

        if (designResult.ShowWebLink)
        {
            liWebsite.css("display","block")
        }
        else
        {
            liWebsite.css("display","none")
        }
        
		var q1 = $HitchedAjaxOptions;
		q1.url = asmxFashionListing + "GetDesignURL";
		q1.data = "{designName: '" + designResult.DesignName + "', sectionName: '" + designResult.SectionName + "', supplierName: '" + designResult.DesignerName + "'}";
		q1.success = GetDesignURLCallback;
		$.ajax(q1); 
		//FashionListing.GetDesignURL(designResult.DesignName, designResult.SectionName, designResult.DesignerName, GetDesignURLCallback);

		currentDesignName.val(designResult.DesignName);

		var q2 = $HitchedAjaxOptions;
		q2.url = asmxFashionListing + "GetSupplierURL";
		q2.data = "{sectionName: '" + designResult.SectionName + "', supplierName: '" + designResult.CompanyName + "'}";
		q2.success = GetSupplierURLCallback;
		$.ajax(q2);
		//FashionListing.GetSupplierURL(designResult.SectionName, designResult.CompanyName, GetSupplierURLCallback);

		var q3 = $HitchedAjaxOptions;
		q3.url = asmxFashionListing + "EmailSearchResultURL";
		q3.data = "{srchDesigner: '" + sCallbackObjID.srchDesigner + "', srchGownType: '" + sCallbackObjID.srchGownType + "', srchNeckLine: '" + sCallbackObjID.srchNeckLine + "', srchFabric: '" + sCallbackObjID.srchFabric + "', srchTrain: '" + sCallbackObjID.srchTrain + "', srchColour: '" + sCallbackObjID.srchColour + "', srchSleeveStyle:'" + srchSleeveStyle + "', DesignID: '" + designResult.FashionDesignID + "'}";
		q2.success = EmailAFriendCallback;
		$.ajax(q3);
		
		$(designerImage).fadeOut(2000, function () {
				designerImage.attr({
						src:  sCallbackObjID.imagePath + designResult.CompanyUrl
				});       
				$(designerImage).fadeIn(2000, function () {});    
		});


		hlnkSupplier.html("Show full collection from " + designResult.CompanyName);
		supplierName.html(designResult.CompanyName);
		descSupplierName.html(designResult.CompanyName);

		document.title = sCallbackObjID.baseTitle + " - " + designResult.CompanyName + " - " + designResult.DesignName;
		var q4 = $HitchedAjaxOptions;
		q4.url = asmxFashionListing + "GetBreadCrum";

		q4.data = "{gender: '" + designResult.Gender + "', supplierName: '" + designResult.CompanyName + "', designName: '" + designResult.DesignName + "', sectionName: '" + designResult.SectionName + "', sectionID: '" + parseInt(designResult.SectionID, 10) + "'}";
		q4.success = GetBreadCrumbCallback;
		$.ajax(q4);
		//FashionListing.GetBreadCrum(designResult.Gender, designResult.CompanyName, designResult.DesignName, designResult.SectionName, parseInt(designResult.SectionID, 10), GetBreadCrumbCallback);	
		lblCurrentIndex.html(parseInt(currentIndex.val(), 10) + 1);
		LoadFashionSupplierList(designResult.Supplierid,designResult.CompanyName);
		var q5 = $HitchedAjaxOptions;
		q5.url = asmxFashionListing + "GetSupplierStockHTML";
		//ByVal supplierID As Integer, ByVal supplierName As String
		q5.data = "{supplierID: '" + designResult.Supplierid + "', supplierName: '" + designResult.CompanyName + "'}";
		q5.success = GetSupplierStockHTMLCallback;
		$.ajax(q5);
		//FashionListing.GetSupplierStockHTML(designResult.Supplierid, designResult.CompanyName, GetSupplierStockHTMLCallback);
	}
	ToggleDesignDetails(designResult,clientID);    
	$("#loader").hide();	
	AdjustSupplierListingHeight(oldHeight); 
	return false;

	}
}
function GetDesignDetailsCallback(result) {
  //alert("GetDesignDetailsCallback");
    if(result !== null && result !== undefined){	
	    var designResult = result.d;
	    $.geekGaTrackPageAgain();
	    var clientID = sCallbackObj.clientID;
	    var currentIndex = sCallbackObj.currentIndex;


	    if (!(designResult === null || designResult === undefined)) {
	        $("#divDesigner").html(result.d);
	        if (!(currentIndex === null || currentIndex === undefined)) {
	        
		        var lblStyleText = $(clientID + "lblStyleText");
		        var lblSilHouetteText = $(clientID + "lblSilHouetteText");
		        var lblNeckLineText = $(clientID + "lblNeckLineText");
		        var lblGownLengthText = $(clientID + "lblGownLengthText");
		        var lblSleeveLengthText = $(clientID + "lblSleeveLengthText");
		        var lblSleeveStyleText = $(clientID + "lblSleeveStyleText");
		        var lblDescriptionText = $(clientID + "lblDescriptionText");
		        var lblFabricText = $(clientID + "lblFabricText");
		        var lblColorText = $(clientID + "lblColorText");
		        var imgSupplier = $(clientID + "imgSupplierLarge");
		        var designID = $(clientID + "hdnFashionDesignID");
		        var contactDesigner = $(clientID + "hlkDesignerName");
		        var hlkSupplierWebsite = $(clientID + "hlkSupplierWebsite");
		        
		        var designLink = $(clientID + "hdnFashionDesignURL");
		        var currentDesignName = $(clientID + "hdnCurrentDesignName");
		        var lblCurrentIndex = $(clientID + "lblCurrentDesignIndex");
		        var descSupplierName = $(clientID + "lblSupplierName");
		        var hlnkEmailFriend = $(clientID + "hlnkEmailFriend");             
                var hlkWebsite = $(clientID + "hlkWebsite");
                
               // alert(designResult.ProductLink)
		        designID.val(designResult.FashionDesignID);
		        lblStyleText.html(designResult.DesignName);
		        lblSilHouetteText.html(designResult.Silhouette);
		        lblNeckLineText.html(designResult.NeckLine);
		        lblGownLengthText.html(designResult.GownLength);
		        lblSleeveLengthText.html(designResult.SleeveLength);
		        lblSleeveStyleText.html(designResult.SleeveType);
		        lblDescriptionText.html(designResult.Description);
		        lblFabricText.html(designResult.Fabric);
		        lblColorText.html(designResult.Colors);
		        descSupplierName.html(designResult.CompanyName); 
		        hlkWebsite.attr("href", "/f.aspx?ct=" +  sCallbackObj.supplierID.toString() + "&DesignID=" + designResult.FashionDesignID);
		        hlkWebsite.html(designResult.CompanyName);
		        hlkSupplierWebsite.attr("href", "/f.aspx?ct=" +  sCallbackObj.supplierID.toString() + "&DesignID=" + designResult.FashionDesignID);

		        imgSupplier.attr({ src: designResult.ImageURLThumb });
						imgSupplier.width(designResult.MainImageWidth);
						imgSupplier.height(designResult.MainImageHeight);
						$('a.jqzoom').attr("href", designResult.ImageURLMedium);
						$('a.jqzoom').attr("title", designResult.DesignName);
		        contactDesigner.attr({
				        href:  "/fashion/requestinfo.aspx?SupplierID=" + sCallbackObj.supplierID + "&DesignID=" + designResult.FashionDesignID
		        });
		        currentDesignName.val(designResult.DesignName);
		        document.title = sCallbackObj.baseTitle + " - " + sCallbackObj.supplierName + " - " + designResult.DesignName;
		        lblCurrentIndex.html(parseInt(currentIndex.val(), 10) + 1);

		        var q1 = $HitchedAjaxOptions;
		        q1.url = asmxFashionListing + "GetBreadCrum";

		        q1.data = "{gender: '" + sCallbackObj.gender + "', supplierName: '" + sCallbackObj.supplierName + "', designName: '" + designResult.DesignName + "', sectionName: '" + sCallbackObj.SectionName + "', sectionID: '" + designResult.SectionID + "'}";
		        q1.success = GetBreadCrumbCallback;
		        $.ajax(q1);
    		    
		        //FashionListing.GetBreadCrum(sCallbackObj.gender, sCallbackObj.supplierName, designResult.DesignName, sCallbackObj.SectionName, designResult.SectionID, GetBreadCrumbCallback);
		        var q2 = $HitchedAjaxOptions;
		        q2.url = asmxFashionListing + "GetDesignURL";
		        q2.data = "{designName: '" + designResult.DesignName + "', sectionName: '" + sCallbackObj.SectionName + "', supplierName: '" + sCallbackObj.supplierName + "'}";
		        q2.success = GetDesignURLCallback;
		        $.ajax(q2); 
		        //FashionListing.GetDesignURL(designResult.DesignName, sCallbackObj.SectionName, sCallbackObj.supplierName, GetDesignURLCallback);
		        var q3 = $HitchedAjaxOptions;
		        q3.url = asmxFashionListing + "EmailFashionDetailURL";
		        q3.data = "{designName: '" + designResult.DesignName + "', sectionName: '" + sCallbackObj.SectionName + "', supplierName: '" + sCallbackObj.supplierName + "'}";
		        q3.success = EmailFriendCallback;
		        $.ajax(q3); 
		        //FashionListing.EmailFashionDetailURL(designResult.DesignName, sCallbackObj.SectionName, sCallbackObj.supplierName, EmailFriendCallback);

		        var ulSupplierStock = $("#ulSupplierStock");
		        var q4 = $HitchedAjaxOptions;
		        q4.url = asmxFashionListing + "GetSupplierStockHTML";
		        //ByVal supplierID As Integer, ByVal supplierName As String
		        q4.data = "{supplierID: '" + sCallbackObj.supplierID + "', supplierName: '" + sCallbackObj.supplierName + "'}";
		        q4.success = GetSupplierStockHTMLCallback;
		        $.ajax(q4);
		        //FashionListing.GetSupplierStockHTML(sCallbackObj.supplierID, sCallbackObj.supplierName, GetSupplierStockHTMLCallback);
		        ToggleDesignDetails(designResult, clientID);    
		    }
	    }   

	  
	    $("#loader").hide();
    }
	return false;
} 




function NavigateDesignByID(srchDesigner,srchGownType,srchNeckLine, srchFabric, srchTrain, srchColour, srchSleeveStyle, baseTitle,imagePath,clientID,value) {
$("#loader").show();	
$("#loader").height($("#fashion-thumbnail-panel").height());
$("#loader").width($("#fashion-thumbnail-panel").width());
clientID = "#" + clientID + "_";  
var oldHeight = $("#divFashionSupplierListing").height();
var designList = $(clientID + "hdnDesignNameList");
var currentIndex = $(clientID + "hdnCurrentIndex");
var designArray = designList.val().split("||");


if(!(parseInt(currentIndex.val(), 10) + value < 0 || parseInt(currentIndex.val(), 10) + value > designArray.length-1))
	{currentIndex.val(parseInt(currentIndex.val(), 10) + value);}
else if((parseInt(currentIndex.val(), 10) + value) < 0 ) 
	{currentIndex.val(designArray.length-1);}
else if((parseInt(currentIndex.val(), 10) + value) > designArray.length-1 ) 
	{currentIndex.val(0);}


sCallbackObjID = {
	clientID: clientID,
	currentIndex: currentIndex,
	srchDesigner: srchDesigner,
	srchGownType: srchGownType,
	srchNeckLine: srchNeckLine,
	srchFabric: srchFabric,
	srchTrain: srchTrain,
	srchColour: srchColour,
	srchSleeveStyle: srchSleeveStyle,
	baseTitle: baseTitle,
	imagePath: imagePath,
	currentIndex: currentIndex,
	value: value};

	var q = $HitchedAjaxOptions;
	q.url = asmxFashionListing + "GetDesignDetailsByID";
	q.data = "{designID: '" + parseInt(designArray[currentIndex.val()], 10) + "'}";
	q.success = GetDesignDetailsByIDCallback;
	$.ajax(q);
		

return false;
} 

function NavigateDesign(gender,sectionName,supplierName,supplierID,imagePath,clientID,baseTitle,value){
	$("#loader").show();	
	$("#loader").height($("#fashion-thumbnail-panel").height());
	$("#loader").width($("#fashion-thumbnail-panel").width());

	clientID = "#" + clientID + "_";  
	var currentIndex = $(clientID + "hdnCurrentIndex");
	
	var designList = $(clientID + "hdnDesignNameList");
	designArray = designList.val().split("||");
	
	var intPlusVal = parseInt(currentIndex.val(), 10) + value;
	if(!(intPlusVal < 0 || intPlusVal > designArray.length-1))
		{currentIndex.val(intPlusVal);}
	else if((intPlusVal) < 0 ) 
		{currentIndex.val(designArray.length-1);}
	else if((intPlusVal) > designArray.length-1 ) 
		{currentIndex.val(0);}
	
	sCallbackObj = {
	clientID: clientID,
	currentIndex: currentIndex,
	gender: gender,
	SectionName: sectionName,
	supplierName: supplierName,
	supplierID: supplierID,
	imagePath: imagePath,
	baseTitle: baseTitle};
	var q = $HitchedAjaxOptions;
	q.url = asmxFashionListing + "GetDesignDetails";
	q.data = "{designName: '" + designArray[currentIndex.val()] + "', supplierID: '" + parseInt(supplierID, 10) + "'}";
	q.success = GetDesignDetailsCallback;
	$.ajax(q);
	//FashionListing.GetDesignDetails(designArray[currentIndex.val()],parseInt(supplierID, 10), GetDesignDetailsCallback);
	return false;
}





 
 

 
function ReplaceAll( str,strReplace, strReplaceWith ) 
{
	    var idx = str.indexOf( strReplace);
	    while ( idx > -1 ) 
	    {
	        str = str.replace( strReplace , strReplaceWith );
	        idx = str.indexOf( strReplace );
	    }
	    return str;
}

    


function AssignBackGround(bgColor) {
    $("#tdLeftHandNav").css("backgroundColor", bgColor);
}


function Bookmark(url,title)
{
    
        if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion, 10) >= 4)) 
        {
            window.external.AddFavorite(url,title);
        } 
        else if (navigator.appName == "Netscape") 
        {
            window.sidebar.addPanel(title,url,"");
        } 
        else 
        {
            alert("Press CTRL-D  or CTRL-T  to bookmark");
        }
    
}


function ShowDescription(pnlIntroID)
{
    var divHeight = $("#two-content").attr("offsetHeight");
    var oldHeight = $("#spanTrimmedText").height();
    
    $("#spanTrimmedText").hide();
    $("#spanCompleteText").show();
    $("#" + pnlIntroID).hide();
    
    var newHeight = $("#spanCompleteText").height();
    
    // Adjust height of the left and content panel
    $("#two-content").css("height", "auto");
    
    ReAssignHieght('two-content',divHeight,newHeight-oldHeight);
    AdjustHeight();
   
    
    
   
    return false;
}
function LoadDesigner(fashionSection, fashionDesign) {
	var sectionID = $("#" + fashionSection).val();
	if(sectionID === "0" || sectionID === undefined || sectionID === null)
	{   
        if($('#'+fashionDesign))
        {
	         $('#'+fashionDesign).attr("disabled", true);
        }
        else if($("#ddlDesigners"))
        {
            $("ddlDesigners").attr("disabled", true);
        }			
        $("#" + fashionDesign).val("");
	} else {
	    $("#" + fashionDesign).attr('disabled', false);
	    fashionDesigners = '';
        var q = $HitchedAjaxOptions;
        q.url = asmxFashionDesigners + "GetDesignDetails";
        q.data = "{sectionID: '" + sectionID + "'}";
        q.success = GetDesignDetailsCallback;
        $.ajax(q);
		//FashionDesigners.GetDesignDetails(sectionID, GetDesignDetailsCallback);
        
	}
}


function GetFashionUrl(fashionSection,fashionDesign)
{
	var sectionID = $("#" + fashionSection).val();
	var fashionDesignLink = "";

	if($("#ddlDesigners"))
	{
		 fashionDesignLink = $("#ddlDesigners").val();
	}
	else if($('#'+fashionDesign))
	{
		fashionDesignLink = $("#" + fashionDesign).val();
	}


	if(fashionDesignLink !== null && fashionDesignLink !== undefined && fashionDesignLink !== "" && sectionID !== 0 && sectionID !== '0')
	{
		location.href = fashionDesignLink;
	}
	else {
	    var q = $HitchedAjaxOptions;
	    q.url = asmxFashionDesigners + "GetFashionUrl";
	    q.data = "{sectionID: '" + sectionID + "'}";
	    q.success = GetFashionUrlCallback;
	    $.ajax(q);		
	}
	return false;  
}


$(document).ready(function() { 
	$('input.SearchFashionSupplierText').keypress(function(e) {
	if(e.keyCode === 13){return false;}
	});  
	$('input.fashionLocalSearchText').keyup(function(e) {
		if(e.keyCode == 13) 
		{
			$('input.fashionLocalSearch').click();
			return false;
		}
	});  
	$('input.fashionLocalSearch').click(function(){return  GetSupplierListing();});
        
	function GetSupplierListing()    
	{

		 $("#loader_supplier").height($("#divSupplierlisting").height()+20);
		 $("#loader_supplier").width($("#divSupplierlisting").width());
		 $("#lblSupplierListingMsg").html("");
		 var searchText =  jQuery.trim($("input.fashionLocalSearchText").val());
		 if(searchText === "")
		 {
				$("#lblSupplierListingMsg").html("Please enter search text");
				return false;
		 }
		 $("#loader_supplier").show();	
		 var categoryID = $("span.lblCategoryID").text();
		 var sectionID = $("span.lblSectionID").text();  
         var q = $HitchedAjaxOptions;
         q.url = asmxFashionListing + "GetWeddingSupplierListing";
         q.data = "{searchText: '" + searchText + "',categoryID:'" + categoryID + "',sectionID:'" + sectionID + "'}";
         q.success = CallBackGetWeddingSupplierListing;
         $.ajax(q);
		 return false;
	}

});

function CallBackGetWeddingSupplierListing(result)
{
	if (result.d != null  && result.d != undefined && result.d != "") {   
		$("#divSupplierlisting").html(result.d);
	} else {
		$("#lblSupplierListingMsg").html("No suppliers found");
		$("#divSupplierlisting").html("");
	}     
	$("#loader_supplier").hide();
}


var _pageSize;
var _range;
var _appendedID;
var _isPrint;
var _supplierList;
var _lblMsg; 
var _searchText;

function GetFashionSuppliers(pageSize,range,appendedID,isPrint)
{
 
        _pageSize= pageSize;
        _range = range;
        _appendedID =appendedID;
        _isPrint =isPrint;
        
        var oldHeight = $("#divFashionSupplierListing").height();
        var supplierList = "";
        appendedID ="#" + appendedID +  "_";
        var geocode,searchText;
        var lblMsg = $(appendedID + "lblMsg");
        _lblMsg =lblMsg;
        supplierList = $(appendedID + "hdnSupplierList").val();
        $("#divSupplierSearchListing").html("");
        _supplierList =supplierList; 
        lblMsg.html("");
        // Code to adjust height of the left hand navigation and content area.
        
        searchText = $(appendedID + "txtSearch").val();
        _searchText=searchText;
        if(searchText === "")
        {
            lblMsg.html("Please enter search text");
            return false;
        }
        
        if(supplierList === null || supplierList === "" || supplierList === undefined)
        {
            lblMsg.html("No records to display");
            return false;
        }
              
         var q = $HitchedAjaxOptions; 
         q.url = asmxSuppliers + "GetGeocode";                 
         q.data = "{searchText:'" + _searchText + "'}";                        
         q.success = CallBackGetGeocode;  
         $.ajax(q);   
        AdjustSupplierListingHeight(oldHeight);
        return false;
 
}


function CallBackGetGeocode(result)
{  
        geocode = result.d;        
        // Get the search Item object
        GetSearchItem(geocode.Latitude, geocode.Longitude, "", _supplierList, _range, globalCurrentPageNo, _pageSize);        
         var q = $HitchedAjaxOptions; 
         q.url = asmxSuppliers + "GetFashionSupplierListingByGeoCode";                 
         q.data = "{_searchMappingItem:" + JSON.stringify(searchItem) + ",searchText:'" + _searchText + "'}";                        
         q.success = CallbackGetFashionSupplierListingByGeoCode;
         $.ajax(q);
}

function CallbackGetFashionSupplierListingByGeoCode(result)
{

      if(result.d.length > 0)
        {                    
            var q = $HitchedAjaxOptions; 
            q.url = asmxSuppliers + "CreateListingHTML";                 
            q.data = "{_mappingList:" + JSON.stringify(result.d) + "}";                        
            q.success = CallbackCreateListingHTML;  
            $.ajax(q);   
        }
        else
        {
            _lblMsg.html("No records to display");
        }       
}

function CallbackCreateListingHTML(result)
{
	var supplierListing = result.d;	
	if(supplierListing != null  && supplierListing != undefined && supplierListing != "")
	{
		$("#divSupplierSearchListing").html(supplierListing);
		$("#divFashionSupplierContent").hide();   
	}
	if ( _isPrint ==1 ) 
	{
		BuildSearchResultHTML(result,_searchText);
	}        
}
// end of FashionListing.js


// Div-adjustments.js
//HACK: Please try to move this to Adjust-Height.js style.
var offSetHeight = 10;
function FixHeight(one, two) {
    if ($('#' + one)) {
        var lh = $('#' + one).height();
        var rh = $('#' + two).height();
        var nh = Math.max(lh, rh);
        $('#' + one).height(nh + offSetHeight);
        $('#' + two).height(nh + offSetHeight);
    }
}
function AdjustHeight()
{
    if($("#two-left"))
    {
        $("#two-left").css("minHeight",$("#two-content").attr("offsetHeight") + offSetHeight + "px");
        if (IsIE6Browser()) 
        {
            $("#two-left").css("height",$("#two-content").attr("offsetHeight") + "px");
        }
        else
        {
             $("#two-left").css("height","auto");
        }
    }
}
function IsIE6Browser()
{
    var returnResult = false;
    var arVersion = navigator.appVersion.split("MSIE");
    var version = parseFloat(arVersion[1]);
    if ((version == 6) && (document.body.filters)) 
    {
        returnResult = true;
    }
    return returnResult;
  
}
function ReAssignHieght(id,orginalHeight,value)
{
        var newheight = orginalHeight + value;
        $('#'+id).css("height", newheight+"px");
}
function AdjustDesignHeight()
{
    if ($("#rndFashionDesign-content")) 
    {     
        var prefixedID = $("#hdnRandomDesignPrefixedID").val() + "_";
        $('#'+prefixedID + "ulRndFashionDesign").css('display','block');  
        if (! IsIE6Browser())
        {
            $("#rndFashionDesign-left").height($("#divFDRandomPanel").height() + 10);
            $("#rndFashionDesign-right").height($("#rndFashionDesign-left").height());
        }
	}
}
// JSGoogleMap
var divString = 0;
var lati=0;
var longi=0;
var ukCenterLat = "54.0710320549604";
var ukCenterLong = "-2.78397635451732";
var points = [];
var mosx,mosy;
var googleMap ;
var googleIcon ;
var clientID;
var markerImage;
var lstLatitude = new Array();
var lstlongitude  = new Array();
var lstlocationDetails = new Array();
var lstMapIcon = new Array();
var marker;
var infowindow; 
var asmxHierarchyManagement = "/API/Venues/JSWSHierarchyManagement.asmx/";


//var googleMarker;
var googleMarkerArray = new Array();
$(document).ready(function () {
	$('#basicModal input.basic, #basicModal a.basic, #basicModal img.basic').mouseover(function (e) {
		e.preventDefault();
		$("#divGoogleMapPaging").show();
		$('#basicModalContent').modal();
		FillGMap();
		CheckPaging();
	});
});

$(document).ready(function () {
	$('#basicModal input.click, #basicModal a.click, #basicModal img.click').click(function (e) {
		e.preventDefault();
		$("#divGoogleMapPaging").show();
		$('#basicModalContent').modal();
		FillGMap();
		CheckPaging();
	});
});


function DisplayHierarchyLocation(latitude,longitude,details, locationID) {

    //alert(latitude + " :: " + longitude);
    
    GetClientID();
    
    $("#" + clientID + "hddnLocationID").val(locationID);
    $("#" + clientID + "divMainMap").show();
    $("#basicModal").hide();
    $('#basicModalContent').modal();
    $("#divGoogleMapPaging").hide();

    var myLatlng = new google.maps.LatLng(latitude, longitude);
    var myOptions =
      {
          zoom: 6,
          center: myLatlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
      }

     var map = new google.maps.Map(document.getElementById(clientID + "pnlMapCanvas"), myOptions);
    //alert("googleMap from DisplayHierarchyLocation in JSGoogleMaps");
        
    Createmarkers(map,latitude,longitude,"",details);
}

//-- Changed For Google Map V3 ---
function Createmarkers(map, lat, lon, icon, details)
 {
    markerImage = DefaultHitchedMapIcon();
    var shadowImage = DefaultHitchedMapIconShadow();
    //alert(lat + " : " + lon + " : " + map);
   
    var myLatlng = new google.maps.LatLng(lat, lon);
    
    var index = -1;
    var points = [];
    var myOptions =
      {
          zoom: 9,
          center: myLatlng,
          
          mapTypeId: google.maps.MapTypeId.ROADMAP
      }

    googleMap = new google.maps.Map(document.getElementById(clientID + "pnlMapCanvas"), myOptions);
    //alert("googleMap from Createmarkers in JSGoogleMaps");
    
    index = index + 1;
    if (points != undefined)
        points[index] = myLatlng;

    var marker = new google.maps.Marker({
        position: myLatlng,
        icon: markerImage,
        shadow: shadowImage,
        draggable: true,
        bouncy: true, 
        map: googleMap

    });

    google.maps.event.addListener(marker, "dragstart", function() {
        infowindow.close();
    });
    
      
    google.maps.event.addListener(marker, "dragend", function(position) {
        infowindow.open(googleMap, marker);
        $("#" + clientID + "hddnLatitude").val(marker.getPosition().lat());
        $("#" + clientID + "hddnLongitude").val(marker.getPosition().lng());

    });

    var contentString = "Save new location?<br /> <a href='javascript:SaveLocation();'>yes</a>";
    infowindow = new google.maps.InfoWindow({ content: contentString });
        
    //FitGoogleMap();
}


function DisplaySupplierMap(latitudeList,longitudeList,icon,locationDetailsList) {
    //alert("DisplaySupplierMap");
    GetClientID();
    var index = 0;
    var  map = new GMap2(document.getElementById(clientID + "pnlMapCanvas"));
    if(latitudeList.length > 0)
    {
        var center = new GLatLng(latitudeList[0],longitudeList[0]);
        map.setCenter(center, 6);       
        var pointArray = new Array();
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.enableDoubleClickZoom();
        for(index = 0;index < latitudeList.length ;index++)
        {
           Createmarkers(map,latitudeList[index],longitudeList[index],icon[index],locationDetailsList[index]);
    		}
    }
}
      
function SaveLocation() {
    var myId = $("#" + clientID + "hddnLocationID").val();
    var mylat = $("#" + clientID + "hddnLatitude").val();
    var mylng = $("#" + clientID + "hddnLongitude").val();

   // LocationManagement.SaveLocationMapping(myId, mylat, mylng);


    var q = $HitchedAjaxOptions;
    q.url = asmxHierarchyManagement + "SaveLocationMapping";
    q.data = "{id:" + myId + ",latitude:'" + mylat + "'" + ",longitude:'" + mylng + "'}";
    q.success = CallBackSaveLocationMapping;
    $.ajax(q);

    infowindow.close();
}

function SetPageIndex(value)
{
    GetClientID();
    if($('#'+clientID + "hdnCurrentPageIndex"))
    {
       $('#'+clientID + "hdnCurrentPageIndex").val(value);
    }
} 

function ClearMarkers()
{
    lstLatitude = new Array();
    lstlongitude = new Array();
    lstlocationDetails = new Array();
    lstMapIcon = new Array();
}
function GetClientID()
{
    if($("#hdnClientID"))
    {
        clientID = $("#hdnClientID").val() + "_"; 
    }
    else
    {
        clientID = "ctl00_ContentMainPane_ctl00_";
    }
}


function FillVenueGMap()
{  
    GetClientID();
    if($('#'+clientID + "hddnLatitude"))
    {
        var lati =$('#'+ clientID + "hddnLatitude").val();    
        var longi = $('#'+ clientID + "hddnLongitude").val();  
        CreateMap(lati,longi);
    }  
}
function FillGMap()
{  
    FillVenueGMap();
    var index = 0;

    var length = lstLatitude.length;
    for(index = 0;index < length ;index++)
    {
         SetMapMarker(lstLatitude[index],lstlongitude[index],lstlocationDetails[index],lstMapIcon[index],0);
    } 
}

function ShowMap()
{
   $("#basicModalContent").css('display','inline');
}

function HideMap() {
    $("#basicModalContent").css('display', 'none');
   
}


//-- Changed For Google Map V3 ---

function CreateMap(latitude,longitude) {
    
    //alert(latitude + " : " + longitude);
    
    var myLatlng = new google.maps.LatLng(latitude, longitude);
    var myOptions =
      {
          zoom: 8,
          center: myLatlng,
          bouncy: false,
          mapTypeControl: true,
          mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR },
          navigationControl: true,
          navigationControlOptions: { style: google.maps.NavigationControlStyle.ZOOM_PAN },
          mapTypeId: google.maps.MapTypeId.ROADMAP
	};
      googleMap = new google.maps.Map(document.getElementById(clientID + "pnlMapCanvas"), myOptions);
      //alert("googleMap from CreateMap in JSGoogleMaps");

}

function SetMapMarker(latitude, longitude, locationDetails,markerIcon,saveDetails)
{
		//alert("SetMapMarker");
    // alert(latitude + " : " + longitude);
    markerImage = "http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png";
    var shadowImage = DefaultHitchedMapIconShadow();

    var markerPoint = new google.maps.LatLng(latitude, longitude);
    var myOptions =
    {
          zoom: 9,
          center: markerPoint,
          mapTypeId: google.maps.MapTypeId.ROADMAP
      }
    if(IsMarkerDraggable()) {
        googleMap = new google.maps.Map(document.getElementById(clientID + "pnlMapCanvas"), myOptions);
        //alert("googleMap from SetMapMarker in JSGoogleMaps");
        var marker = new google.maps.Marker({
            position: markerPoint,
            icon: markerImage,
            shadow: shadowImage,
            draggable: true,
            bouncy:true,
            map: googleMap

         });

       // var contentString = locationDetails;
       // infowindow = new google.maps.InfoWindow({ content: contentString });
       
       google.maps.event.addListener(marker, "dragstart", function() {
       
            infowindow.close();
         });
        
        google.maps.event.addListener(marker, "dragend", function(position) {
            infowindow.open(googleMap, marker);
            $("#" + IDMainContent() + "txtLat").val(marker.getPosition().lat());
            $("#" + IDMainContent() + "txtLng").val(marker.getPosition().lng());

        });
       // var contentString = "Save new location?<br /> <a href='javascript:SaveLocation();'>yes</a>";
       // infowindow = new google.maps.InfoWindow({ content: contentString });

    }
    
    else
    {
        googleMap = new google.maps.Map(document.getElementById(clientID + "pnlMapCanvas"), myOptions);
        //alert("googleMap from SetMapMarker2 in JSGoogleMaps");
        var marker = new google.maps.Marker({
            position: markerPoint,
            icon: markerImage,
            shadow: shadowImage,
            draggable: false,
            map: googleMap

        });

    }   
      
    if(locationDetails !== "" && locationDetails !== undefined && locationDetails !== null) {

        var contentString = locationDetails;
        infowindow = new google.maps.InfoWindow({ content: contentString });
        google.maps.event.addListener(marker, "mouseover",
						function() 
						{
								infowindow.close();
								// Open new window with respective info
								//googleMarker.openInfoWindowHtml(locationDetails);
								infowindow.open(googleMap, marker); 
						}
				);
    }
    if(saveDetails === 1 || saveDetails === '1') {
        var markerIndex = lstLatitude.length;
        lstLatitude[markerIndex] = latitude;
        lstlongitude[markerIndex] = longitude;
        lstlocationDetails[markerIndex] = locationDetails;
        lstMapIcon[markerIndex] = markerIcon;
    }
   // FitGoogleMap();
} 
// Determine whether marker can be dragged or not.
function IsMarkerDraggable()
{
    var isMarkerDraggable = false;
    var hdnMarkerDraggable = $("#hdnMarkerDraggable");

    if (hdnMarkerDraggable.val())
    {
        isMarkerDraggable = hdnMarkerDraggable.val();
    }
    if(isMarkerDraggable === "False" || isMarkerDraggable === "false" || isMarkerDraggable === false)
    {
        isMarkerDraggable = false; 
    }
    else
    {
       
        isMarkerDraggable =  true; 
    }
    
    return isMarkerDraggable;
    
}



//Google Map address.js
var globalCurrentPageNo = 0;
var globalTotalPages = 0;
var getListing= false;
var result= true;
var searchItem;
var isMapVisible = false;


var asmxSuppliers = "/API/Suppliers/JSWSSuppliers.asmx/";

var $HitchedAjaxOptions = {
type: "POST",
contentType: "application/json; charset=utf-8",
      dataType: "text",dataFilter: function (data, type) {return $.parseJSON(data);},
      error: function(result) {
          if (this.console && typeof console.log != "undefined")
              console.log("Error in server:" + result.status + ' ' + result.statusText);
      },cache:false};



function DisplaySuppliers(supplierListingClientID,latitudeList,longitudeList,iconList,locationDetailsList)
{
    
        var latitude = latitudeList.split('||');
        var longitude = longitudeList.split('||');
        var locationDetails = locationDetailsList.split('||');
        var icon = iconList.split('||');
        var index = 0;
        var googleMapClientID ="#" + $("#hdnClientID").val() + "_"; 
        supplierListingClientID = "#" + supplierListingClientID + "_"; 
         $(supplierListingClientID + "lblSupplierErrorMsg").html("");
        
        if(!IsListEmpty(latitude)) 
        {
            $(googleMapClientID + "divMainMap").show();
        
            if(!isMapVisible)
            {
                $("#basicModal").hide();
            }
        
            $('#basicModalContent').modal();
            $("#divGoogleMapPaging").hide();
            
            DisplaySupplierMap(latitude,longitude,icon,locationDetails);
        }
        else
        {
            $(supplierListingClientID + "lblSupplierErrorMsg").html("No results found");
        }    
        return false;
   
}
function IsListEmpty(locationList)
{
    var _isListEmpty = true;
    
    if(locationList!== null)
    {
        if(locationList !== "")
        {
            _isListEmpty =  false;
        }
    }
    return _isListEmpty;
}
function ToggleFieldEnableStatus(chkAddressId,titleID,streetID,localityID,countyID,countryID,postCodeID,pnlMapID)
{
    
    var isEnabled = false;

    if ($('#' + chkAddressId).is(':checked'))
    {
         $('#'+pnlMapID).css('display','none');
         isEnabled = true;
    }
    else
    {
       $('#'+pnlMapID).css('display','block');
        
    }
    EnableDisableControls(isEnabled,titleID,streetID,localityID,countyID,countryID,postCodeID);
}
function EnableDisableControls(isEnabled,titleID,streetID,localityID,countyID,countryID,postCodeID)
{
    $('#'+titleID).attr('disabled',isEnabled);
    $('#'+streetID).attr('disabled',isEnabled);
    $('#'+localityID).attr('disabled',isEnabled);
    $('#'+countyID).attr('disabled',isEnabled);
    $('#'+countryID).attr('disabled',isEnabled);
    $('#'+postCodeID).attr('disabled',isEnabled);
    if(!isEnabled)
    {
        // Recreate the map.
        FillGMap();
    }
}
function ShowGoogleMap()
{
       $('#basicModalContent').modal();
       FillGMap();
}
function BindFashionSupplierListing(pageSize,range,searchText)
{
      var clientID = $("#hdnClientID").val()+ "_"; 
        var index;
        
        EnableDisablePaging(globalTotalPages,globalCurrentPageNo);
        
        if(getListing)
        {
            var latitude = $('#'+clientID + "hddnLatitude").val();
            var longitude = $('#'+clientID + "hddnLongitude").val();
            
            GetSearchItem(latitude, longitude, "", range, globalCurrentPageNo, pageSize);            
             var q = $HitchedAjaxOptions; 
             q.url = asmxSuppliers + "GetFashionSupplierListingByGeoCode";                 
             q.data = "{searchText:'" + _searchText + "'}";                        
             q.success = CallBackBindFashionSupplierListing;  
             $.ajax(q);               
        }
        
        return false;
    }

function CallBackBindFashionSupplierListing(result)
{
if(result.d.length > 0)
            {
               BuildMap();
               
            }
            else
            {
                alert("No result to show");
            }
}

function CallBackBindSupplierListing(result)
{
     if(result.length > 0)
                 {
               BuildMap();
               
            }
            else
            {
                alert("No result to show");
            }
}

function BindSupplierListing(pageSize,range,categoryID)
{
 
        var clientID = $("#hdnClientID").val() + "_"; 
        var index;
        
        EnableDisablePaging(globalTotalPages,globalCurrentPageNo);
        
        if(getListing)
        {
            var latitude = $('#'+clientID + "hddnLatitude").val();
            var longitude = $('#'+clientID + "hddnLongitude").val();            
            var q = $HitchedAjaxOptions; 
            q.url = asmxSuppliers + "GetSupplierListingByGeoCode";                 
            q.data = "{latitude:'" + latitude + "',longitude:'" + longitude + "',categoryID:'" + categoryID + "',range:" + range + ",currentPageNo:" + globalCurrentPageNo + ",pageSize:" + pageSize + "}";                        
            q.success = CallBackBindSupplierListing;  
            $.ajax(q);   
        }
        
        
        return false;
     
}




function GetSearchItem(latitude, longitude, categoryID, range, currentPageNo, pageSize)
{
    // search item is used in fashionlisting.js so did not changed to call back method          
    $.ajax({
      async: false,
      type: "POST",
      url: asmxSuppliers + "GetSearchItem",
      data: "{latitude:" + parseFloat(latitude) + ",longitude:" + parseFloat(longitude) + ",categoryID:'" + categoryID + "',range:" + parseInt(range,10) + ",currentPageNo:" + parseInt(currentPageNo,10) + ",pageSize:" + parseInt(pageSize,10) + "}",
      contentType: "application/json; charset=utf-8",      
      dataType: "text",dataFilter: function (data, type) {return $.parseJSON(data);},
      success:function(resultReturn){      
      searchItem=resultReturn.d;
      }      
    });    
}



function BuildMap()
{
     var googleMapClientID ="#" + $("#hdnClientID").val() + "_"; 
     
     $(googleMapClientID + "divMainMap").show();

     ClearMarkers();
            
     FillVenueGMap();
      
     for(index=0;index<result.length;index++)
     {
        SetMapMarker(result[index].Latitude,result[index].Longitude,result[index].LocationDetails,result[index].IconFile,1);
     }
}
/************************* Function used for demo map *****************************/
function ShowRecords(showLocationDetails)
{
     
        var clientID = $("#hdnClientID").val() + "_"; 
        var index;
        EnableDisablePaging(globalTotalPages,globalCurrentPageNo);
        if(getListing)
        {
            var range = parseInt($("#txtRange").val(),10);
            var latitude = $('#'+clientID + "hddnLatitude").val();
            var longitude = $('#'+clientID + "hddnLongitude").val();
            DemoListing.GetSupplierListingByGeoCode(latitude,longitude,"",range,globalCurrentPageNo,5,showLocationDetails,CallBackGetSupplierListingByGeoCode) ;         
            
        }
        
        return false;
   
    
}

function CallBackGetSupplierListingByGeoCode(result)
{
  if(result.length > 0)
            {
                BuildMap();
                DemoListing.GetSupplierListing(result,CallbackGetSupplierListing);               
            }
            else
            {
                alert("No result to show");
            }
}

function CallbackGetSupplierListing(result)
{
     $("#divSupplierDetails").html(result.value);
}

/************** Functions used for google map paging *********************************/
function IsFirstPage(isEnabled)
{
    if($("#hdnClientID"))
    {
        var clientID = $("#hdnClientID").val() + "_"; 
        if(isEnabled)
        {
            $('#'+clientID + "lnkFirst").css('color','#380062');
            $('#'+clientID + "lnkPrev").css('color','#380062');
            $('#'+clientID + "lnkFirst").css('textDecoration','underline');
            $('#'+clientID + "lnkPrev").css('textDecoration','underline');
            $('#'+clientID + "lnkFirst").css('cursor','pointer');
            $('#'+clientID + "lnkPrev").css('cursor','pointer');
        }
        else
        {
            $('#'+clientID + "lnkFirst").css('color','#696969');
            $('#'+clientID + "lnkPrev").css('color','#696969');
            $('#'+clientID + "lnkFirst").css('textDecoration','none');
            $('#'+clientID + "lnkPrev").css('textDecoration','none');
            $('#'+clientID + "lnkFirst").css('cursor','text');
            $('#'+clientID + "lnkPrev").css('cursor','text');
        }
    }      
    
}
function IsLastPage(isEnabled)
{
    if($("#hdnClientID"))
    {
        var clientID = $("#hdnClientID").val() + "_"; 
        if(isEnabled)
        {      
            
            $('#'+clientID + "lnkNext").css('color','#380062');
            $('#'+clientID + "lnkLast").css('color','#380062');
            $('#'+clientID + "lnkNext").css('textDecoration','underline');
            $('#'+clientID + "lnkLast").css('textDecoration','underline');
            $('#'+clientID + "lnkNext").css('cursor','pointer');
            $('#'+clientID + "lnkLast").css('cursor','pointer');
            
        }
        else
        {            
            $('#'+clientID + "lnkNext").css('color','#696969');
            $('#'+clientID + "lnkLast").css('color','#696969');
            $('#'+clientID + "lnkNext").css('textDecoration','none');
            $('#'+clientID + "lnkLast").css('textDecoration','none');
            $('#'+clientID + "lnkNext").css('cursor','text');
            $('#'+clientID + "lnkLast").css('cursor','text');
        }
    }        
   
}
function CheckPaging()
{
   
        var clientID = $("#hdnClientID").val() + "_"; 
        if(globalCurrentPageNo !== null && globalCurrentPageNo !== 0)
        {
            $('#'+clientID + "hdnCurrentPageIndex").val(globalCurrentPageNo); 
            $('#'+clientID + "lblCurrentPage").html(globalCurrentPageNo); 
        }
        var totalPages = parseInt($('#'+clientID + "hdnTotalPages").val(),10); 
       
        if(globalCurrentPageNo <= 1)
        {
            IsFirstPage(false);
        }
        else
        {
            IsFirstPage(true);
        }
        
        
        if(globalCurrentPageNo >= totalPages)
        {
            IsLastPage(false);
        }
        else
        {
            IsLastPage(true);
        }
        
   
}
function NextPrevPages_Click(totalPages, pageIndex, lblCurrentPageIndex, value)
{
  
        
        getListing = true;
        var clientID = $("#hdnClientID").val() + "_"; 
        var currentPageNo = parseInt($('#'+pageIndex).val(),10); 
        currentPageNo = currentPageNo + value;
        totalPages = $('#'+totalPages).val();
        
        
        if(currentPageNo < 1 || currentPageNo > parseInt(totalPages,10))
        {
            getListing = false;
            return;
           // return false;
        }
        
        globalCurrentPageNo = currentPageNo;
        globalTotalPages = totalPages;
              
        $('#'+pageIndex).val(currentPageNo);
        $('#'+lblCurrentPageIndex).html(currentPageNo);  
   
}

function LastPage_Click(hdnTotalPages, hdnPageIndex, lblCurrentPageIndex)
{
    getListing = true;
    var totalPages = parseInt($("#" + hdnTotalPages).val(),10);
    var pageIndex = parseInt($("#" + hdnPageIndex).val(),10);
    var currentPage = parseInt($("#" + lblCurrentPageIndex).html(),10);
    
    if(currentPage == totalPages)
    {
        getListing = false;
        return;
    }
    
    globalCurrentPageNo = totalPages;
    globalTotalPages = totalPages;
    $("#" + hdnPageIndex).val(totalPages);
    $("#" + lblCurrentPageIndex).html(totalPages);
   
}
function FistPage_Click(totalPages, pageIndex, lblCurrentPageIndex,currentPageNo)
{
    
        getListing = true;
        var clientID = $("#hdnClientID").val() + "_"; 
        totalPages = $('#'+totalPages).val();
        pageIndex =  $('#'+pageIndex).val();
        
        
        if(currentPageNo == parseInt(pageIndex,10))
        {
            getListing = false;
            return;
        }
        
        globalCurrentPageNo = currentPageNo;
        globalTotalPages = totalPages;
        
        $('#'+pageIndex).val(currentPageNo);
        
        $('#'+lblCurrentPageIndex).html(currentPageNo);  
        
        
  
    
}
function EnableDisablePaging(totalPages,currentPageNo)
{
    if(currentPageNo <= 1)
    {
      IsFirstPage(false);
    }
    else
    {
         IsFirstPage(true);
    }
    
    if (parseInt(currentPageNo,1) >= parseInt(totalPages,10))
    {
        IsLastPage(false);
    }
    else
    {
        IsLastPage(true);
    }
}






/*
 * SimpleModal 1.3 - jQuery Plugin
 * http://www.ericmmartin.com/projects/simplemodal/
 * Copyright (c) 2009 Eric Martin
 * Dual licensed under the MIT and GPL licenses
 * Revision: $Id: jquery.simplemodal.js 205 2009-06-12 13:29:21Z emartin24 $
 */
;(function($){var ie6=$.browser.msie&&parseInt($.browser.version)==6&&typeof window['XMLHttpRequest']!="object",ieQuirks=null,w=[];$.modal=function(data,options){return $.modal.impl.init(data,options);};$.modal.close=function(){$.modal.impl.close();};$.fn.modal=function(options){return $.modal.impl.init(this,options);};$.modal.defaults={appendTo:'body',focus:true,opacity:50,overlayId:'simplemodal-overlay',overlayCss:{},containerId:'simplemodal-container',containerCss:{},dataId:'simplemodal-data',dataCss:{},autoResize:false,zIndex:1000,close:true,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:'simplemodal-close',escClose:true,overlayClose:true,position:null,persist:false,onOpen:null,onShow:null,onClose:null};$.modal.impl={opts:null,dialog:{},init:function(data,options){if(this.dialog.data){return false;}ieQuirks=$.browser.msie&&!$.boxModel;this.opts=$.extend({},$.modal.defaults,options);this.zIndex=this.opts.zIndex;this.occb=false;if(typeof data=='object'){data=data instanceof jQuery?data:$(data);if(data.parent().parent().size()>0){this.dialog.parentNode=data.parent();if(!this.opts.persist){this.dialog.orig=data.clone(true);}}}else if(typeof data=='string'||typeof data=='number'){data=$('<div/>').html(data);}else{alert('SimpleModal Error: Unsupported data type: '+typeof data);return false;}this.create(data);data=null;this.open();if($.isFunction(this.opts.onShow)){this.opts.onShow.apply(this,[this.dialog]);}return this;},create:function(data){w=this.getDimensions();if(ie6){this.dialog.iframe=$('<iframe src="javascript:false;"/>').css($.extend(this.opts.iframeCss,{display:'none',opacity:0,position:'fixed',height:w[0],width:w[1],zIndex:this.opts.zIndex,top:0,left:0})).appendTo(this.opts.appendTo);}this.dialog.overlay=$('<div/>').attr('id',this.opts.overlayId).addClass('simplemodal-overlay').css($.extend(this.opts.overlayCss,{display:'none',opacity:this.opts.opacity/100,height:w[0],width:w[1],position:'fixed',left:0,top:0,zIndex:this.opts.zIndex+1})).appendTo(this.opts.appendTo);this.dialog.container=$('<div/>').attr('id',this.opts.containerId).addClass('simplemodal-container').css($.extend(this.opts.containerCss,{display:'none',position:'fixed',zIndex:this.opts.zIndex+2})).append(this.opts.close&&this.opts.closeHTML?$(this.opts.closeHTML).addClass(this.opts.closeClass):'').appendTo(this.opts.appendTo);this.dialog.wrap=$('<div/>').attr('tabIndex',-1).addClass('simplemodal-wrap').css({height:'100%',outline:0,width:'100%'}).appendTo(this.dialog.container);this.dialog.data=data.attr('id',data.attr('id')||this.opts.dataId).addClass('simplemodal-data').css($.extend(this.opts.dataCss,{display:'none'}));data=null;this.setContainerDimensions();this.dialog.data.appendTo(this.dialog.wrap);if(ie6||ieQuirks){this.fixIE();}},bindEvents:function(){var self=this;$('.'+self.opts.closeClass).bind('click.simplemodal',function(e){e.preventDefault();self.close();});if(self.opts.close&&self.opts.overlayClose){self.dialog.overlay.bind('click.simplemodal',function(e){e.preventDefault();self.close();});}$(document).bind('keydown.simplemodal',function(e){if(self.opts.focus&&e.keyCode==9){self.watchTab(e);}else if((self.opts.close&&self.opts.escClose)&&e.keyCode==27){e.preventDefault();self.close();}});$(window).bind('resize.simplemodal',function(){w=self.getDimensions();self.opts.autoResize?self.setContainerDimensions():self.setPosition();if(ie6||ieQuirks){self.fixIE();}else{self.dialog.iframe&&self.dialog.iframe.css({height:w[0],width:w[1]});self.dialog.overlay.css({height:w[0],width:w[1]});}});},unbindEvents:function(){$('.'+this.opts.closeClass).unbind('click.simplemodal');$(document).unbind('keydown.simplemodal');$(window).unbind('resize.simplemodal');this.dialog.overlay.unbind('click.simplemodal');},fixIE:function(){var p=this.opts.position;$.each([this.dialog.iframe||null,this.dialog.overlay,this.dialog.container],function(i,el){if(el){var bch='document.body.clientHeight',bcw='document.body.clientWidth',bsh='document.body.scrollHeight',bsl='document.body.scrollLeft',bst='document.body.scrollTop',bsw='document.body.scrollWidth',ch='document.documentElement.clientHeight',cw='document.documentElement.clientWidth',sl='document.documentElement.scrollLeft',st='document.documentElement.scrollTop',s=el[0].style;s.position='absolute';if(i<2){s.removeExpression('height');s.removeExpression('width');s.setExpression('height',''+bsh+' > '+bch+' ? '+bsh+' : '+bch+' + "px"');s.setExpression('width',''+bsw+' > '+bcw+' ? '+bsw+' : '+bcw+' + "px"');}else{var te,le;if(p&&p.constructor==Array){var top=p[0]?typeof p[0]=='number'?p[0].toString():p[0].replace(/px/,''):el.css('top').replace(/px/,'');te=top.indexOf('%')==-1?top+' + (t = '+st+' ? '+st+' : '+bst+') + "px"':parseInt(top.replace(/%/,''))+' * (('+ch+' || '+bch+') / 100) + (t = '+st+' ? '+st+' : '+bst+') + "px"';if(p[1]){var left=typeof p[1]=='number'?p[1].toString():p[1].replace(/px/,'');le=left.indexOf('%')==-1?left+' + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"':parseInt(left.replace(/%/,''))+' * (('+cw+' || '+bcw+') / 100) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}}else{te='('+ch+' || '+bch+') / 2 - (this.offsetHeight / 2) + (t = '+st+' ? '+st+' : '+bst+') + "px"';le='('+cw+' || '+bcw+') / 2 - (this.offsetWidth / 2) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}s.removeExpression('top');s.removeExpression('left');s.setExpression('top',te);s.setExpression('left',le);}}});},focus:function(pos){var self=this,p=pos||'first';var input=$(':input:enabled:visible:'+p,self.dialog.wrap);input.length>0?input.focus():self.dialog.wrap.focus();},getDimensions:function(){var el=$(window);var h=$.browser.opera&&$.browser.version>'9.5'&&$.fn.jquery<='1.2.6'?document.documentElement['clientHeight']:$.browser.opera&&$.browser.version<'9.5'&&$.fn.jquery>'1.2.6'?window.innerHeight:el.height();return[h,el.width()];},getVal:function(v){return v=='auto'?0:parseInt(v.replace(/px/,''));},setContainerDimensions:function(){var ch=this.getVal(this.dialog.container.css('height')),cw=this.dialog.container.width(),dh=this.dialog.data.height(),dw=this.dialog.data.width();var mh=this.opts.maxHeight&&this.opts.maxHeight<w[0]?this.opts.maxHeight:w[0],mw=this.opts.maxWidth&&this.opts.maxWidth<w[1]?this.opts.maxWidth:w[1];if(!ch){if(!dh){ch=this.opts.minHeight;}else{if(dh>mh){ch=mh;}else if(dh<this.opts.minHeight){ch=this.opts.minHeight;}else{ch=dh;}}}else{ch=ch>mh?mh:ch;}if(!cw){if(!dw){cw=this.opts.minWidth;}else{if(dw>mw){cw=mw;}else if(dw<this.opts.minWidth){cw=this.opts.minWidth;}else{cw=dw;}}}else{cw=cw>mw?mw:cw;}this.dialog.container.css({height:ch,width:cw});if(dh>ch||dw>cw){this.dialog.wrap.css({overflow:'auto'});}this.setPosition();},setPosition:function(){var top,left,hc=(w[0]/2)-((this.dialog.container.height()||this.dialog.data.height())/2),vc=(w[1]/2)-((this.dialog.container.width()||this.dialog.data.width())/2);if(this.opts.position&&this.opts.position.constructor==Array){top=this.opts.position[0]||hc;left=this.opts.position[1]||vc;}else{top=hc;left=vc;}this.dialog.container.css({left:left,top:top});},watchTab:function(e){var self=this;if($(e.target).parents('.simplemodal-container').length>0){self.inputs=$(':input:enabled:visible:first, :input:enabled:visible:last',self.dialog.data);if(!e.shiftKey&&e.target==self.inputs[self.inputs.length-1]||e.shiftKey&&e.target==self.inputs[0]||self.inputs.length==0){e.preventDefault();var pos=e.shiftKey?'last':'first';setTimeout(function(){self.focus(pos);},10);}}else{e.preventDefault();setTimeout(function(){self.focus();},10);}},open:function(){this.dialog.iframe&&this.dialog.iframe.show();if($.isFunction(this.opts.onOpen)){this.opts.onOpen.apply(this,[this.dialog]);}else{this.dialog.overlay.show();this.dialog.container.show();this.dialog.data.show();}this.focus();this.bindEvents();},close:function(){if(!this.dialog.data){return false;}this.unbindEvents();if($.isFunction(this.opts.onClose)&&!this.occb){this.occb=true;this.opts.onClose.apply(this,[this.dialog]);}else{if(this.dialog.parentNode){if(this.opts.persist){this.dialog.data.hide().appendTo(this.dialog.parentNode);}else{this.dialog.data.hide().remove();this.dialog.orig.appendTo(this.dialog.parentNode);}}else{this.dialog.data.hide().remove();}this.dialog.container.hide().remove();this.dialog.overlay.hide().remove();this.dialog.iframe&&this.dialog.iframe.hide().remove();this.dialog={};}}};})(jQuery);/* =========================================================

// jquery.innerfade.js

// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com

// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
// and Ralf S. Engelschall http://trainofthoughts.org/

 *
 *  <ul id="news"> 
 *      <li>content 1</li>
 *      <li>content 2</li>
 *      <li>content 3</li>
 *  </ul>
 *  
 *  $('#news').innerfade({ 
 *	  animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'), 
 *	  speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'), 
 *	  timeout: Time between the fades in milliseconds (Default: '2000'), 
 *	  type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'), 
 * 		containerheight: Height of the containing element in any css-height-value (Default: 'auto'),
 *	  runningclass: CSS-Class which the container getâ€™s applied (Default: 'innerfade'),
 *	  children: optional children selector (Default: null)
 *  }); 
 *

// ========================================================= */


(function($) {

    $.fn.innerfade = function(options) {
        return this.each(function() {   
            $.innerfade(this, options);
        });
    };

    $.innerfade = function(container, options) {
        var settings = {
        		'animationtype':    'fade',
            'speed':            'normal',
            'type':             'sequence',
            'timeout':          2000,
            'containerheight':  'auto',
            'runningclass':     'innerfade',
            'children':         null
        };
        if (options)
            $.extend(settings, options);
        if (settings.children === null || settings.children === undefined)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i++) {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
                setTimeout(function() {
                    $.innerfade.next(elements, settings, 1, 0);
                }, settings.timeout);
                $(elements[0]).show();
            } else if (settings.type == "random") {
            		var last = Math.floor ( Math.random () * ( elements.length ) );
                setTimeout(function() {
                    do { 
												current = Math.floor ( Math.random ( ) * ( elements.length ) );
										} while (last == current );             
										$.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
						} else if ( settings.type == 'random_start' ) {
								settings.type = 'sequence';
								var current = Math.floor ( Math.random () * ( elements.length ) );
								setTimeout(function(){
									$.innerfade.next(elements, settings, (current + 1) %  elements.length, current);
								}, settings.timeout);
								$(elements[current]).show();
						}	else {
							alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
						}
				}
    };

    $.innerfade.next = function(elements, settings, current, last) {
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
							removeFilter($(this)[0]);
						});
        } else
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        if (settings.type == "sequence") {
            if ((current + 1) < elements.length) {
                current = current + 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
        setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
	if(element.style.removeAttribute){
		element.style.removeAttribute('filter');
	}
}
(function ($) {
    $.fn.jCarouselLite = function(o) {
        o = $.extend({
            btnPrev: null,
            btnNext: null,
            btnGo: null,
            mouseWheel: false,
            auto: null,

            speed: 200,
            easing: null,

            vertical: false,
            circular: true,
            visible: 3,
            start: 0,
            scroll: 1,
            rows: 1, //ADDED: Property to allow multiple rows

            beforeStart: null,
            afterEnd: null
        }, o || {});

        return this.each(function() {                           // Returns the element collection. Chainable.

            var running = false, animCss = o.vertical ? "top" :"left", sizeCss = o.vertical ? "height" : "width";
            var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;
            var rowCss = o.vertical ? "width" : "height"; //ADDED: rowCss is used to set the height/width of the viewport based on how many rows are showing

            if (o.circular) {
                ul.prepend(tLi.slice(tl - v - 1 + 1).clone())
              .append(tLi.slice(0, v).clone());
                o.start += v;
            }

            var li = $("li", ul), itemLength = li.size(), curr = o.start;
            div.css("visibility", "visible");

            li.css({ overflow: "hidden", float: o.vertical ? "none" :"left" });
            ul.css({ margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1" });
            div.css({ overflow: "hidden", position: "relative", "z-index": "2", left: "0px" });

            var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation
            var liRowSize = o.vertical ? width(li) : height(li);   // ADDED: size of the li's row
            var ulSize = ((liSize * itemLength) / o.rows) + (liSize / 1.5);                   // size of full ul(total length, not just for the visible items)
            var divSize = liSize * v;                          // size of entire div(total length for just the visible items)
            var rowSize = liRowSize * o.rows; //ADDED: gets the size in pixels of the height/width of the viewport

            li.css({ width: li.width(), height: li.height() });
            ul.css(sizeCss, ulSize + "px").css(animCss, -(curr * liSize));

            div.css(sizeCss, divSize + "px");                     // Width of the DIV. length of visible images
            div.css(rowCss, rowSize + "px");                     // ADDED: Height of the DIV

            //ADDED: special consideration for vertical carousels with multiple rows
            if (o.vertical && o.rows > 1) {
                ul.children().filter(function(index) {
                    return ((index + 1) % o.rows > 0);
                }).css({ float: "left", width: "" });
            }

            if (o.btnPrev)
                $(o.btnPrev).click(function() {
                    return go(curr - (o.scroll));
                });

            if (o.btnNext)
                $(o.btnNext).click(function() {
                    return go(curr + (o.scroll));
                });

            if (o.btnGo)
                $.each(o.btnGo, function(i, val) {
                    $(val).click(function() {
                        return go(o.circular ? o.visible + i : i);
                    });
                });

            if (o.mouseWheel && div.mousewheel)
                div.mousewheel(function(e, d) {
                    return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll);
                });

            if (o.auto)
                setInterval(function() {
                    go(curr + o.scroll);
                }, o.auto + o.speed);

            function vis() {
                return li.slice(curr).slice(0, v);
            };

            function go(to) {
                if (!running) {

                    if (o.beforeStart)
                        o.beforeStart.call(this, vis());

                    if (o.circular) {            // If circular we are in first or last, then goto the other end
                        if (to <= o.start - v - 1) {           // If first, then goto last
                            ul.css(animCss, -((itemLength - (v * 2)) * liSize) + "px");
                            // If "scroll" > 1, then the "to" might not be equal to the condition; it can be lesser depending on the number of elements.
                            curr = to == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll;
                        } else if (to >= itemLength - v + 1) { // If last, then goto first
                            ul.css(animCss, -((v) * liSize) + "px");
                            // If "scroll" > 1, then the "to" might not be equal to the condition; it can be greater depending on the  of elements.
                            curr = to == itemLength - v + 1 ? v + 1 : v + o.scroll;
                        } else curr = to;
                    } else {                    // If non-circular and to points to first or last, we just return.
                        //ADDED: This determines when to stop scrolling when more than 1 row is viewable
                        if (to < 0 || to > ((itemLength - v) / o.rows)) return;
                        else curr = to;
                    }                           // If neither overrides it, the curr will still be "to" and we can proceed.

                    running = true;

                    ul.animate(
                    animCss == "left" ? { left: -(curr * liSize)} : { top: -(curr * liSize) }, o.speed, o.easing,
                    function() {
                        if (o.afterEnd)
                            o.afterEnd.call(this, vis());
                        running = false;
                    }
                );
                    // Disable buttons when the carousel reaches the last/first, and enable when not
                    if (!o.circular) {
                        $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
                        //ADDED: This determines when to add the disabled class to the link when more than 1 row is viewable
                        $((curr - o.scroll < 0 && o.btnPrev)
                        ||
                        (curr + o.scroll > ((itemLength - v) / o.rows) && o.btnNext)
                        ||
                        []
                        ).addClass("disabled");
                    }
                }
                return false;
            };
        });
    };

    function css(el, prop) {
        return parseInt($.css(el[0], prop)) || 0;
    };
    function width(el) {
        return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
    };
    function height(el) { 
        return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
    };

})(jQuery);/*
 * JQZoom Evolution 1.0.1 - Javascript Image magnifier
 *
 * Copyright (c) Engineer Renzi Marco(www.mind-projects.it)
 *
 * $Date: 12-12-2008
 *
 *	ChangeLog:
 *  
 * $License : GPL,so any change to the code you should copy and paste this section,and would be nice to report this to me(renzi.mrc@gmail.com).
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.30.31=6(G){I H={17:\'32\',18:2l,19:2l,1a:10,1b:0,Q:"2m",2n:1s,2o:12,2p:0.3,14:1s,1p:12,2q:\'1g\',2r:\'23\',2s:\'24\',2t:\'33\',2u:12,2v:1s,2w:\'34 35\',2x:\'1t\'};G=G||{};$.36(H,G);R 4.37(6(){I a=$(4);I d=a.1q(\'14\');$(a).1Q(\'14\');$(a).J(\'38-K\',\'1r\');$(a).J(\'39-3a\',\'1r\');I f=$(a).1q(\'3b\');I g=$("1H",4);I j=g.1q(\'14\');g.1Q(\'14\');I k=U 25(g);I l={};I m=0;I n=0;I p=1u;p=U 1R();I q=(26(d).Y>0)?d:(26(j).Y>0)?j:1u;I r=U 27();I s=U 1v(a[0].2y);I t=U 1c();I u={};I v=12;I y={};I z=1u;I A=12;I B={};I C=0;I D=12;I E=12;I F=12;k.1I();$(4).3c(6(){R 12});$(4).3d(6(e){B.x=e.1w;B.y=e.1x;k.1S();1d()},6(){k.1S();2z()});8(H.1p){2A(6(){1d()},3e)}6 1d(){8(!A){k.28();A=1s;j=g.1q(\'14\');g.1Q(\'14\');d=a.1q(\'14\');$(a).1Q(\'14\');s=U 1v(a[0].2y);8(!v||$.1e.2B){s.1I()}V{8(H.17!=\'1j\'){z=U 1J();z.1d()}t=U 1c;t.1d()}a[0].3f();R 12}};6 2z(){8(H.17==\'1K\'&&!H.1p){g.J({\'1T\':1})}8(!H.1p){A=12;v=12;$(t.5).29(\'1L\');t.Z();8($(\'P.1M\').Y>0){z.Z()}8($(\'P.2a\').Y>0){r.Z()}g.1q(\'14\',j);a.1q(\'14\',d);$().29();a.29(\'1L\');C=0;8(1y(\'.2b\').Y>0){1y(\'.2b\').Z()}}V{8(H.2o){1k(H.17){11\'1j\':s.2c();N;1l:t.1t();N}}}8(H.1p){1d()}};6 25(c){4.5=c[0];4.1I=6(){4.5.1m=c[0].1m};4.28=6(){I a=\'\';a=$(g).J(\'2C-L-W\');m=\'\';I b=\'\';b=$(g).J(\'2C-M-W\');n=\'\';8(a){1U(i=0;i<3;i++){I x=[];x=a.1n(i,1);8(1V(x)==12){m=m+\'\'+a.1n(i,1)}V{N}}}8(b){1U(i=0;i<3;i++){8(!1V(b.1n(i,1))){n=n+b.1n(i,1)}V{N}}}m=(m.Y>0)?1W(m):0;n=(n.Y>0)?1W(n):0};4.5.2D=6(){a.J({\'2E\':\'2F\',\'1h\':\'1X\'});8(a.J(\'Q\')!=\'15\'&&a.2d().J(\'Q\')){a.J({\'2E\':\'2F\',\'Q\':\'2G\',\'1h\':\'1X\'})}8(a.2d().J(\'Q\')!=\'15\'){a.2d().J(\'Q\',\'2G\')}V{}8($.1e.2B||$.1e.3g){$(g).J({Q:\'15\',L:\'2H\',M:\'2H\'})}l.w=$(4).W();l.h=$(4).1f();l.9=$(4).1i();l.9.l=$(4).1i().M;l.9.t=$(4).1i().L;l.9.r=l.w+l.9.l;l.9.b=l.h+l.9.t;a.1f(l.h);a.W(l.w);8(H.2u){k.1S();s.1I()}};R 4};25.13.1S=6(){l.9=$(g).1i();l.9.l=$(g).1i().M;l.9.t=$(g).1i().L;l.9.r=l.w+l.9.l;l.9.b=l.h+l.9.t};6 1c(){4.5=16.2e("P");$(4.5).1Y(\'X\');4.5.3h=6(){$(t.5).Z();t=U 1c();t.1d()};4.2I=6(){1k(H.17){11\'1K\':4.1z=U 1Z();4.1z.1m=k.5.1m;4.5.1N(4.1z);$(4.5).J({\'1T\':1});N;11\'1j\':4.1z=U 1Z();4.1z.1m=s.5.1m;4.5.1N(4.1z);$(4.5).J({\'1T\':1});N;1l:N}1k(H.17){11\'1j\':u.w=l.w;u.h=l.h;N;1l:u.w=(H.18)/y.x;u.h=(H.19)/y.y;N}$(4.5).J({W:u.w+\'S\',1f:u.h+\'S\',Q:\'15\',1h:\'1r\',3i:1+\'S\'});a.3j(4.5)};R 4};1c.13.1d=6(){4.2I();1k(H.17){11\'1K\':g.J({\'1T\':H.2p});(H.1p)?t.1t():t.1o(1u);a.2f(\'1L\',6(e){B.x=e.1w;B.y=e.1x;t.1o(e)});N;11\'1j\':$(4.5).J({L:0,M:0});8(H.14){r.2g()}s.2c();a.2f(\'1L\',6(e){B.x=e.1w;B.y=e.1x;s.2J(e)});N;1l:(H.1p)?t.1t():t.1o(1u);$(a).2f(\'1L\',6(e){B.x=e.1w;B.y=e.1x;t.1o(e)});N}R 4};1c.13.1o=6(e){8(e){B.x=e.1w;B.y=e.1x}8(C==0){I b=(l.w)/2-(u.w)/2;I c=(l.h)/2-(u.h)/2;$(\'P.X\').1g();8(H.2n){4.5.K.20=\'2K\'}V{4.5.K.20=\'2h\';$(\'P.X\').23()}C=1}V{I b=B.x-l.9.l-(u.w)/2;I c=B.y-l.9.t-(u.h)/2}8(2L()){b=0+n}V 8(2M()){8($.1e.1O&&$.1e.2i<7){b=l.w-u.w+n-1}V{b=l.w-u.w+n-1}}8(2N()){c=0+m}V 8(2O()){8($.1e.1O&&$.1e.2i<7){c=l.h-u.h+m-1}V{c=l.h-u.h-1+m}}b=1A(b);c=1A(c);$(\'P.X\',a).J({L:c,M:b});8(H.17==\'1K\'){$(\'P.X 1H\',a).J({\'Q\':\'15\',\'L\':-(c-m+1),\'M\':-(b-n+1)})}4.5.K.M=b+\'S\';4.5.K.L=c+\'S\';s.1o();6 2L(){R B.x-(u.w+2*1)/2-n<l.9.l}6 2M(){R B.x+(u.w+2*1)/2>l.9.r+n}6 2N(){R B.y-(u.h+2*1)/2-m<l.9.t}6 2O(){R B.y+(u.h+2*1)/2>l.9.b+m}R 4};1c.13.1t=6(){$(\'P.X\',a).J(\'1h\',\'1r\');I b=(l.w)/2-(u.w)/2;I c=(l.h)/2-(u.h)/2;4.5.K.M=b+\'S\';4.5.K.L=c+\'S\';$(\'P.X\',a).J({L:c,M:b});8(H.17==\'1K\'){$(\'P.X 1H\',a).J({\'Q\':\'15\',\'L\':-(c-m+1),\'M\':-(b-n+1)})}s.1o();8($.1e.1O){$(\'P.X\',a).1g()}V{2A(6(){$(\'P.X\').2P(\'24\')},10)}};1c.13.1P=6(){I o={};o.M=1A(4.5.K.M);o.L=1A(4.5.K.L);R o};1c.13.Z=6(){8(H.17==\'1j\'){$(\'P.X\',a).2Q(\'24\',6(){$(4).Z()})}V{$(\'P.X\',a).Z()}};1c.13.28=6(){I a=\'\';a=$(\'P.X\').J(\'3k\');1B=\'\';I b=\'\';b=$(\'P.X\').J(\'3l\');1C=\'\';8($.1e.1O){I c=a.2R(\' \');a=c[1];I c=b.2R(\' \');b=c[1]}8(a){1U(i=0;i<3;i++){I x=[];x=a.1n(i,1);8(1V(x)==12){1B=1B+\'\'+a.1n(i,1)}V{N}}}8(b){1U(i=0;i<3;i++){8(!1V(b.1n(i,1))){1C=1C+b.1n(i,1)}V{N}}}1B=(1B.Y>0)?1W(1B):0;1C=(1C.Y>0)?1W(1C):0};6 1v(a){4.2S=a;4.5=U 1Z();4.1I=6(){8(!4.5)4.5=U 1Z();4.5.K.Q=\'15\';4.5.K.1h=\'1r\';4.5.K.M=\'-3m\';4.5.K.L=\'3n\';p=U 1R();8(H.2v&&!D){p.1g();D=1s}16.2j.1N(4.5);4.5.1m=4.2S};4.5.2D=6(){4.K.1h=\'1X\';I w=O.21($(4).W());I h=O.21($(4).1f());4.K.1h=\'1r\';y.x=(w/l.w);y.y=(h/l.h);8($(\'P.1D\').Y>0){$(\'P.1D\').Z()}v=1s;8(H.17!=\'1j\'&&A){z=U 1J();z.1d()}8(A){t=U 1c();t.1d()}8($(\'P.1D\').Y>0){$(\'P.1D\').Z()}};R 4};1v.13.1o=6(){4.5.K.M=O.1E(-y.x*1A(t.1P().M)+n)+\'S\';4.5.K.L=O.1E(-y.y*1A(t.1P().L)+m)+\'S\'};1v.13.2J=6(e){4.5.K.M=O.1E(-y.x*O.T(e.1w-l.9.l))+\'S\';4.5.K.L=O.1E(-y.y*O.T(e.1x-l.9.t))+\'S\';$(\'P.X 1H\',a).J({\'Q\':\'15\',\'L\':4.5.K.L,\'M\':4.5.K.M})};1v.13.2c=6(){4.5.K.M=O.1E(-y.x*O.T((l.w)/2))+\'S\';4.5.K.L=O.1E(-y.y*O.T((l.h)/2))+\'S\';$(\'P.X 1H\',a).J({\'Q\':\'15\',\'L\':4.5.K.L,\'M\':4.5.K.M})};6 1J(){I a=1y(g).1i().M;I b=1y(g).1i().L;4.5=16.2e("P");$(4.5).1Y(\'1M\');$(4.5).J({Q:\'15\',W:O.21(H.18)+\'S\',1f:O.21(H.19)+\'S\',1h:\'1r\',2T:3o,3p:\'2h\'});1k(H.Q){11"2m":a=(a+$(g).W()+O.T(H.1a)+H.18<$(16).W())?(a+$(g).W()+O.T(H.1a)):(a-H.18-10);1F=b+H.1b+H.19;b=(1F<$(16).1f()&&1F>0)?b+H.1b:b;N;11"M":a=(l.9.l-O.T(H.1a)-H.18>0)?(l.9.l-O.T(H.1a)-H.18):(l.9.l+l.w+10);1F=l.9.t+H.1b+H.19;b=(1F<$(16).1f()&&1F>0)?l.9.t+H.1b:l.9.t;N;11"L":b=(l.9.t-O.T(H.1b)-H.19>0)?(l.9.t-O.T(H.1b)-H.19):(l.9.t+l.h+10);1G=l.9.l+H.1a+H.18;a=(1G<$(16).W()&&1G>0)?l.9.l+H.1a:l.9.l;N;11"3q":b=(l.9.b+O.T(H.1b)+H.19<$(16).1f())?(l.9.b+O.T(H.1b)):(l.9.t-H.19-10);1G=l.9.l+H.1a+H.18;a=(1G<$(16).W()&&1G>0)?l.9.l+H.1a:l.9.l;N;1l:a=(l.9.l+l.w+H.1a+H.18<$(16).W())?(l.9.l+l.w+O.T(H.1a)):(l.9.l-H.18-O.T(H.1a));b=(l.9.b+O.T(H.1b)+H.19<$(16).1f())?(l.9.b+O.T(H.1b)):(l.9.t-H.19-O.T(H.1b));N}4.5.K.M=a+\'S\';4.5.K.L=b+\'S\';R 4};1J.13.1d=6(){8(!4.5.3r)4.5.1N(s.5);8(H.14){r.2g()}16.2j.1N(4.5);1k(H.2q){11\'1g\':$(4.5).1g();N;11\'3s\':$(4.5).2P(H.2s);N;1l:$(4.5).1g();N}$(4.5).1g();8($.1e.1O&&$.1e.2i<7){4.3t=$(\'<2U 3u="2b" 3v="3w" 3x="0"  1m="#"  K="3y-3z: 2V" 3A="2V"></2U>\').J({Q:"15",M:4.5.K.M,L:4.5.K.L,2T:3B,W:(H.18+2),1f:(H.19)}).3C(4.5)};s.5.K.1h=\'1X\'};1J.13.Z=6(){1k(H.2r){11\'23\':$(\'.1M\').Z();N;11\'3D\':$(\'.1M\').2Q(H.2t);N;1l:$(\'.1M\').Z();N}};6 27(){4.5=1y(\'<P />\').1Y(\'2a\').2W(\'\'+q+\'\');4.2g=6(){8(H.17==\'1j\'){$(4.5).J({Q:\'15\',L:l.9.b+3,M:(l.9.l+1),W:l.w}).2k(\'2j\')}V{$(4.5).2k(z.5)}}};27.13.Z=6(){$(\'.2a\').Z()};6 1R(){4.5=16.2e("P");$(4.5).1Y(\'1D\');$(4.5).2W(H.2w);$(4.5).2k(a).J(\'20\',\'2h\');4.1g=6(){1k(H.2x){11\'1t\':2X=(l.h-$(4.5).1f())/2;2Y=(l.w-$(4.5).W())/2;$(4.5).J({L:2X,M:2Y});N;1l:I a=4.1P();N}$(4.5).J({Q:\'15\',20:\'2K\'})};R 4};1R.13.1P=6(){I o=1u;o=$(\'P.1D\').1i();R o}})}})(1y);6 26(a){2Z(a.22(0,1)==\' \'){a=a.22(1,a.Y)}2Z(a.22(a.Y-1,a.Y)==\' \'){a=a.22(0,a.Y-1)}R a};',62,226,'||||this|node|function||if|pos|||||||||||||||||||||||||||||||||||var|css|style|top|left|break|Math|div|position|return|px|abs|new|else|width|jqZoomPup|length|remove||case|false|prototype|title|absolute|document|zoomType|zoomWidth|zoomHeight|xOffset|yOffset|Lens|activate|browser|height|show|display|offset|innerzoom|switch|default|src|substr|setposition|alwaysOn|attr|none|true|center|null|Largeimage|pageX|pageY|jQuery|image|parseInt|lensbtop|lensbleft|preload|ceil|topwindow|leftwindow|img|loadimage|Stage|reverse|mousemove|jqZoomWindow|appendChild|msie|getoffset|removeAttr|Loader|setpos|opacity|for|isNaN|eval|block|addClass|Image|visibility|round|substring|hide|fast|Smallimage|trim|zoomTitle|findborder|unbind|jqZoomTitle|zoom_ieframe|setcenter|parent|createElement|bind|loadtitle|hidden|version|body|appendTo|200|right|lens|lensReset|imageOpacity|showEffect|hideEffect|fadeinSpeed|fadeoutSpeed|preloadImages|showPreload|preloadText|preloadPosition|href|deactivate|setTimeout|safari|border|onload|cursor|crosshair|relative|0px|loadlens|setinner|visible|overleft|overright|overtop|overbottom|fadeIn|fadeOut|split|url|zIndex|iframe|transparent|html|loadertop|loaderleft|while|fn|jqzoom|standard|slow|Loading|zoom|extend|each|outline|text|decoration|rel|click|hover|150|blur|opera|onerror|borderWidth|append|borderTop|borderLeft|5000px|10px|10000|overflow|bottom|firstChild|fadein|ieframe|class|name|content|frameborder|background|color|bgcolor|99|insertBefore|fadeout'.split('|'),0,{}))// JScript File


function ToggleFashionNavigation(HeaderId)
{
    if($('#slideeffectRegion' + HeaderId).is(":hidden"))
    {       
         $("#slideInRegion_" + HeaderId).css({backgroundImage :"url(/Images/down-arrow.gif)"});
         $('#slideeffectRegion' + HeaderId).slideDown('slow');  
    }   
    else
    { 
        $("#slideInRegion_" + HeaderId).css({backgroundImage :"url(/Images/left-arrow.gif)"});
        $('#slideeffectRegion' + HeaderId).slideUp('slow');          
    }
    AdjustHeight(); 
} 

function ToggleFashionSection()
{
    if($('#slideSectionRegion').is(":hidden"))
    {       
         $("#slideInSection").css({backgroundImage :"url(/Images/down-arrow.gif)"});
         $('#slideSectionRegion').slideDown('slow');  
    }   
    else
    {
        $("#slideInSection").css({backgroundImage :"url(/Images/left-arrow.gif)"});
        $('#slideSectionRegion').slideUp('slow');          
    }
    AdjustHeight(); 
} 


$(document).ready(function(){ 

    // For left hand nav
    $('div .toggle-list-head').click(function(){
        var listingId=this.id;
        listingId=listingId.split('_');
       ToggleFashionNavigation(listingId[1]);
    });
    
      $('div .toggle-section-head').click(function(){
       ToggleFashionSection();
    });


});/*
* FancyBox - jQuery Plugin
* Simple and fancy lightbox alternative
*
* Examples and documentation at: http://fancybox.net
*
* Copyright (c) 2008 - 2010 Janis Skarnelis
* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
*
* Version: 1.3.4 (11/11/2010)
* Requires: jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*/

; (function ($) {
    var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right,

		selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],

		ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,

		loadingTimer, loadingFrame = 1,

		titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),

		isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,

    /*
    * Private methods 
    */

		_abort = function () {
		    loading.hide();

		    imgPreloader.onerror = imgPreloader.onload = null;

		    if (ajaxLoader) {
		        ajaxLoader.abort();
        } 

		    tmp.empty();
		},

		_error = function () {
		    if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) {
		        loading.hide();
		        busy = false;
		        return;
		    }

		    selectedOpts.titleShow = false;

		    selectedOpts.width = 'auto';
		    selectedOpts.height = 'auto';

		    tmp.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');

		    _process_inline();
		},

		_start = function () {
		    var obj = selectedArray[selectedIndex],
				href,
				type,
				title,
				str,
				emb,
				ret;

		    _abort();

		    selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));

		    ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts);

		    if (ret === false) {
		        busy = false;
		        return;
		    } else if (typeof ret == 'object') {
		        selectedOpts = $.extend(selectedOpts, ret);
		    }

		    title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || '';

		    if (obj.nodeName && !selectedOpts.orig) {
		        selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
		    }

		    if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) {
		        title = selectedOpts.orig.attr('alt');
		    }

		    href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;

		    if ((/^(?:javascript)/i).test(href) || href == '#') {
		        href = null;
		    }

		    if (selectedOpts.type) {
		        type = selectedOpts.type;

		        if (!href) {
		            href = selectedOpts.content;
		        }

		    } else if (selectedOpts.content) {
		        type = 'html';

		    } else if (href) {
		        if (href.match(imgRegExp)) {
		            type = 'image';

		        } else if (href.match(swfRegExp)) {
		            type = 'swf';

		        } else if ($(obj).hasClass("iframe")) {
		            type = 'iframe';

		        } else if (href.indexOf("#") === 0) {
		            type = 'inline';

        } else {
		            type = 'ajax';
        } 
        } 

		    if (!type) {
		        _error();
		        return;
            } 

		    if (type == 'inline') {
		        obj = href.substr(href.indexOf("#"));
		        type = $(obj).length > 0 ? 'inline' : 'ajax';
        } 

		    selectedOpts.type = type;
		    selectedOpts.href = href;
		    selectedOpts.title = title;

		    if (selectedOpts.autoDimensions) {
		        if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') {
		            selectedOpts.width = 'auto';
		            selectedOpts.height = 'auto';
		        } else {
		            selectedOpts.autoDimensions = false;
        } 
    }

		    if (selectedOpts.modal) {
		        selectedOpts.overlayShow = true;
		        selectedOpts.hideOnOverlayClick = false;
		        selectedOpts.hideOnContentClick = false;
		        selectedOpts.enableEscapeButton = false;
		        selectedOpts.showCloseButton = false;
            } 

		    selectedOpts.padding = parseInt(selectedOpts.padding, 10);
		    selectedOpts.margin = parseInt(selectedOpts.margin, 10);

		    tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));

		    $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function () {
		        $(this).replaceWith(content.children());
		    });

		    switch (type) {
		        case 'html':
		            tmp.html(selectedOpts.content);
		            _process_inline();
		            break;

		        case 'inline':
		            if ($(obj).parent().is('#fancybox-content') === true) {
		                busy = false;
		                return;
		            }

		            $('<div class="fancybox-inline-tmp" />')
						.hide()
						.insertBefore($(obj))
						.bind('fancybox-cleanup', function () {
						    $(this).replaceWith(content.children());
						}).bind('fancybox-cancel', function () {
						    $(this).replaceWith(tmp.children());
						});

		            $(obj).appendTo(tmp);

		            _process_inline();
		            break;

		        case 'image':
		            busy = false;

		            $.fancybox.showActivity();

		            imgPreloader = new Image();

		            imgPreloader.onerror = function () {
		                _error();
		            };

		            imgPreloader.onload = function () {
		                busy = true;

		                imgPreloader.onerror = imgPreloader.onload = null;

		                _process_image();
		            };

		            imgPreloader.src = href;
		            break;

		        case 'swf':
		            selectedOpts.scrolling = 'no';

		            str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
		            emb = '';

		            $.each(selectedOpts.swf, function (name, val) {
		                str += '<param name="' + name + '" value="' + val + '"></param>';
		                emb += ' ' + name + '="' + val + '"';
		            });

		            str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';

		            tmp.html(str);

		            _process_inline();
		            break;

		        case 'ajax':
		            busy = false;

		            $.fancybox.showActivity();

		            selectedOpts.ajax.win = selectedOpts.ajax.success;

		            ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, {
		                url: href,
		                data: selectedOpts.ajax.data || {},
		                error: function (XMLHttpRequest, textStatus, errorThrown) {
		                    if (XMLHttpRequest.status > 0) {
		                        _error();
		                    }
		                },
		                success: function (data, textStatus, XMLHttpRequest) {
		                    var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader;
		                    if (o.status == 200) {
		                        if (typeof selectedOpts.ajax.win == 'function') {
		                            ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest);

		                            if (ret === false) {
		                                loading.hide();
		                                return;
		                            } else if (typeof ret == 'string' || typeof ret == 'object') {
		                                data = ret;
		                            }
		                        }

		                        tmp.html(data);
		                        _process_inline();
		                    }
		                }
		            }));

		            break;

		        case 'iframe':
		            _show();
		            break;
		    }
		},

		_process_inline = function () {
		    var 
				w = selectedOpts.width,
				h = selectedOpts.height;

		    if (w.toString().indexOf('%') > -1) {
		        w = parseInt(($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px';

		    } else {
		        w = w == 'auto' ? 'auto' : w + 'px';
		    }

		    if (h.toString().indexOf('%') > -1) {
		        h = parseInt(($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px';

		    } else {
		        h = h == 'auto' ? 'auto' : h + 'px';
		    }

		    tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>');

		    selectedOpts.width = tmp.width();
		    selectedOpts.height = tmp.height();

		    _show();
		},

		_process_image = function () {
		    selectedOpts.width = imgPreloader.width;
		    selectedOpts.height = imgPreloader.height;

		    $("<img />").attr({
		        'id': 'fancybox-img',
		        'src': imgPreloader.src,
		        'alt': selectedOpts.title
		    }).appendTo(tmp);

		    _show();
		},

		_show = function () {
		    var pos, equal;

		    loading.hide();

		    if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
		        $.event.trigger('fancybox-cancel');

		        busy = false;
		        return;
		    }

		    busy = true;

		    $(content.add(overlay)).unbind();

		    $(window).unbind("resize.fb scroll.fb");
		    $(document).unbind('keydown.fb');

		    if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') {
		        wrap.css('height', wrap.height());
		    }

		    currentArray = selectedArray;
		    currentIndex = selectedIndex;
		    currentOpts = selectedOpts;

		    if (currentOpts.overlayShow) {
		        overlay.css({
		            'background-color': currentOpts.overlayColor,
		            'opacity': currentOpts.overlayOpacity,
		            'cursor': currentOpts.hideOnOverlayClick ? 'pointer' : 'auto',
		            'height': $(document).height()
		        });

		        if (!overlay.is(':visible')) {
		            if (isIE6) {
		                $('select:not(#fancybox-tmp select)').filter(function () {
		                    return this.style.visibility !== 'hidden';
		                }).css({ 'visibility': 'hidden' }).one('fancybox-cleanup', function () {
		                    this.style.visibility = 'inherit';
		                });
		            }

		            overlay.show();
		        }
		    } else {
		        overlay.hide();
		    }

		    final_pos = _get_zoom_to();

		    _process_title();

		    if (wrap.is(":visible")) {
		        $(close.add(nav_left).add(nav_right)).hide();

		        pos = wrap.position(),

				start_pos = {
				    top: pos.top,
				    left: pos.left,
				    width: wrap.width(),
				    height: wrap.height()
				};

		        equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);

		        content.fadeTo(currentOpts.changeFade, 0.3, function () {
		            var finish_resizing = function () {
		                content.html(tmp.contents()).fadeTo(currentOpts.changeFade, 1, _finish);
		            };

		            $.event.trigger('fancybox-change');

		            content
						.empty()
						.removeAttr('filter')
						.css({
						    'border-width': currentOpts.padding,
						    'width': final_pos.width - currentOpts.padding * 2,
						    'height': selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
						});

		            if (equal) {
		                finish_resizing();

		            } else {
		                fx.prop = 0;

		                $(fx).animate({ prop: 1 }, {
		                    duration: currentOpts.changeSpeed,
		                    easing: currentOpts.easingChange,
		                    step: _draw,
		                    complete: finish_resizing
		                });
		            }
		        });

		        return;
		    }

		    wrap.removeAttr("style");

		    content.css('border-width', currentOpts.padding);

		    if (currentOpts.transitionIn == 'elastic') {
		        start_pos = _get_zoom_from();

		        content.html(tmp.contents());

		        wrap.show();

		        if (currentOpts.opacity) {
		            final_pos.opacity = 0;
		        }

		        fx.prop = 0;

		        $(fx).animate({ prop: 1 }, {
		            duration: currentOpts.speedIn,
		            easing: currentOpts.easingIn,
		            step: _draw,
		            complete: _finish
		        });

		        return;
		    }

		    if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {
		        title.show();
		    }

		    content
				.css({
				    'width': final_pos.width - currentOpts.padding * 2,
				    'height': selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
        })
				.html(tmp.contents());

		    wrap
				.css(final_pos)
				.fadeIn(currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish);
		},

		_format_title = function (title) {
		    if (title && title.length) {
		        if (currentOpts.titlePosition == 'float') {
		            return '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + title + '</td><td id="fancybox-title-float-right"></td></tr></table>';
            } 

		        return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>';
        } 

		    return false;
		},

		_process_title = function () {
		    titleStr = currentOpts.title || '';
		    titleHeight = 0;

		    title
				.empty()
				.removeAttr('style')
				.removeClass();

		    if (currentOpts.titleShow === false) {
		        title.hide();
		        return;
		    }

		    titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr);

		    if (!titleStr || titleStr === '') {
		        title.hide();
		        return;
		    }

		    title
				.addClass('fancybox-title-' + currentOpts.titlePosition)
				.html(titleStr)
				.appendTo('body')
				.show();

		    switch (currentOpts.titlePosition) {
		        case 'inside':
		            title
						.css({
						    'width': final_pos.width - (currentOpts.padding * 2),
						    'marginLeft': currentOpts.padding,
						    'marginRight': currentOpts.padding
						});

		            titleHeight = title.outerHeight(true);

		            title.appendTo(outer);

		            final_pos.height += titleHeight;
		            break;

		        case 'over':
		            title
						.css({
						    'marginLeft': currentOpts.padding,
						    'width': final_pos.width - (currentOpts.padding * 2),
						    'bottom': currentOpts.padding
						})
						.appendTo(outer);
		            break;

		        case 'float':
		            title
						.css('left', parseInt((title.width() - final_pos.width - 40) / 2, 10) * -1)
						.appendTo(wrap);
		            break;

		        default:
		            title
						.css({
						    'width': final_pos.width - (currentOpts.padding * 2),
						    'paddingLeft': currentOpts.padding,
						    'paddingRight': currentOpts.padding
						})
						.appendTo(wrap);
		            break;
		    }

		    title.hide();
		},

		_set_navigation = function () {
		    if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) {
		        $(document).bind('keydown.fb', function (e) {
		            if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
		                e.preventDefault();
		                $.fancybox.close();

		            } else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
		                e.preventDefault();
		                $.fancybox[e.keyCode == 37 ? 'prev' : 'next']();
		            }
		        });
		    }

		    if (!currentOpts.showNavArrows) {
		        nav_left.hide();
		        nav_right.hide();
		        return;
		    }

		    if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
		        nav_left.show();
		    }

		    if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length - 1)) {
		        nav_right.show();
		    }
		},

		_finish = function () {
		    if (!$.support.opacity) {
		        content.get(0).style.removeAttribute('filter');
		        wrap.get(0).style.removeAttribute('filter');
		    }

		    if (selectedOpts.autoDimensions) {
		        content.css('height', 'auto');
		    }

		    wrap.css('height', 'auto');

		    if (titleStr && titleStr.length) {
		        title.show();
		    }

		    if (currentOpts.showCloseButton) {
		        close.show();
		    }

		    _set_navigation();

		    if (currentOpts.hideOnContentClick) {
		        content.bind('click', $.fancybox.close);
		    }

		    if (currentOpts.hideOnOverlayClick) {
		        overlay.bind('click', $.fancybox.close);
		    }

		    $(window).bind("resize.fb", $.fancybox.resize);

		    if (currentOpts.centerOnScroll) {
		        $(window).bind("scroll.fb", $.fancybox.center);
		    }

		    if (currentOpts.type == 'iframe') {
		        $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
		    }

		    wrap.show();

		    busy = false;

		    $.fancybox.center();

		    currentOpts.onComplete(currentArray, currentIndex, currentOpts);

		    _preload_images();
		},

		_preload_images = function () {
		    var href,
				objNext;

		    if ((currentArray.length - 1) > currentIndex) {
		        href = currentArray[currentIndex + 1].href;

		        if (typeof href !== 'undefined' && href.match(imgRegExp)) {
		            objNext = new Image();
		            objNext.src = href;
		        }
		    }

		    if (currentIndex > 0) {
		        href = currentArray[currentIndex - 1].href;

		        if (typeof href !== 'undefined' && href.match(imgRegExp)) {
		            objNext = new Image();
		            objNext.src = href;
		        }
		    }
		},

		_draw = function (pos) {
		    var dim = {
		        width: parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10),
		        height: parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10),

		        top: parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10),
		        left: parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10)
		    };

		    if (typeof final_pos.opacity !== 'undefined') {
		        dim.opacity = pos < 0.5 ? 0.5 : pos;
		    }

		    wrap.css(dim);

		    content.css({
		        'width': dim.width - currentOpts.padding * 2,
		        'height': dim.height - (titleHeight * pos) - currentOpts.padding * 2
		    });
		},

		_get_viewport = function () {
		    return [
				$(window).width() - (currentOpts.margin * 2),
				$(window).height() - (currentOpts.margin * 2),
				$(document).scrollLeft() + currentOpts.margin,
				$(document).scrollTop() + currentOpts.margin
			];
		},

		_get_zoom_to = function () {
		    var view = _get_viewport(),
				to = {},
				resize = currentOpts.autoScale,
				double_padding = currentOpts.padding * 2,
				ratio;

		    if (currentOpts.width.toString().indexOf('%') > -1) {
		        to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10);
		    } else {
		        to.width = currentOpts.width + double_padding;
		    }

		    if (currentOpts.height.toString().indexOf('%') > -1) {
		        to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10);
		    } else {
		        to.height = currentOpts.height + double_padding;
		    }

		    if (resize && (to.width > view[0] || to.height > view[1])) {
		        if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
		            ratio = (currentOpts.width) / (currentOpts.height);

		            if ((to.width) > view[0]) {
		                to.width = view[0];
		                to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10);
		            }

		            if ((to.height) > view[1]) {
		                to.height = view[1];
		                to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10);
		            }

		        } else {
		            to.width = Math.min(to.width, view[0]);
		            to.height = Math.min(to.height, view[1]);
		        }
		    }

		    to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10);
		    to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10);

		    return to;
		},

		_get_obj_pos = function (obj) {
		    var pos = obj.offset();

		    pos.top += parseInt(obj.css('paddingTop'), 10) || 0;
		    pos.left += parseInt(obj.css('paddingLeft'), 10) || 0;

		    pos.top += parseInt(obj.css('border-top-width'), 10) || 0;
		    pos.left += parseInt(obj.css('border-left-width'), 10) || 0;

		    pos.width = obj.width();
		    pos.height = obj.height();

		    return pos;
		},

		_get_zoom_from = function () {
		    var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
				from = {},
				pos,
				view;

		    if (orig && orig.length) {
		        pos = _get_obj_pos(orig);

		        from = {
		            width: pos.width + (currentOpts.padding * 2),
		            height: pos.height + (currentOpts.padding * 2),
		            top: pos.top - currentOpts.padding - 20,
		            left: pos.left - currentOpts.padding - 20
		        };

		    } else {
		        view = _get_viewport();

		        from = {
		            width: currentOpts.padding * 2,
		            height: currentOpts.padding * 2,
		            top: parseInt(view[3] + view[1] * 0.5, 10),
		            left: parseInt(view[2] + view[0] * 0.5, 10)
		        };
		    }

		    return from;
		},

		_animate_loading = function () {
		    if (!loading.is(':visible')) {
		        clearInterval(loadingTimer);
		        return;
		    }

		    $('div', loading).css('top', (loadingFrame * -40) + 'px');

		    loadingFrame = (loadingFrame + 1) % 12;
		};

    /*
    * Public methods 
    */

    $.fn.fancybox = function (options) {
        if (!$(this).length) {
            return this;
        }

        $(this)
			.data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
			.unbind('click.fb')
			.bind('click.fb', function (e) {
			    e.preventDefault();

			    if (busy) {
			        return;
			    }

			    busy = true;

			    $(this).blur();

			    selectedArray = [];
			    selectedIndex = 0;

			    var rel = $(this).attr('rel') || '';

			    if (!rel || rel == '' || rel === 'nofollow') {
			        selectedArray.push(this);

			    } else {
			        selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
			        selectedIndex = selectedArray.index(this);
			    }

			    _start();

			    return;
			});

        return this;
    };

    $.fancybox = function (obj) {
        var opts;

        if (busy) {
            return;
        }

        busy = true;
        opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};

        selectedArray = [];
        selectedIndex = parseInt(opts.index, 10) || 0;

        if ($.isArray(obj)) {
            for (var i = 0, j = obj.length; i < j; i++) {
                if (typeof obj[i] == 'object') {
                    $(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
                } else {
                    obj[i] = $({}).data('fancybox', $.extend({ content: obj[i] }, opts));
                }
            }

            selectedArray = jQuery.merge(selectedArray, obj);

        } else {
            if (typeof obj == 'object') {
                $(obj).data('fancybox', $.extend({}, opts, obj));
            } else {
                obj = $({}).data('fancybox', $.extend({ content: obj }, opts));
            }

            selectedArray.push(obj);
        }

        if (selectedIndex > selectedArray.length || selectedIndex < 0) {
            selectedIndex = 0;
        }

        _start();
    };

    $.fancybox.showActivity = function () {
        clearInterval(loadingTimer);

        loading.show();
        loadingTimer = setInterval(_animate_loading, 66);
    };

    $.fancybox.hideActivity = function () {
        loading.hide();
    };

    $.fancybox.next = function () {
        return $.fancybox.pos(currentIndex + 1);
    };

    $.fancybox.prev = function () {
        return $.fancybox.pos(currentIndex - 1);
    };

    $.fancybox.pos = function (pos) {
        if (busy) {
            return;
        }

        pos = parseInt(pos);

        selectedArray = currentArray;

        if (pos > -1 && pos < currentArray.length) {
            selectedIndex = pos;
            _start();

        } else if (currentOpts.cyclic && currentArray.length > 1) {
            selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1;
            _start();
        }

        return;
    };

    $.fancybox.cancel = function () {
        if (busy) {
            return;
        }

        busy = true;

        $.event.trigger('fancybox-cancel');

        _abort();

        selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);

        busy = false;
    };

    // Note: within an iframe use - parent.$.fancybox.close();
    $.fancybox.close = function () {
        if (busy || wrap.is(':hidden')) {
            return;
        }

        busy = true;

        if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
            busy = false;
            return;
        }

        _abort();

        $(close.add(nav_left).add(nav_right)).hide();

        $(content.add(overlay)).unbind();

        $(window).unbind("resize.fb scroll.fb");
        $(document).unbind('keydown.fb');

        content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank');

        if (currentOpts.titlePosition !== 'inside') {
            title.empty();
        }

        wrap.stop();

        function _cleanup() {
            overlay.fadeOut('fast');

            title.empty().hide();
            wrap.hide();

            $.event.trigger('fancybox-cleanup');

            content.empty();

            currentOpts.onClosed(currentArray, currentIndex, currentOpts);

            currentArray = selectedOpts = [];
            currentIndex = selectedIndex = 0;
            currentOpts = selectedOpts = {};

            busy = false;
        }

        if (currentOpts.transitionOut == 'elastic') {
            start_pos = _get_zoom_from();

            var pos = wrap.position();

            final_pos = {
                top: pos.top,
                left: pos.left,
                width: wrap.width(),
                height: wrap.height()
            };

            if (currentOpts.opacity) {
                final_pos.opacity = 1;
            }

            title.empty().hide();

            fx.prop = 1;

            $(fx).animate({ prop: 0 }, {
                duration: currentOpts.speedOut,
                easing: currentOpts.easingOut,
                step: _draw,
                complete: _cleanup
            });

        } else {
            wrap.fadeOut(currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
        }
    };

    $.fancybox.resize = function () {
        if (overlay.is(':visible')) {
            overlay.css('height', $(document).height());
        }

        $.fancybox.center(true);
    };

    $.fancybox.center = function () {
        var view, align;

        if (busy) {
            return;
        }

        align = arguments[0] === true ? 1 : 0;
        view = _get_viewport();

        if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) {
            return;
        }

        wrap
			.stop()
			.animate({
			    'top': parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)),
			    'left': parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding))
			}, typeof arguments[0] == 'number' ? arguments[0] : 200);
    };

    $.fancybox.init = function () {
        if ($("#fancybox-wrap").length) {
            return;
        }

        $('body').append(
			tmp = $('<div id="fancybox-tmp"></div>'),
			loading = $('<div id="fancybox-loading"><div></div></div>'),
			overlay = $('<div id="fancybox-overlay"></div>'),
			wrap = $('<div id="fancybox-wrap"></div>')
		);

        outer = $('<div id="fancybox-outer"></div>')
			.append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>')
			.appendTo(wrap);

        outer.append(
			content = $('<div id="fancybox-content"></div>'),
			close = $('<a id="fancybox-close"></a>'),
			title = $('<div id="fancybox-title"></div>'),

			nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
			nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
		);

        close.click($.fancybox.close);
        loading.click($.fancybox.cancel);

        nav_left.click(function (e) {
            e.preventDefault();
            $.fancybox.prev();
        });

        nav_right.click(function (e) {
            e.preventDefault();
            $.fancybox.next();
        });

        if ($.fn.mousewheel) {
            wrap.bind('mousewheel.fb', function (e, delta) {
                if (busy) {
                    e.preventDefault();

                } else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
                    e.preventDefault();
                    $.fancybox[delta > 0 ? 'prev' : 'next']();
                }
            });
        }

        if (!$.support.opacity) {
            wrap.addClass('fancybox-ie');
        }

        if (isIE6) {
            loading.addClass('fancybox-ie6');
            wrap.addClass('fancybox-ie6');

            $('<iframe id="fancybox-hide-sel-frame" src="' + (/^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank') + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer);
        }
    };

    $.fn.fancybox.defaults = {
        padding: 10,
        margin: 40,
        opacity: false,
        modal: false,
        cyclic: false,
        scrolling: 'auto', // 'auto', 'yes' or 'no'

        width: 560,
        height: 340,

        autoScale: true,
        autoDimensions: true,
        centerOnScroll: false,

        ajax: {},
        swf: { wmode: 'transparent' },

        hideOnOverlayClick: true,
        hideOnContentClick: false,

        overlayShow: true,
        overlayOpacity: 0.7,
        overlayColor: '#777',

        titleShow: true,
        titlePosition: 'float', // 'float', 'outside', 'inside' or 'over'
        titleFormat: null,
        titleFromAlt: false,

        transitionIn: 'fade', // 'elastic', 'fade' or 'none'
        transitionOut: 'fade', // 'elastic', 'fade' or 'none'

        speedIn: 300,
        speedOut: 300,

        changeSpeed: 300,
        changeFade: 'fast',

        easingIn: 'swing',
        easingOut: 'swing',

        showCloseButton: true,
        showNavArrows: true,
        enableEscapeButton: true,
        enableKeyboardNav: true,

        onStart: function () { },
        onCancel: function () { },
        onComplete: function () { },
        onCleanup: function () { },
        onClosed: function () { },
        onError: function () { }
    };

    $(document).ready(function () {
        $.fancybox.init();
    });

})(jQuery);$(document).ready(function() {
	$("a.thickbox").fancybox();
}); 

