// #########  code from js/hm1.js   ######### //

var mf_wall_x = 1010;
var mf_wall_y = 5;
var mf_wall_center = false;

function mf_wall_init(top) {
    if ( document.getElementById('eBayRelevanceSky') ) {
        document.getElementById('eBayRelevanceSky').style.display = 'none';
    }
}

function detectBrowser()
{
    var browser=navigator.appName;
    var b_version=navigator.appVersion;
    var version=parseFloat(b_version);

    return browser;
    /*
    if ((browser=="Netscape"||browser=="Microsoft Internet Explorer")
    && (version>=4))
    {
    alert("Your browser is good enough!");
    }
    else
    {
    alert("It's time to upgrade your browser!");
    }
    */
}


// #########  code from js/filter.js   ######### //

function switch_display(id) {
    all_elements = getElementsByClassName("f_" + id);
    more = document.getElementById("more_" + id);	// "More filter" part
    less = document.getElementById("less_" + id);	// "Less filter" part

    if (all_elements[0]) {
        var elem_0 = all_elements[0];
        if (elem_0 && (elem_0.style.display == "block" || elem_0.style.display == "")) {
            var display = "none";
            var display_inv = "";
        } else {
            var display = "";
            var display_inv = "none";
        }
        for (var i = 0; i < all_elements.length; i++) {
            obj = all_elements[i];
            obj.style.display = display;
        }
        more.style.display = display_inv;
        less.style.display = display;
    }
}
function getElementsByClassName(classname) {
    all_elements = document.getElementById("filter").getElementsByTagName("li");
    return_array = new Array();
    for(var i = 0; i < all_elements.length; i++) {
        if (i < 20) {
        }
        if (all_elements[i].className == classname) {
            return_array = return_array.concat(all_elements[i]);
        }
    }
    return(return_array);
}


// #########  code from js/animatedcollapse.js   ######### //

function getposOffset(overlay, offsettype){
    var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
    var parentEl=overlay.offsetParent;
    while (parentEl!=null){
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl=parentEl.offsetParent;
    }
    return totaloffset;
}

function overlay(curobj, subobjstr, opt_position,left,top){
    if (document.getElementById){

        if(subobjstr == "subcontent_login") {
            if(chkObject('subcontent')){
                if(document.getElementById('subcontent').style.display == "block") {
                    document.getElementById('subcontent').style.display="none";
                }
            }
        } else {
            if(chkObject('subcontent_login')){
                if(document.getElementById('subcontent_login').style.display == "block") {
                    document.getElementById('subcontent_login').style.display="none";
                }
            }        
        }

        var subobj=document.getElementById(subobjstr)
        subobj.style.display=(subobj.style.display!="block")? "block" : "none"
        var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) - left;
        var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0) + top;
        //alert(xpos + " : " + ypos);
        //xpos=xpos-10;
        //ypos=ypos-8;
        subobj.style.left=xpos+"px"
        /*subobj.style.left=xpos+"px"
        subobj.style.top=ypos+"px"*/
        subobj.style.top=ypos+"px"
        return false
    }
    else
    return true
}

function overlayopen(subobjstr){
    var subobj=document.getElementById(subobjstr)
    subobj.style.display=(subobj.style.display!="block")? "block" : "none"
}


function overlayclose(subobj){
    document.getElementById(subobj).style.display="none"
}

function chkObject(theVal) {
    if (document.getElementById(theVal) != null) {
        return true;
    } else {
        return false;
    }
}


var menuTimer = 0;
/*function open_timedMenu(menuName, openTime)
{
clearTimeout(menuTimer);
var functionStr = "ShowHideLeft('" + menuName + "')";
menuTimer = setTimeout(functionStr, openTime);
}*/


// #########  code from js/common.js   ######### //


/**
 * COMMON DHTML FUNCTIONS
 * These are handy functions I use all the time.
 *
 * By Seth Banks (webmaster at subimage dot com)
 * http://www.subimage.com/
 *
 * Up to date code can be found at http://www.subimage.com/dhtml/
 *
 * This code is free for you to use anywhere, just keep this comment block.
 */

/**
 * X-browser event handler attachment and detachment
 * TH: Switched first true to false per http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html
 *
 * @argument obj - the object to attach event to
 * @argument evType - name of the event - DONT ADD "on", pass only "mouseover", etc
 * @argument fn - function to call
 */
function addEvent(obj, evType, fn){
    if (obj.addEventListener){
        obj.addEventListener(evType, fn, false);
        return true;
    } else if (obj.attachEvent){
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    } else {
        return false;
    }
}
function removeEvent(obj, evType, fn, useCapture){
    if (obj.removeEventListener){
        obj.removeEventListener(evType, fn, useCapture);
        return true;
    } else if (obj.detachEvent){
        var r = obj.detachEvent("on"+evType, fn);
        return r;
    } else {
        alert("Handler could not be removed");
    }
}

/**
 * Code below taken from - http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/
 *
 * Modified 4/22/04 to work with Opera/Moz (by webmaster at subimage dot com)
 *
 * Gets the full width/height because it's different for most browsers.
 */
function getViewportHeight() {
    if (window.innerHeight!=window.undefined) return window.innerHeight;
    if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
    if (document.body) return document.body.clientHeight; 

    return window.undefined; 
}
function getViewportWidth() {
    var offset = 17;
    var width = null;
    if (window.innerWidth!=window.undefined) return window.innerWidth; 
    if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
    if (document.body) return document.body.clientWidth; 
}

/**
 * Gets the real scroll top
 */
function getScrollTop() {
    if (self.pageYOffset) // all except Explorer
    {
        return self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop)
    // Explorer 6 Strict
    {
        return document.documentElement.scrollTop;
    }
    else if (document.body) // all other Explorers
    {
        return document.body.scrollTop;
    }
}
function getScrollLeft() {
    if (self.pageXOffset) // all except Explorer
    {
        return self.pageXOffset;
    }
    else if (document.documentElement && document.documentElement.scrollLeft)
    // Explorer 6 Strict
    {
        return document.documentElement.scrollLeft;
    }
    else if (document.body) // all other Explorers
    {
        return document.body.scrollLeft;
    }
}



function priceValidate(min,max) {
    var x=document.filter_price;

    for(i=0; i<document.filter_price.elements.length; i++)
    {
        if( document.filter_price.elements[i].type == "text" || document.filter_price.elements[i].type == "password" || document.filter_price.elements[i].type == "textarea" )
        { document.filter_price.elements[i].value  = trim(document.filter_price.elements[i].value); }
    }

    if(x.min.value != "")
    {
        var tel1 = x.min.value;
        ret = numCheck(tel1,'Invalid From Price Value.');
        if(ret == 1)
        {x.min.focus();return false;}

        if(parseInt(x.min.value) < parseInt(min)){
            //alert("The From price cannot be less then "+min);
            //x.min.focus();
            //return false;	
            //x.min.value = min;
        }

        if(parseInt(x.min.value) > parseInt(max)){
            //alert("The From price cannot be greater then "+max);
            //x.min.focus();
            //return false;	
            //x.min.value = min;
        }

    }	


    if(x.max.value != "")
    {
        var tel1 = x.max.value;
        ret = numCheck(tel1,'Invalid To Price value');
        if(ret == 1)
        {x.max.focus();return false;}

        if(parseInt(x.max.value) > parseInt(max)){
            //alert("The To price cannot be greater then "+max);
            //x.max.focus();
            //return false;	
            //x.max.value = max;
        }

        if(parseInt(x.max.value) < parseInt(min)){
            //alert("The To price cannot be less then "+min);
            //x.max.focus();
            //return false;	
            //x.max.value = max;
        }		

    }
    x.submit();
}

function trim(s)
{
    return s.replace(/^\s*|\s*$/g,"");
}


function numCheck(tel,msg,focus)
{
    for (var i = 0; i < tel.length; i++)
    {
        var ch = tel.substring(i, i+1);
        if(ch < '0' || ch > '9' )
        {

            alert(msg);
            return 1;
        }
    }
}//end of numCheck function



// Title: Tigra Form Validator
// URL: http://www.softcomplex.com/products/tigra_form_validator/
// Version: 1.3
// Date: 08/25/2005 (mm/dd/yyyy)
// Notes: Registration needed to use this script legally. Visit official site for details.
//'text': /^\w+\s*/,
// regular expressions or function to validate the format
var re_dt = /^(\d{1,2})\-(\d{1,2})\-(\d{4})$/,
re_tm = /^(\d{1,2})\:(\d{1,2})\:(\d{1,2})$/,
a_formats = {
    'alpha'   : /^[a-zA-Z\.\-]*$/,
    'alphanum': /^\w+$/,
    'alphaphone': /^[0-9\.\-]*$/,
    'text'	  : /^[a-zA-Z\.\-äÄöÖüÜßÃ‰Éé©ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßŸŠàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿš`]+\s*/,
    'unsigned': /^\d+$/,
    'integer' : /^[\+\-]?\d*$/,
    'real'    : /^[\+\-]?\d*\.?\d*$/,
    'email'   : /^[0-9a-zA-Z\.\-_äÄöÖüÜßÃ‰Éé©ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßŸŠàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿš`]+\@[0-9\w\.-_]+\.[a-z]{2,4}$/,
    'phone'   : /^[\d\.\s\-]+$/,
    'date'    : function (s_date) {
        // check format
        if (!re_dt.test(s_date))
        return false;
        // check allowed ranges	
        if (RegExp.$1 > 31 || RegExp.$2 > 12)
        return false;
        // check number of day in month
        var dt_test = new Date(RegExp.$3, Number(RegExp.$2-1), RegExp.$1);
        if (dt_test.getMonth() != Number(RegExp.$2-1))
        return false;
        return true;
    },
    'time'    : function (s_time) {
        // check format
        if (!re_tm.test(s_time))
        return false;
        // check allowed ranges	
        if (RegExp.$1 > 23 || RegExp.$2 > 59 || RegExp.$3 > 59)
        return false;
        return true;
    }
},
a_messages = [
'No form name passed to validator construction routine',
'No array of "%form%" form fields passed to validator construction routine',
'Form "%form%" can not be found in this document',
'Incomplete "%n%" form field descriptor entry. "l" attribute is missing',
'Can not find form field "%n%" in the form "%form%"',
'Can not find label tag (id="%t%")',
'Can not verify match. Field "%m%" was not found',
'"%l%" ist ein Pflichtfeld!',
'"%l%" muß mindestens %mn% Zeichen lang sein.',
'"%l%" darf nicht länger als %mx% Zeichen sein',
'Bitte verwenden Sie nur Zahlen und Buchstaben.',	
'Die Passwort-Eingabe war nicht korrekt. Bitte geben Sie Ihr Passwort erneut ein.'
]

//"%v%" is kein gültier Wert für "%l%"		incorect password value eg fashion.de
//'"%l%" muß passen zu "%ml%"'

// validator counstruction routine
function validator(s_form, a_fields, o_cfg) {
    this.f_error = validator_error;
    this.f_alert = o_cfg && o_cfg.alert
    ? function(s_msg) { alert(s_msg); return false }
    : function() { return false };

    // check required parameters
    if (!s_form)	
    return this.f_alert(this.f_error(0));
    this.s_form = s_form;

    if (!a_fields || typeof(a_fields) != 'object')
    return this.f_alert(this.f_error(1));
    this.a_fields = a_fields;

    this.a_2disable = o_cfg && o_cfg['to_disable'] && typeof(o_cfg['to_disable']) == 'object'
    ? o_cfg['to_disable']
    : [];

    this.exec = validator_exec;
}

// validator execution method
function validator_exec() {
    var o_form = document.forms[this.s_form];
    if (!o_form)	
    return this.f_alert(this.f_error(2));

    b_dom = document.body && document.body.innerHTML;

    // check integrity of the form fields description structure
    for (var n_key in this.a_fields) {
        // check input description entry
        this.a_fields[n_key]['n'] = n_key;
        if (!this.a_fields[n_key]['l'])
        return this.f_alert(this.f_error(3, this.a_fields[n_key]));
        o_input = o_form.elements[n_key];
        if (!o_input)
        return this.f_alert(this.f_error(4, this.a_fields[n_key]));
        this.a_fields[n_key].o_input = o_input;
    }

    // reset labels highlight
    if (b_dom)
    for (var n_key in this.a_fields) 
    if (this.a_fields[n_key]['t']) {
        var s_labeltag = this.a_fields[n_key]['t'], e_labeltag = get_element(s_labeltag);
        if (!e_labeltag)
        return this.f_alert(this.f_error(5, this.a_fields[n_key]));
        this.a_fields[n_key].o_tag = e_labeltag;

        // normal state parameters assigned here
        e_labeltag.className = 'tfvNormal';
    }

    // collect values depending on the type of the input
    for (var n_key in this.a_fields) {
        var s_value = '';
        o_input = this.a_fields[n_key].o_input;
        if (o_input.type == 'checkbox') // checkbox
        s_value = o_input.checked ? o_input.value : '';
        else if (o_input.value) // text, password, hidden
        s_value = o_input.value;
        else if (o_input.options) // select
        s_value = o_input.selectedIndex > -1
        ? o_input.options[o_input.selectedIndex].value
        : null;
        else if (o_input.length > 0) // radiobuton
        for (var n_index = 0; n_index < o_input.length; n_index++)
        if (o_input[n_index].checked) {
            s_value = o_input[n_index].value;
            break;
        }
        this.a_fields[n_key]['v'] = s_value.replace(/(^\s+)|(\s+$)/g, '');
    }

    // check for errors
    var n_errors_count = 0,
    n_another, o_format_check;
    for (var n_key in this.a_fields) {
        o_format_check = this.a_fields[n_key]['f'] && a_formats[this.a_fields[n_key]['f']]
        ? a_formats[this.a_fields[n_key]['f']]
        : null;

        // reset previous error if any
        this.a_fields[n_key].n_error = null;

        // check reqired fields
        if (this.a_fields[n_key]['r'] && !this.a_fields[n_key]['v']) {
            this.a_fields[n_key].n_error = 1;
            n_errors_count++;
        }
        // check length
        else if (this.a_fields[n_key]['mn'] && this.a_fields[n_key]['v'] != '' && String(this.a_fields[n_key]['v']).length < this.a_fields[n_key]['mn']) {
            this.a_fields[n_key].n_error = 2;
            n_errors_count++;
        }
        else if (this.a_fields[n_key]['mx'] && String(this.a_fields[n_key]['v']).length > this.a_fields[n_key]['mx']) {
            this.a_fields[n_key].n_error = 3;
            n_errors_count++;
        }
        // check format
        else if (this.a_fields[n_key]['v'] && this.a_fields[n_key]['f'] && (
        (typeof(o_format_check) == 'function'
        && !o_format_check(this.a_fields[n_key]['v']))
        || (typeof(o_format_check) != 'function'
        && !o_format_check.test(this.a_fields[n_key]['v'])))
        ) {
            this.a_fields[n_key].n_error = 4;
            n_errors_count++;
        }
        // check match	
        else if (this.a_fields[n_key]['m']) {
            for (var n_key2 in this.a_fields)
            if (n_key2 == this.a_fields[n_key]['m']) {
                n_another = n_key2;
                break;
            }
            if (n_another == null)
            return this.f_alert(this.f_error(6, this.a_fields[n_key]));
            if (this.a_fields[n_another]['v'] != this.a_fields[n_key]['v']) {
                this.a_fields[n_key]['ml'] = this.a_fields[n_another]['l'];
                this.a_fields[n_key].n_error = 5;
                n_errors_count++;
            }
        }

    }

    // collect error messages and highlight captions for errorneous fields
    var s_alert_message = '',
    e_first_error;

    if (n_errors_count) {
        for (var n_key in this.a_fields) {
            var n_error_type = this.a_fields[n_key].n_error,
            s_message = '';

            if (n_error_type)
            s_message = this.f_error(n_error_type + 6, this.a_fields[n_key]);

            if (s_message) {
                if (!e_first_error)
                e_first_error = o_form.elements[n_key];
                s_alert_message += s_message + "\n";
                // highlighted state parameters assigned here
                if (b_dom && this.a_fields[n_key].o_tag)
                this.a_fields[n_key].o_tag.className = 'tfvHighlight';
            }
        }
        alert(s_alert_message);
        // set focus to first errorneous field
        if (e_first_error.focus && e_first_error.type != 'hidden'  && !e_first_error.disabled)
        eval("e_first_error.focus()");
        // cancel form submission if errors detected
        return false;
    }

    for (n_key in this.a_2disable)
    if (o_form.elements[this.a_2disable[n_key]])
    o_form.elements[this.a_2disable[n_key]].disabled = true;

    return true;
}

function validator_error(n_index) {
    var s_ = a_messages[n_index], n_i = 1, s_key;
    for (; n_i < arguments.length; n_i ++)
    for (s_key in arguments[n_i])
    s_ = s_.replace('%' + s_key + '%', arguments[n_i][s_key]);
    s_ = s_.replace('%form%', this.s_form);
    return s_
}

function get_element (s_id) {
    return (document.all ? document.all[s_id] : (document.getElementById ? document.getElementById(s_id) : null));
}

function trim(s)
{
    return s.replace(/^\s*|\s*$/g,"");
}

function checkEnter(e){
    var characterCode

    if(e && e.which){
        e = e
        characterCode = e.which 
    }
    else{
        e = event
        characterCode = e.keyCode 
    }

    if(characterCode == 13){ 
        document.search.submit()
        return false 
    }
    else{
        return true 
    }

}

function load_page(page){
    window.location.href=page;

}

function chgtxt(obj,linkid,linkcolor)
{
    if(document.getElementById) // IE5+ and NS6+ only
    {
        document.getElementById(linkid).style.color=linkcolor
    }
}


// #########  code from assets/anylinkvertical.js   ######### //

var disappeardelay=0  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)
var horizontaloffset=0 //horizontal offset of menu from default location. (0-5 is a good value)

/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
    var parentEl=what.offsetParent;
    while (parentEl!=null){
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl=parentEl.offsetParent;
    }
    return totaloffset;
}

function showhide(obj, e, visible, hidden){
    if (ie5||ns6)
    dropmenuobj.style.left=dropmenuobj.style.top=-500
    if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
    obj.visibility=visible
    else if (e.type=="click")
    obj.visibility=hidden
}

function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
    var edgeoffset=0
    if (whichedge=="rightedge"){
        var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
        dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
        if (windowedge-dropmenuobj.x-obj.offsetWidth < dropmenuobj.contentmeasure)
        edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+(horizontaloffset*2) //no space to the right of page? Move menu over to the left
    }
    else{
        var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
        var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
        dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
        if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move menu up?
            edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
            if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? (position at top of viewable window then)
            edgeoffset=dropmenuobj.y
        }
    }
    return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
    if (window.event) event.cancelBubble=true
    else if (e.stopPropagation) e.stopPropagation()
    if (typeof dropmenuobj!="undefined") //hide previous menu
    dropmenuobj.style.visibility="hidden"
    clearhidemenu()
    if (ie5||ns6){
        obj.onmouseout=delayhidemenu
        dropmenuobj=document.getElementById(dropmenuID)
        if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
        dropmenuobj.onmouseover=clearhidemenu
        dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
        showhide(dropmenuobj.style, e, "visible", "hidden")
        dropmenuobj.x=getposOffset(obj, "left")
        dropmenuobj.y=getposOffset(obj, "top")
        dropmenuobj.x=dropmenuobj.x-3;
        dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+horizontaloffset+"px"
        dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
    }
    return clickreturnvalue()
}

function clickreturnvalue(){
    if ((ie5||ns6) && !enableanchorlink) return false
    else return true
}

function contains_ns6(a, b) {
    if(b != "")
    {
        while (b.parentNode)
        if ((b = b.parentNode) == a)
        return true;
    }
    return false;
}

function dynamichide(e){
    if (ie5&&!dropmenuobj.contains(e.toElement))
    delayhidemenu()
    else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
    delayhidemenu()
}

function delayhidemenu(){
    delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
    if (typeof delayhide!="undefined")
    clearTimeout(delayhide)
}


// #########  code from js/meta.js   ######### //

function setFocus()
{
    var field = document.top_search.keyword;
    field.focus();
    field.select();
}
function IESelectionSend()
{
    if ( (event.which && event.which == 13) || (event.keyCode && event.keyCode == 13) ) {
        show_loading_indicator();
        document.top_search_form_id.submit();return false;
    } else {
        return true;
    }

}
function FirefoxSelectionSend(myfield,e)
{
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

    if (keycode == 13)
    {
        show_loading_indicator();
        myfield.form.submit();
        return false;
    }
    else
    {
        return true;

    }
}
function SetElementProperty(elemId, property, value)
{
    var elem = null;

    if(typeof(elemId) == "object")
    elem = elemId;
    else
    elem = document.getElementById(elemId);

    if((elem != null) && (elem.style != null))
    {
        elem = elem.style;
        elem[property] = value;
    }
}
function submitNewsletter()
{
    var newsletter_email = document.getElementById("newsletter_email").value;
    if( ! isValidEmail (newsletter_email)){
        alert(valid_email_address);
        document.getElementById("newsletter_email").focus();
    } else {
        var url = "process.php";
        var params = "mode=subscribeNewsletter&email="+escape(newsletter_email);
        var response = AjaxAgent.call(url,"","",params);
        alert(response);
    }
}
function submitNewsletter_contactform()
{
    var newsletter_email = document.getElementById("newsletter_email_contact").value;
    if( ! isValidEmail (newsletter_email)){
        alert(valid_email_address);
        document.getElementById("newsletter_email_contact").focus();
    } else {
        var url = "process.php";
        var params = "mode=subscribeNewsletter&email="+escape(newsletter_email);
        var response = AjaxAgent.call(url,"","",params);
        alert(response);
    }
}

function isValidEmail(s)
{
    var re = new RegExp ("^([a-zA-Z0-9_\\-\\.]+)@"
    + "((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)"
    + "|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
    return s.match ( re ) != null;
}


function newImage(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
    }
}

function changeImages() {
    if (document.images && (preloadFlag == true)) {
        for (var i=0; i<changeImages.arguments.length; i+=2) {
            document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
        }
    }
}

var preloadFlag = false;
function preloadImages() {
    if (document.images) {
        but_01_over = newImage(Tbut_01_over);
        but_01_but_02_over = newImage(Tbut_01_but_02_over);
        but_02_but_01_over = newImage(Tbut_02_but_01_over);
        but_02_over = newImage(Tbut_02_over);
        but_02_but_03_over = newImage(Tbut_02_but_03_over);
        but_03_but_02_over = newImage(Tbut_03_but_02_over);
        but_03_over = newImage(Tbut_03_over);
        loading_small = newImage("images/loading_small.gif");
        loading_small = newImage('images/loading.gif');

        icon_mk_over = newImage("images/note_pad.inside.jpg");

        preloadFlag = true;
    }

}

function showLogoTip(){
    var url = "process.php";
    var params = "mode=showlogopopup";
    var showProductDetail = AjaxAgent.call(url,"","",params);

    document.getElementById("overDiv").innerHTML = showProductDetail;
    SetElementProperty('overDiv', 'display', 'block');
    SetElementProperty('logoframe', 'display', 'block');
}

function hideLogoTip(){
    SetElementProperty('overDiv', 'display', 'none');
    SetElementProperty('logoframe', 'display', 'none');
}
function getheight() {
    if(document.getElementById("OnTopBanner")!=null)
    {
        var theDiv = document.getElementById("OnTopBanner");
        var dheight = theDiv.offsetHeight;
        var newheight = parseInt(dheight);

        var iframe1 = document.getElementById("cover_23_a");
        iframe1.style.top = parseInt(120+newheight)+"px";

        var iframe2 = document.getElementById("cover_24_a");
        iframe2.style.top = parseInt(120+newheight)+"px";

        var iframe3 = document.getElementById("cover_25_a");
        iframe3.style.top = parseInt(120+newheight)+"px";

        var iframe4 = document.getElementById("cover_26_a");
        iframe4.style.top = parseInt(120+newheight)+"px";

        var iframe5 = document.getElementById("cover_27_a");
        iframe5.style.top = parseInt(120+newheight)+"px";

        var iframe6 = document.getElementById("cover_28_a");
        iframe6.style.top = parseInt(120+newheight)+"px";

        var iframe6 = document.getElementById("cover_29_a");
        iframe6.style.top = parseInt(120+newheight)+"px";

        var iframe6 = document.getElementById("cover_30_a");
        iframe6.style.top = parseInt(120+newheight)+"px";

        var iframe6 = document.getElementById("cover_31_a");
        iframe6.style.top = parseInt(120+newheight)+"px";

        var iframe6 = document.getElementById("cover_32_a");
        iframe6.style.top = parseInt(120+newheight)+"px";

    }
}

function BookmarkStats(burl, title, siteid)
{
    var url = "process.php";
    var params = "mode=BookmarkStats&URL="+burl+"&TITLE="+title+"&SITE_ID="+siteid;
    //alert(params);
    AjaxAgent.call(url,"","BookmarkStatsResponse",params);
}
function BookmarkStatsResponse(output)
{}


// #########  code from js/functions.js   ######### //



function writestyle(platform)
{

}

if (navigator.appVersion.indexOf("Mac") != -1 )
{
    writestyle("mac")
}
else
{
    writestyle("pc")
}

function MM_reloadPage(init)	//reloads the window if Nav4 resized
{
    if (init==true) with (navigator)
    {
        if ((appName=="Netscape")&&(parseInt(appVersion)==4))
        {
            document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
        }
    }
    else if(innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function emailCheck (emailStr) 
{
    /* The following variable tells the rest of the function whether or not to verify that the address ends in a two-letter 
    country or well-known TLD.  1 means check it, 0 means don't. */
    var checkTLD=0;

    /* The following is the list of known TLDs that an e-mail address must end with. */
    var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

    /* The following pattern is used to check if the entered e-mail address fits the user@domain format. It also is used to
    separate the username from the domain. */
    var emailPat=/^(.+)@(.+)$/;

    /* The following string represents the pattern for matching all special characters.  We don't want to allow special characters 
    in the address. These characters include ( ) < > @ , ; : \ " . [ ] */
    var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

    /* The following string represents the range of characters allowed in a username or domainname.  It really states which chars 
    aren't allowed.*/
    var validChars="\[^\\s" + specialChars + "\]";

    /* The following pattern applies if the "user" is a quoted string (in which case, there are no rules about which characters are 	allowed and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com is a legal e-mail address. */
    var quotedUser="(\"[^\"]*\")";

    /* The following pattern applies for domains that are IP addresses, rather than symbolic names.  E.g. joe@[123.124.233.4] is a 
    legal e-mail address. NOTE: The square brackets are required. */
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

    /* The following string represents an atom (basically a series of non-special characters.) */
    var atom=validChars + '+';

    /* The following string represents one word in the typical username. For example, in john.doe@somewhere.com, john and doe are 
    words. Basically, a word is either an atom or quoted string. */
    var word="(" + atom + "|" + quotedUser + ")";

    // The following pattern describes the structure of the user
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

    /* The following pattern describes the structure of a normal symbolic domain, as opposed to ipDomainPat, shown above. */
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

    /* Finally, let's start trying to figure out if the supplied address is valid. */
    /* Begin with the coarse pattern to simply break up user@domain into different pieces that are easy to analyze. */
    var matchArray=emailStr.match(emailPat);

    if (matchArray==null) 
    {
        /* Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address. */
        alert("Email address seems incorrect (check @ and .'s)");
        return false;
    }

    var user=matchArray[1];
    var domain=matchArray[2];

    // Start by checking that only basic ASCII characters are in the strings (0-127).
    for (i=0; i<user.length; i++) 
    {
        if (user.charCodeAt(i)>127) 
        {
            alert("Ths email username contains invalid characters.");
            return false;
        }
    }
    for (i=0; i<domain.length; i++) 
    {
        if (domain.charCodeAt(i)>127) 
        {
            alert("Ths email domain name contains invalid characters.");
            return false;
        }
    }

    // See if "user" is valid 
    if (user.match(userPat)==null) 
    {
        // user is not valid
        alert("The email username doesn't seem to be valid.");
        return false;
    }

    /* if the e-mail address is at an IP address (as opposed to a symbolic host name) make sure the IP address is valid. */
    var IPArray=domain.match(ipDomainPat);
    if (IPArray!=null) 
    {
        // this is an IP address
        for (var i=1;i<=4;i++) 
        {
            if (IPArray[i]>255) 
            {
                alert("email Destination IP address is invalid!");
                return false;
            }
        }
    }

    // Domain is symbolic name.  Check if it's valid.
    var atomPat=new RegExp("^" + atom + "$");
    var domArr=domain.split(".");
    var len=domArr.length;
    for (i=0;i<len;i++)
    {
        if (domArr[i].search(atomPat)==-1) 
        {
            alert("The email domain name does not seem to be valid.");
            return false;
        }
    }

    /* domain name seems valid, but now make sure that it ends in a known top-level domain (like com, edu, gov) or a two-letter
    word, representing country (uk, nl), and that there's a hostname preceding the domain or country. */

    if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) 
    {
        alert("The email address must end in a well-known domain or two letter " + "country.");
        return false;
    }

    // Make sure there's a host name preceding the domain.
    if (len<2) 
    {
        alert("This email address is missing a hostname!");
        return false;
    }

    // If we've gotten this far, everything's valid!
    return ("done");
}

function isblank(s)
{
    for(var i=0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if((c!=' ')&&(c!="\n")&&(c!="\t"))
        return false;
    }
    return true;
}


function username_focus()
{
    document.dataform.username.focus();
}

function set()
{
    if(document.dataform.username.value=="")
    {
        alert("Enter User Name");
        document.dataform.username.focus();
        return false;
    }
    if(document.dataform.passwd.value=="")
    {
        alert("Enter your Password");
        document.dataform.passwd.focus();
        return false;
    }
}

function MM_callJS(jsStr) { //v2.0
    return eval(jsStr);
}

function chkId()
{
    if ( isblank(document.loginform.username.value) )
    {
        alert("Enter Mirchi ID");
        document.loginform.username.focus();
    }
    else
    {
        var username=document.loginform.username.value;
        window.location.replace('forgotPassword.php?username='+username);
    }
}

function username_focus()
{
    document.loginform.username.focus();
}

function set()
{
    if(document.loginform.username.value=="")
    {
        alert("Enter User Name");
        document.loginform.username.focus();
        return false;
    }
    if(document.loginform.passwd.value=="")
    {
        alert("Enter your Password");
        document.loginform.passwd.focus();
        return false;
    }
}

function MM_callJS(jsStr) { //v2.0
    return eval(jsStr);
}

function CheckForLogin(id)
{

    if(!(id!="0" && id!="")){	
        alert("Please login to use this feature");
        return false;
    }
    if(document.PostCommtform.CommentText.value=="Add a Comment" || document.PostCommtform.CommentText.value==""){

        alert("Please add a comment");
        document.PostCommtform.CommentText.value="";
        document.PostCommtform.CommentText.focus();
        return false;

    }	

}



function clearText()
{

    if(document.PostCommtform.CommentText.value=="Add a Comment"){

        document.PostCommtform.CommentText.value="";
        document.PostCommtform.CommentText.focus();
        return false;

    }

}

function ModeratePostAns(repid,senderId){


    if(document.getElementById("ans"+repid).value=="Post a Answer" || document.getElementById("ans"+repid).value==""){

        alert("Please add a answer");
        return false;
    }
    else{

        document.moderate_comm_form.postedans.value=document.getElementById("ans"+repid).value;
        document.moderate_comm_form.private.value=document.getElementById("prv"+repid).value;
        document.moderate_comm_form.scrapId.value=repid;
        document.moderate_comm_form.senderId.value=senderId;

        document.moderate_comm_form.pmode.value="PostAns";
        document.moderate_comm_form.submit();
    }
}


function ModerateComment(formname, mode, scrapid)
{
    formname.pmode.value=mode;
    formname.scrapId.value=scrapid;
    formname.submit();
}

function validActivationForm(formname)
{
    if(formname.username.value=="")
    {
        alert("Please enter username");
        formname.username.focus();
        return false;
    }
    else
    {
        var nonums = /^[0-9_]*$/;
        if (nonums.test(formname.username.value)) 
        {
            alert("Invalid username.");
            return false;
        }

        var iChars = " \n\t`~!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
        for (var i = 0; i < formname.username.value.length; i++) 
        {
            if (iChars.indexOf(formname.username.value.charAt(i)) != -1) 
            {
                alert ("Invalid username");
                return false;
            }
        }		
    }

    if(formname.email.value=="")
    {
        alert("Please enter email");
        formname.email.focus();
        return false;
    }
    else
    {
        if(emailCheck(formname.email.value)!="done")
        {
            formname.email.focus();
            return false;
        }
    }
}


function EmailCheckjs(argvalue)
{
    if (argvalue.indexOf(" ") != -1)
    return false;
    else if (argvalue.indexOf("@") == -1)
    return false;
    else if (argvalue.indexOf("@") == 0)
    return false;
    else if (argvalue.indexOf("@") == (argvalue.length-1))
    return false;
    var arrayString = argvalue.split("@");
    if(arrayString.length > 2)
    return false;
    if (arrayString[1].indexOf(".") == -1)
    return false;
    else if (arrayString[1].indexOf(".") == 0)
    return false;
    else if (arrayString[1].charAt(arrayString[1].length-1) == ".") {
        return false;
    }
    return true;
}


function Trim(TRIM_VALUE)
{
    if(TRIM_VALUE.length < 1)
    {
        return"";
    }
    TRIM_VALUE = RTrim(TRIM_VALUE);
    TRIM_VALUE = LTrim(TRIM_VALUE);
    if(TRIM_VALUE=="")
    {
        return "";
    }
    else
    {
        return TRIM_VALUE;
    }
} //End Function

function RTrim(VALUE)
{
    var w_space = String.fromCharCode(32);
    var v_length = VALUE.length;
    var strTemp = "";
    if(v_length < 0)
    {
        return"";
    }
    var iTemp = v_length -1;
    while(iTemp > -1)
    {
        if(VALUE.charAt(iTemp) == w_space)
        {
        }
        else
        {
            strTemp = VALUE.substring(0,iTemp +1);
            break;
        }
        iTemp = iTemp-1;
    } //End While
    return strTemp;
} //End Function

function LTrim(VALUE)
{
    var w_space = String.fromCharCode(32);
    if(v_length < 1)
    {
        return"";
    }
    var v_length = VALUE.length;
    var strTemp = "";
    var iTemp = 0;
    while(iTemp < v_length)
    {
        if(VALUE.charAt(iTemp) == w_space)
        {
        }
        else
        {
            strTemp = VALUE.substring(iTemp,v_length);
            break;
        }
        iTemp = iTemp + 1;
    } //End While
    return strTemp;
} //End Function

function textCounter(field,counter,maxlimit,linecounter) {
    // text width//
    var fieldWidth =  parseInt(field.offsetWidth);
    var charcnt = field.value.length;

    // trim the extra text
    if (charcnt > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    }

    else {
        // progress bar percentage
        var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
        document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
        document.getElementById(counter).innerHTML=""+percentage+"%"
        // color correction on style from CCFFF -> CC0000
        setcolor(document.getElementById(counter),percentage,"background-color");
    }
}


function setcolor(obj,percentage,prop){
    obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}

//for CreateCommunity

function goBack()
{
    //alert("{$V_GO_TO}");
    window.location.replace('comunityList.php');
    document.dataform2.goback.value="y";
    document.dataform2.submit(); 
}


function set1()
{  
    df=document.dataform2;

    //alert on finding all numbers
    var nonums = /^[0-9_]*$/;
    if (nonums.test(document.dataform2.name.value)) 
    {
        alert("Community Name Can Contain only alphabets and numbers and underscore");
        return false;
    }

    var iChars = " \n\t`~!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
    for (var i = 0; i < document.dataform2.name.value.length; i++) 
    {
        if (iChars.indexOf(document.dataform2.name.value.charAt(i)) != -1) 
        {
            alert ("Community Name Can Contain only alphabets and numbers and underscore ");
            return false;
        }
    }



    if(document.dataform2.name.value=="")
    {
        alert("Enter Community name")
        document.dataform2.name.focus();
        return false;
    }				
    else if ( document.dataform2.cmcategory.options[document.dataform2.cmcategory.selectedIndex].value == "" )
    {
        alert("Select Category");
        document.dataform2.cmcategory.focus();
        return false;
    }


    if( isblank(document.dataform2.description.value))
    {
        alert("Description can not be blank")
        document.dataform2.description.focus();
        return false;
    }


    return true;
}	
function AddDestinations()
{
    var	FName = document.getElementById('friends');
    var data = "";

    var len = FName.length;

    for(i=0; i<len; i++)
    {
        if(FName.options[i].selected)
        {
            data = data+FName.options[i].value+",";
        }
    }
    //alert(data);

    document.getElementById("destination").value = data;	
    var destiny = document.getElementById("destination").value;

    var deslen = destiny.length-1;

    if(destiny.charAt(deslen)==",")
    {
        document.getElementById("destination").value = destiny.substring(0,deslen);
    }
}

function AddDestinations2()
{
    var	FName = document.getElementById('friends');
    var data = "";

    var len = FName.length;

    for(i=0; i<len; i++)
    {
        if(FName.options[i].selected)
        {
            data = data+FName.options[i].value+",";
        }
    }

    if(document.getElementById("destination").value.length > 0)
    {
        document.getElementById("destination").value += ",";	
    }
    document.getElementById("destination").value += data;	
    var destiny = document.getElementById("destination").value;

    var deslen = destiny.length-1;

    if(destiny.charAt(deslen)==",")
    {
        document.getElementById("destination").value = destiny.substring(0,deslen);
    }
}

//Comunity List

function member(grpname,gId)
{

    document.comunityList.action='listmembers.php';
    document.comunityList.groupnam.value=grpname;
    document.comunityList.groupid.value=gId;
    //obj.groupnam.value=grpname;
    document.comunityList.submit();

}

// Buddy List 2grp

function buddygrp_back(obj)
{
    obj.action='list_members.php';	
    obj.submit();
}

function ChangeInboxSelectOption()
{
    ctr = document.inbox;
    if(ctr.sel_option.value=="None")
    {
        for (i=0;i<ctr.length;i++)
        {
            var el = ctr.elements[i].name;
            if (el.indexOf("messid")!= -1)
            {
                ctr.elements[i].checked=false;
            }
        }
    }
    if(ctr.sel_option.value=="All")
    {
        for (i=0;i<ctr.length;i++)
        {
            var el = ctr.elements[i].name;
            if (el.indexOf("messid")!= -1)
            {
                ctr.elements[i].checked=true;
            }
        }
    }

    if(ctr.sel_option.value=="Read")
    {
        for (i=0;i<ctr.length;i++)
        {
            var el = ctr.elements[i].name;
            if (el.indexOf("messid")!= -1)
            {
                var toggId = ctr.elements[i].id;
                if (toggId.indexOf("_0")!= -1)
                {
                    ctr.elements[i].checked=false;
                }
                else
                {
                    ctr.elements[i].checked=true;
                }

            }
        }
    }

    if(ctr.sel_option.value=="Unread")
    {
        for (i=0;i<ctr.length;i++)
        {
            var el = ctr.elements[i].name;
            if (el.indexOf("messid")!= -1)
            {
                var toggId = ctr.elements[i].id;
                if (toggId.indexOf("_0")!= -1)
                {
                    ctr.elements[i].checked=true;
                }
                else
                {
                    ctr.elements[i].checked=false;
                }

            }
        }
    }

}

function  changeMarkAs(txt)
{
    ctr = document.inbox;
    ctr.mark_as.value=txt;
    ctr.submit();
}

//List Members
function dele(obj)
{

    document.dataform1.del.value=obj;

    document.dataform1.submit();
}

function ConfirmMessDel(id)
{
    var where_to = confirm("Do you want to delete this message?");
    if(where_to == true)
    {
        ctr = document.inbox;
        ctr.id_message.value = id;
        ctr.mode.value = "MessageDelete";
        ctr.action="process.php";
        ctr.submit();
    }
}

function ConfirmMessDelForCommunity(id)
{
    var where_to = confirm("Do you want to delete this message?");
    if(where_to == true)
    {
        ctr = document.inbox;
        ctr.id_message.value = id;
        ctr.mode.value = "MessageDeleteForCommunity";
        ctr.action="process.php";
        ctr.submit();
    }
}

//Comunity friend

function accept1(obj)
{

    obj.acc.value=obj.requestId.value;
    //alert(obj.acc.value);

    obj.submit();
}

function reject1(obj)
{
    obj.rej.value=obj.requestId.value;
    //alert(obj.rej.value);

    obj.submit();


}

function showInline (elName) {

    var theElemenet = document.getElementById(elName);
    if (theElemenet) {
        theElemenet.style.display = "inline";
    }
}
function hideInline (elName) {
    var theElemenet = document.getElementById(elName);
    if (theElemenet) {
        theElemenet.style.display = "none";
    }
}

function ValidateSendMessage()
{
    ctr = document.send_sms;
    if(ctr.phone.value=="")
    {
        alert("Please enter phone number.");
        ctr.phone.focus();
        return false;
    }

    if(isNaN(ctr.phone.value))
    {
        alert("Phone number should be numeric only.");
        ctr.phone.focus();
        return false;
    }
    if(ctr.phone.value.length<10)
    {
        alert("Invalid phone number.");
        ctr.phone.focus();
        return false;
    }
    return true;
}

function SetSoftboardHeight()
{
    if(document.getElementById("oDiv")!=undefined)
    {
        var theDiv = document.getElementById("oDiv");
        var dheight = theDiv.offsetHeight;	
        if(dheight==0)
        {
            theDiv.style.height=404;
        }
        else
        {
            if(dheight<404)
            {
                theDiv.style.height=parseInt(dheight+60);
            }
            else
            {
                theDiv.style.height=404;
            }
        }	
    }
}

function ValidateUploadCelebrityImage()
{
    ctr = document.send_sms;
    if(ctr.reference.value=="")
    {
        alert("Please select an image.");
        ctr.reference.focus();
        return false;
    }
    return true;
}



function ShowHideLeft(toggleId)
{
    var body1 = document.getElementById(toggleId);
    var body2 = document.getElementById("link_"+toggleId);
    //alert("this is here..."+body2);

    if (body1.style.display == "none")
    {
        body1.style.display = "block";

        body2.className='left_category_sel';

    }
    else
    {
        body1.style.display = "none";
        body2.className='left_category';


    }

    var x;
    for (x in myCats)
    {

        if(toggleId == myCats[x]){
            var body1 = document.getElementById(myCats[x]);
            body1.style.display = "block";
            var body2 = document.getElementById("link_"+myCats[x]);
            body2.className='left_category_sel';

        } else {
            var body1 = document.getElementById(myCats[x]);
            body1.style.display = "none";
            var body2 = document.getElementById("link_"+myCats[x]);
            body2.className='left_category';


        }	
    } 


}

function ShowLeft(toggleId,sel_img)
{
    //alert("toggleId = " + toggleId);
    var body1 = document.getElementById(toggleId);
    body1.style.display = "block";

}

function open_timedMenu(menuName, openTime)
{
    //clearTimeout(menuTimer);
    ShowHideLeft(menuName);

    //var functionStr = "ShowHideLeft('" + menuName + "')";
    //menuTimer = setTimeout(functionStr, openTime);
}

function open_timedMenu_1(menuName, openTime, bgsel)
{
    //clearTimeout(menuTimer);
    //var functionStr = "ShowHideLeft('" + menuName + "')";
    //ShowHideLeft(menuName);
    var body1 = document.getElementById(menuName);
    body1.style.display = "none";

    var body2 = document.getElementById("link_"+menuName);
    if(bgsel =="yes")
    {
        body2.className='left_category_sel';
    }else
    {
        body2.className='left_category';
    }




}
function open_timedMenu_3(menuName, openTime)
{
    var body2 = document.getElementById("link_"+menuName);
    body2.className='left_category_sel';
    //alert("aaaaaaaaaaa");
    //document.getElementById(menuName).className='leftbg_sel';
}
function open_timedMenu_4(menuName, openTime)
{
    var body2 = document.getElementById("link_"+menuName);
    body2.className='left_category';

    //document.getElementById(leftcr).className='';
}

function mouseover(leftcr, openfly)
{
    document.getElementById(leftcr).className='leftbg_sel';
    var body2 = document.getElementById("link_"+openfly);
    body2.className='left_category_sel';


    //$newtst="onMouseover=dropdownmenu('leftcat1')";
}
function mouseout(leftcr, openfly, bgsel)
{
    document.getElementById(leftcr).className='left_category';
    var body2 = document.getElementById("link_"+openfly);
    if(bgsel =="yes")
    {
        body2.className='left_category_sel';
    }else
    {
        body2.className='left_category';

    }
} 


function mouseout_1(toggleId,toggleclr)
{
    var body1 = document.getElementById(toggleId);
    body1.style.display = "none";
    document.getElementById(toggleclr).className='left_category';
    var body2 = document.getElementById("link_"+toggleId);
    body2.className='left_category';
} 

function mouseover_2(toggleId,toggleclr)
{
    var body1 = document.getElementById(toggleId);
    body1.style.display = "block";
    document.getElementById(toggleclr).className='leftbg_sel';
    var body2 = document.getElementById("link_"+toggleId);
    body2.className='left_category_sel';
} 


function mouseover_topmenu(toggleId)
{
    var body2 = document.getElementById("main_div_"+toggleId);
    var link_text = document.getElementById("main_div_url_"+toggleId);
    body2.className='leftbg_sel';
    link_text.style.color="#ffffff";
    //var browser=navigator.appName;
    var b_version=navigator.appVersion;
    var re = "MSIE 6.0";
    var found = b_version.match( re );
    if(found=="MSIE 6.0")
    {
        if(toggleId != 804 && toggleId != 805)
        {
            document.getElementById("id_sort_select").style.display="none";    
        }

    }
    //link_text.className='sublink_se';
} 

function mouseout_topmenu(toggleId,cat)
{
    var body2 = document.getElementById("main_div_"+toggleId);
    var link_text = document.getElementById("main_div_url_"+toggleId);
    body2.className='';
    if(toggleId == cat){
        //link_text.className='sublink_sel';
        link_text.style.color="#FF3746";
    } else {
        //link_text.className='sublink';
        link_text.style.color="#000000";
    }
    var b_version=navigator.appVersion;
    var re = "MSIE 6.0";
    var found = b_version.match( re );
    if(found=="MSIE 6.0")
    {
        if(toggleId != 804 && toggleId != 805)
        {
            document.getElementById("id_sort_select").style.display="inline";
        }
    }
} 

function mouseover_topmenu_off(toggleId)
{
    var body2 = document.getElementById("main_div_"+toggleId);
    var link_text = document.getElementById("main_div_url_"+toggleId);
    body2.className='sublink_se';
    //link_text.style.color="#ffffff";
    link_text.className='sublink_se';
} 

function mouseout_topmenu_off(toggleId,cat)
{
    var body2 = document.getElementById("main_div_"+toggleId);
    var link_text = document.getElementById("main_div_url_"+toggleId);
    body2.className='';
    if(toggleId == cat){
        link_text.className='sublink_se';

    } else {
        link_text.className='sublink';

    }
} 

function ShowLeftAsSelected(ctn_sel){

    if(ctn_sel != "")
    {
        var body2 = document.getElementById(ctn_sel);
        body2.className='left_navigation_sublink_selected';	
    }
}

function ShowTopAsSelected(ctn_sel){
    if(ctn_sel !="")
    {
        var body2 = document.getElementById(ctn_sel);
        body2.className='sublink_sel';	
    }
}

function ShowBottomAsSelected(ctn_sel){
    var body2 = document.getElementById(ctn_sel);
    body2.className='sublink_sel';		
}



function add_to_cart(product_id,prodprice,prodtitle,cur_id)
{
    var url = "process.php";
    var params = "mode=AddToCart&ProdNum="+product_id+"&ProdPrice="+prodprice+"&ProdTitle="+escape(prodtitle)+"&cur_id="+cur_id;
    var response = AjaxAgent.call(url,"","",params);
    document.getElementById("marksheet_detail").innerHTML = response;
    //alert(response);
    //alert(item_added_message);

    //reload the marksheet_detail
    //var url = "process.php";
    //var params = "mode=reloadMarksheetDetail";
    //AjaxAgent.call(url,"","reload_marksheetdetail",params);

    return response;
}

function add_to_cart_layer(product_id,prodprice,prodtitle,cur_id)
{
    var url = "process.php";
    var params = "mode=AddToCart&ProdNum="+product_id+"&ProdPrice="+prodprice+"&ProdTitle="+escape(prodtitle)+"&cur_id="+cur_id;
    var response = AjaxAgent.call(url,"","",params);
    var object = document.getElementById('link_'+product_id);
    var img = object.firstChild;
    if(img.innerHTML.search(/Artikel von Merkzettel entfernen/) != -1) {
        if(response) {
            img.innerHTML = '<font class="Headline_brand_underline">Artikel merken</font>'
        }
    }
    else
    {
        if(response) {
            img.innerHTML = '<font class="Headline_brand_underline_red">Artikel von Merkzettel entfernen</font>';
        }
    }

    document.getElementById("marksheet_detail").innerHTML = response;
    //alert(response);
    //alert(item_added_message);

    //reload the marksheet_detail
    //var url = "process.php";
    //var params = "mode=reloadMarksheetDetail";
    //AjaxAgent.call(url,"","reload_marksheetdetail",params);
    //window.location.reload();
    return response;
}
function add_to_cart_layer_grid(product_id,prodprice,prodtitle,cur_id)
{
    var url = "process.php";
    var params = "mode=AddToCart&ProdNum="+product_id+"&ProdPrice="+prodprice+"&ProdTitle="+escape(prodtitle)+"&cur_id="+cur_id;
    var response = AjaxAgent.call(url,"","",params);
    var object = document.getElementById('link_'+product_id);
    var img = object.firstChild;
    if(img.innerHTML.search(/gemerkt/) != -1) {
        if(response) {
            img.innerHTML = '<font class="Headline_brand_underline">merken</font>'
        }
    }
    else
    {
        if(response) {
            img.innerHTML = '<font class="Headline_brand_underline_red">gemerkt</font>';
        }
    }

    document.getElementById("marksheet_detail").innerHTML = response;
    //alert(response);
    //alert(item_added_message);

    //reload the marksheet_detail
    //var url = "process.php";
    //var params = "mode=reloadMarksheetDetail";
    //AjaxAgent.call(url,"","reload_marksheetdetail",params);
    //window.location.reload();
    return response;
}

function delete_from_cart_layer(product_id)
{
    var url = "process.php";
    var params = "mode=DeleteFromCart&ProdNum="+product_id;
    var response = AjaxAgent.call(url,"","",params);
    var object = document.getElementById('link_'+product_id);
    var img = object.firstChild;
    if(img.innerHTML.search(/Artikel von Merkzettel entfernen/) != -1) {
        if(response) {
            img.innerHTML = '<font class="Headline_brand_underline">Artikel merken</font>'
        }
    }
    else
    {
        if(response) {
            img.innerHTML = '<font class="Headline_brand_underline_red">Artikel von Merkzettel entfernen</font>';
        }
    }
    document.getElementById("marksheet_detail").innerHTML = response;

    //alert(item_deleted_message);


    //reload the marksheet_detail
    //var url = "process.php";
    //var params = "mode=reloadMarksheetDetail";
    //AjaxAgent.call(url,"","reload_marksheetdetail",params);

    //window.location.reload();

    return response;
}


function delete_from_cart_layer_grid(product_id)
{
    var url = "process.php";
    var params = "mode=DeleteFromCart&ProdNum="+product_id;
    var response = AjaxAgent.call(url,"","",params);
    var object = document.getElementById('link_'+product_id);
    var img = object.firstChild;
    if(img.innerHTML.search(/gemerkt/) != -1) {
        if(response) {
            img.innerHTML = '<font class="Headline_brand_underline">merken</font>'
        }
    }
    else
    {
        if(response) {
            img.innerHTML = '<font class="Headline_brand_underline_red">gemerkt</font>';
        }
    }
    document.getElementById("marksheet_detail").innerHTML = response;

    //alert(item_deleted_message);


    //reload the marksheet_detail
    //var url = "process.php";
    //var params = "mode=reloadMarksheetDetail";
    //AjaxAgent.call(url,"","reload_marksheetdetail",params);

    //window.location.reload();

    return response;
}


function delete_from_cart(product_id)
{
    var url = "process.php";
    var params = "mode=DeleteFromCart&ProdNum="+product_id;
    var response = AjaxAgent.call(url,"","",params);
    //alert(response);
    document.getElementById("marksheet_detail").innerHTML = response;

    //alert(item_deleted_message);


    //reload the marksheet_detail
    //var url = "process.php";
    //var params = "mode=reloadMarksheetDetail";
    //AjaxAgent.call(url,"","reload_marksheetdetail",params);

    if(document.URL.search(/marksheet.php$/) != -1) {
        // Reload page because we are in the marksheet
        location.reload();
    }

    return response;
}

function switch_marksheet(product_id, price_original, product_name_original, currency) {
    var object = document.getElementById('link_'+product_id);

    if(object) {
        var img = object.firstChild;
        if(img.src.search(/merkzettel_2/) != -1) {
            // product is already in the marksheet
            var response = delete_from_cart(product_id);
            if(response) {
                rand_flt = Math.random();
                img.src = 'images/merkzettel_1.gif?' + rand_flt;
                img.alt = 'In den Merkzettel übernehmen';
                img.title = img.alt;
            }
        } else {
            // product is not in the marksheet yet
            var response = add_to_cart(product_id, price_original, product_name_original, currency);
            if(response) {
                rand_flt = Math.random();
                img.src = 'images/merkzettel_2.gif?' + rand_flt;
                img.alt = 'Vom Merkzettel entfernen';
                img.title = img.alt;
            }
        }
    } else {
    }

    //	document.getElementById("marksheet_detail").innerHTML = response;
    return;
}

function switch_marksheet_list2(product_id, price_original, product_name_original, currency) {
    var object = document.getElementById('link_'+product_id);

    if(object) {
        var img = object.firstChild;
        if(img.innerHTML.search(/gemerkt/) != -1) {
            // product is already in the marksheet
            var response = delete_from_cart(product_id);
            if(response) {
                //rand_flt = Math.random();
                img.innerHTML = '<font class="Headline_brand_underline">merken</font>'
                //img.alt = 'In den Merkzettel übernehmen';
                //img.title = img.alt;
            }
            window.location.reload();
        } else {
            // product is not in the marksheet yet
            var response = add_to_cart(product_id, price_original, product_name_original, currency);
            if(response) {
                //rand_flt = Math.random();
                //img.src = 'images/merkzettel_2.gif?' + rand_flt;

                img.innerHTML = '<font class="Headline_brand_underline_red">gemerkt</font>';

                //img.alt = 'Vom Merkzettel entfernen';
                //img.title = img.alt;
            }
        }
    } else {
    }

    //    document.getElementById("marksheet_detail").innerHTML = response;
    return;
}
function switch_marksheet_detail(product_id, price_original, product_name_original, currency) {
    var img = document.getElementById('link_'+product_id);

    if(img) {

        if(img.innerHTML.search(/Artikel von Merkzettel entfernen/) != -1) {
            // product is already in the marksheet
            var response = delete_from_cart(product_id);
            if(response) {
                //rand_flt = Math.random();
                img.innerHTML = '<font class="Headline_brand_underline">Artikel merken</font>'
                //img.alt = 'In den Merkzettel übernehmen';
                //img.title = img.alt;
            }
        } else {
            // product is not in the marksheet yet
            var response = add_to_cart(product_id, price_original, product_name_original, currency);
            if(response) {
                //rand_flt = Math.random();
                //img.src = 'images/merkzettel_2.gif?' + rand_flt;

                img.innerHTML = '<font class="Headline_brand_underline_red">Artikel von Merkzettel entfernen</font>';

                //img.alt = 'Vom Merkzettel entfernen';
                //img.title = img.alt;
            }
        }
    } else {
    }

    //    document.getElementById("marksheet_detail").innerHTML = response;
    return;
}


function switch_marksheet_bk(product_id, price_original, product_name_original, currency) {
    var object = document.getElementById('link_'+product_id);

    if(object) {
        var img = object.firstChild;
        if(img.innerHTML.search(/gemerkt/) != -1) {
            // product is already in the marksheet
            var response = delete_from_cart(product_id);
            if(response) {
                //rand_flt = Math.random();
                img.innerHTML = '<font class="Headline_brand_underline">merken</font>'
                //img.alt = 'In den Merkzettel übernehmen';
                //img.title = img.alt;
            }
        } else {
            // product is not in the marksheet yet
            var response = add_to_cart(product_id, price_original, product_name_original, currency);
            if(response) {
                //rand_flt = Math.random();
                //img.src = 'images/merkzettel_2.gif?' + rand_flt;

                img.innerHTML = '<font class="Headline_brand_underline_red">gemerkt</font>';

                //img.alt = 'Vom Merkzettel entfernen';
                //img.title = img.alt;
            }
        }
    } else {
    }

    //	document.getElementById("marksheet_detail").innerHTML = response;
    return;
}

function delete_from_user_cart(product_id)
{
    var url = "process.php";
    var params = "mode=DeleteFromCart&ProdNum="+product_id;
    var response = AjaxAgent.call(url,"","",params);
    //alert(response);
    //alert(item_deleted_message);

    //reload the marksheet_detail
    //var url = "process.php";
    //var params = "mode=reloadMarksheetDetail";
    //AjaxAgent.call(url,"","reload_marksheetdetail",params);

    //window.location.href='marksheet.php';

    window.location.reload();

    return;
}


function delete_from_user_cart_layer(product_id)
{
    var url = "process.php";
    var params = "mode=DeleteFromCart&ProdNum="+product_id;
    var response = AjaxAgent.call(url,"","",params);
    //alert(response);
    //alert(item_deleted_message);

    //reload the marksheet_detail
    //var url = "process.php";
    //var params = "mode=reloadMarksheetDetail";
    //AjaxAgent.call(url,"","reload_marksheetdetail",params);

    //window.location.href='marksheet.php';

    window.location.reload();

    return;
}

function reload_marksheetdetail(output)
{
    document.getElementById("marksheet_detail").innerHTML = output;

}


function reload_marksheet_page()
{
    //reload the marksheet_detail
    var url = "process.php";
    var params = "mode=reloadMarksheetDetailPage";
    var output = AjaxAgent.call(url,"","",params);

    document.getElementById("marksheet_detail").innerHTML = output;

    return;
}


// #########  code from js/ajax.loading.js   ######### //

function getNextProductsAjax(page, cat, limit, bgclass, min, max)
{
    pageTracker._trackPageview(SITE_URL+"product.php?cat="+cat+"&page="+page); // for google analytic
    //alert(SITE_URL+"product.php?cat="+cat+"&page="+page);

    //tt_Hide();

    document.getElementById("popupmaskloading").className=bgclass;
    var sort = document.getElementById("id_sort_select").value;
    var url = "product.php";
    if(limit==""){
        var params = "page="+page+"&cat="+cat+"&sort="+sort+"&GetIt=Ajax&min="+min+"&max="+max;
    }else{
        var params = "page="+page+"&cat="+cat+"&sort="+sort+"&limit="+limit+"&GetIt=Ajax&min="+min+"&max="+max;
    }
    AjaxAgent.call(url,"","getNextProductsAjaxResponse",params);
}

function getNextProductsAjaxResponse(output)
{
    //alert(output);

    document.getElementById('products_center_id').innerHTML=output;
    var scriptMarker = "<!--JSCODE-->";
    var indexOfStart = 0;
    var indexOfMarker = 0;
    while ((indexOfMarker = output.indexOf(scriptMarker, indexOfStart)) != -1) {
        indexOfStart = indexOfMarker + scriptMarker.length;
        var indexOfEnd = output.indexOf(scriptMarker, indexOfStart);
        var substring = output.substring(indexOfStart, indexOfEnd);
        eval(substring);
        indexOfStart = indexOfEnd + 1;
    }    	

    ReloadPixelImages();
    window.scrollTo(0,0);
}

//  for partner product page......
function getNextPartnerProductsAjax(page, pid, limit, bgclass, min, max)
{
    pageTracker._trackPageview(SITE_URL+"partner_product.php?pid="+pid+"&page="+page); // for google analytic
    //alert(SITE_URL+"partner_product.php?pid="+pid+"&page="+page);

    document.getElementById("popupmaskloading").className=bgclass;
    var sort = document.getElementById("id_sort_select").value;
    var url = "partner_product.php";
    if(limit==""){
        var params = "page="+page+"&pid="+pid+"&sort="+sort+"&GetIt=Ajax&min="+min+"&max="+max;
    }else{
        var params = "page="+page+"&pid="+pid+"&sort="+sort+"&limit="+limit+"&GetIt=Ajax&min="+min+"&max="+max;
    }
    AjaxAgent.call(url,"","getNextPartnerProductsAjaxResponse",params);
}

function getNextPartnerProductsAjaxResponse(output)
{
    //alert(output);
    document.getElementById('products_center_id').innerHTML=output;
    var scriptMarker = "<!--JSCODE-->";
    var indexOfStart = 0;
    var indexOfMarker = 0;
    while ((indexOfMarker = output.indexOf(scriptMarker, indexOfStart)) != -1) {
        indexOfStart = indexOfMarker + scriptMarker.length;
        var indexOfEnd = output.indexOf(scriptMarker, indexOfStart);
        var substring = output.substring(indexOfStart, indexOfEnd);
        eval(substring);
        indexOfStart = indexOfEnd + 1;
    }    	
    ReloadPixelImages(); 
    window.scrollTo(0,0);
}

function getNextResultAjax(page, cat, limit, bgclass, is_sort, min, max)
{
    pageTracker._trackPageview(SITE_URL+"result.php?cat="+cat+"&page="+page); // for google analytic
    //alert(SITE_URL+"result.php?cat="+cat+"&page="+page);

    document.getElementById("popupmaskloading").className=bgclass;
    var sort = document.getElementById("id_sort_select").value;
    var url = "result.php";
    if(arguments[4]=="yes"){
        var params = "page="+page+"&cat="+cat+"&sort="+sort+"&sortchange=yes&previous_value="+document.sortform.value+"&GetIt=Ajax&min="+min+"&max="+max;
    }else{
        if(limit==""){
            var params = "page="+page+"&cat="+cat+"&sort="+sort+"&GetIt=Ajax&min="+min+"&max="+max;
        }else{
            var params = "page="+page+"&cat="+cat+"&sort="+sort+"&limit="+limit+"&GetIt=Ajax&min="+min+"&max="+max;
        }
    }
    //alert(url+" = "+params);
    AjaxAgent.call(url,"","getNextResultAjaxResponse",params);
}

function getNextMarkenResultAjax(page, cat, limit, bgclass, is_sort, min, max)
{
    pageTracker._trackPageview(SITE_URL+"marken_result.php?cat="+cat+"&page="+page); // for google analytic
    //alert(SITE_URL+"marken_result.php?cat="+cat+"&page="+page);

    document.getElementById("popupmaskloading").className=bgclass;
    var sort = document.getElementById("id_sort_select").value;
    var url = "marken_result.php";
    if(arguments[4]=="yes"){
        var params = "page="+page+"&cat="+cat+"&sort="+sort+"&sortchange=yes&previous_value="+document.sortform.value+"&GetIt=Ajax&min="+min+"&max="+max;
    }else{
        if(limit==""){
            var params = "page="+page+"&cat="+cat+"&sort="+sort+"&GetIt=Ajax&min="+min+"&max="+max;
        }else{
            var params = "page="+page+"&cat="+cat+"&sort="+sort+"&limit="+limit+"&GetIt=Ajax&min="+min+"&max="+max;
        }
    }
    //alert(url+" = "+params);
    AjaxAgent.call(url,"","getNextResultAjaxResponse",params);
}

function getNextResultAjaxResponse(output)
{
    //alert(output);
    document.getElementById('products_center_id').innerHTML=output;
    var scriptMarker = "<!--JSCODE-->";
    var indexOfStart = 0;
    var indexOfMarker = 0;
    while ((indexOfMarker = output.indexOf(scriptMarker, indexOfStart)) != -1) {
        indexOfStart = indexOfMarker + scriptMarker.length;
        var indexOfEnd = output.indexOf(scriptMarker, indexOfStart);
        var substring = output.substring(indexOfStart, indexOfEnd);
        eval(substring);
        indexOfStart = indexOfEnd + 1;
    }    	

    ReloadPixelImages();
    window.scrollTo(0,0);
}

function SetCookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function getArtDetailFilter(cat)
{
    var url = "process.php";
    var params = "mode=getArtDetailFilter&cat="+cat;
    AjaxAgent.call(url,"","getArtDetailFilterResponse",params);
}

function getArtDetailFilterResponse(output)
{
    document.getElementById('art_detail').innerHTML=output;
    //getLoadPriceFilterAjax();
}

function getLoadPriceFilterAjax()
{
    var url = "process.php";
    var params = "mode=getLoadPriceFilterAjax";
    AjaxAgent.call(url,"","getLoadPriceFilterAjaxResponse",params);
}


function getLoadPriceFilterAjaxResponse(output)
{
    document.getElementById('price_filter').innerHTML=output;
    getLoadOtherCategoryFilterAjax();
}


function getLoadOtherCategoryFilterAjax()
{
    var url = "process.php";
    var params = "mode=getLoadOtherCategoryFilterAjax";
    AjaxAgent.call(url,"","getLoadOtherCategoryFilterAjaxResponse",params);
}


function getLoadOtherCategoryFilterAjaxResponse(output)
{
    document.getElementById('other_category_filter').innerHTML=output;
    getLoadOurPartnerFilterAjax();
}


function getLoadOurPartnerFilterAjax()
{
    var url = "process.php";
    var params = "mode=getLoadOurPartnerFilterAjax";
    AjaxAgent.call(url,"","getLoadOurPartnerFilterAjaxResponse",params);
}


function getLoadOurPartnerFilterAjaxResponse(output)
{
    document.getElementById('our_partenrs').innerHTML=output;
}

function getSearchCategoryFilter()
{
    var url = "process.php";
    var params = "mode=getSearchCategoryFilter";
    AjaxAgent.call(url,"","getSearchCategoryFilterResponse",params);
}

function getSearchCategoryFilterResponse(output)
{
    document.getElementById('search_category_filter').innerHTML=output;
}

//
function getLoadPriceFilterAjaxResult()
{
    var url = "process.php";
    var params = "mode=getLoadPriceFilterAjaxResult";
    AjaxAgent.call(url,"","getLoadPriceFilterAjaxResultResponse",params);
}


function getLoadPriceFilterAjaxResultResponse(output)
{
    document.getElementById('price_filter').innerHTML=output;
    getLoadOtherCategoryFilterAjaxResult();
}


function getLoadOtherCategoryFilterAjaxResult()
{
    var url = "process.php";
    var params = "mode=getLoadOtherCategoryFilterAjaxResult";
    AjaxAgent.call(url,"","getLoadOtherCategoryFilterAjaxResultResponse",params);
}


function getLoadOtherCategoryFilterAjaxResultResponse(output)
{
    document.getElementById('other_category_filter').innerHTML=output;
    getLoadOurPartnerFilterAjaxResult();
}


function getLoadOurPartnerFilterAjaxResult()
{
    var url = "process.php";
    var params = "mode=getLoadOurPartnerFilterAjaxResult";
    AjaxAgent.call(url,"","getLoadOurPartnerFilterAjaxResultResponse",params);
}


function getLoadOurPartnerFilterAjaxResultResponse(output)
{
    document.getElementById('our_partenrs').innerHTML=output;
}



// #########  code from js/categorycontentslider.js   ######### //


//** Featured Content Slider script- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com.
//** May 2nd, 08'- Script rewritten and updated to 2.0.
//** June 12th, 08'- Script updated to v 2.3, which adds the following features:
//1) Changed behavior of script to actually collapse the previous content when the active one is shown, instead of just tucking it underneath the later.
//2) Added setting to reveal a content either via "click" or "mouseover" of pagination links (default is former).
//3) Added public function for jumping to a particular slide within a Featured Content instance using an arbitrary link, for example.

//** July 11th, 08'- Script updated to v 2.4:
//1) Added ability to select a particular slide when the page first loads using a URL parameter (ie: mypage.htm?myslider=4 to select 4th slide in "myslider")
//2) Fixed bug where the first slide disappears when the mouse clicks or mouses over it when page first loads.

var featuredcontentslider={

    //3 variables below you can customize if desired:
    ajaxloadingmsg: '<div style="margin: 20px 0 0 20px"><img src="images/loading.gif" /> Fetching slider Contents. Please wait...</div>',
    bustajaxcache: true, //bust caching of external ajax page after 1st request?
    enablepersist: true, //persist to last content viewed when returning to page?

    settingcaches: {}, //object to cache "setting" object of each script instance

    jumpTo:function(fcsid, pagenumber){ //public function to go to a slide manually.
        this.turnpage(this.settingcaches[fcsid], pagenumber)
    },

    ajaxconnect:function(setting){
        var page_request = false
        if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
            try {
                page_request = new ActiveXObject("Msxml2.XMLHTTP")
            } 
            catch (e){
                try{
                    page_request = new ActiveXObject("Microsoft.XMLHTTP")
                }
                catch (e){}
            }
        }
        else if (window.XMLHttpRequest) // if Mozilla, Safari etc
        page_request = new XMLHttpRequest()
        else
        return false
        var pageurl=setting.contentsource[1]
        page_request.onreadystatechange=function(){
            featuredcontentslider.ajaxpopulate(page_request, setting)
        }
        document.getElementById(setting.id).innerHTML=this.ajaxloadingmsg
        var bustcache=(!this.bustajaxcache)? "" : (pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
        page_request.open('GET', pageurl+bustcache, true)
        page_request.send(null)
    },

    ajaxpopulate:function(page_request, setting){
        if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
            document.getElementById(setting.id).innerHTML=page_request.responseText
            this.buildpaginate(setting)
        }
    },

    buildcontentdivs:function(setting){
        var alldivs=document.getElementById(setting.id).getElementsByTagName("div")
        for (var i=0; i<alldivs.length; i++){
            if (this.css(alldivs[i], "contentdiv", "check")){ //check for DIVs with class "contentdiv"
                setting.contentdivs.push(alldivs[i])
                alldivs[i].style.display="none" //collapse all content DIVs to begin with
            }
        }
    },

    buildpaginate:function(setting){
        this.buildcontentdivs(setting)
        var sliderdiv=document.getElementById(setting.id)
        var pdiv=document.getElementById("paginate-"+setting.id)
        var phtml=""
        var toc=setting.toc
        var nextprev=setting.nextprev
        if (typeof toc=="string" && toc!="markup" || typeof toc=="object"){
            for (var i=1; i<=setting.contentdivs.length; i++){
                phtml+='<a href="#'+i+'" class="toc">'+(typeof toc=="string"? toc.replace(/#increment/, i) : toc[i-1])+'</a>'
                if(i<3)
                {
                    //phtml+='<IMG SRC="images/animatedbanner_02.gif" WIDTH=22 HEIGHT=18>';
                    phtml+="<div style='float:left;margin-left:10px;margin-right:10px' class='Headline_Animation'>/</div>";
                }
            }
            phtml=(nextprev[0]!=''? '<a href="#prev" class="prev">'+nextprev[0]+'</a> ' : '') + phtml + (nextprev[1]!=''? '<a href="#next" class="next">'+nextprev[1]+'</a>' : '')
            pdiv.innerHTML=phtml
        }
        var pdivlinks=pdiv.getElementsByTagName("a")
        var toclinkscount=0 //var to keep track of actual # of toc links
        for (var i=0; i<pdivlinks.length; i++){
            if (this.css(pdivlinks[i], "toc", "check")){
                if (toclinkscount>setting.contentdivs.length-1){ //if this toc link is out of range (user defined more toc links then there are contents)
                    pdivlinks[i].style.display="none" //hide this toc link
                    continue
                }
                pdivlinks[i].setAttribute("rel", ++toclinkscount) //store page number inside toc link
                pdivlinks[i][setting.revealtype]=function(){
                    featuredcontentslider.turnpage(setting, this.getAttribute("rel"))
                    return false
                }
                setting.toclinks.push(pdivlinks[i])
            }
            else if (this.css(pdivlinks[i], "prev", "check") || this.css(pdivlinks[i], "next", "check")){ //check for links with class "prev" or "next"
                pdivlinks[i].onclick=function(){
                    featuredcontentslider.turnpage(setting, this.className)
                    return false
                }
            }
        }
        this.turnpage(setting, setting.currentpage, true)
        if (setting.autorotate[0]){ //if auto rotate enabled
            pdiv[setting.revealtype]=function(){
                featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id])
            }
            sliderdiv["onclick"]=function(){ //stop content slider when slides themselves are clicked on
                featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id])
            }
            setting.autorotate[1]=setting.autorotate[1]+(1/setting.enablefade[1]*50) //add time to run fade animation (roughly) to delay between rotation
            this.autorotate(setting)
        }
    },

    urlparamselect:function(fcsid){
        var result=window.location.search.match(new RegExp(fcsid+"=(\\d+)", "i")) //check for "?featuredcontentsliderid=2" in URL
        return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index
    },

    turnpage:function(setting, thepage, autocall){
        var currentpage=setting.currentpage //current page # before change
        var totalpages=setting.contentdivs.length
        var turntopage=(/prev/i.test(thepage))? currentpage-1 : (/next/i.test(thepage))? currentpage+1 : parseInt(thepage)
        turntopage=(turntopage<1)? totalpages : (turntopage>totalpages)? 1 : turntopage //test for out of bound and adjust
        if (turntopage==setting.currentpage && typeof autocall=="undefined") //if a pagination link is clicked on repeatedly
        return
        setting.currentpage=turntopage
        setting.contentdivs[turntopage-1].style.zIndex=++setting.topzindex
        this.cleartimer(setting, window["fcsfade"+setting.id])
        setting.cacheprevpage=setting.prevpage
        if (setting.enablefade[0]==true){
            setting.curopacity=0
            this.fadeup(setting)
        }
        if (setting.enablefade[0]==false){ //if fade is disabled, fire onChange event immediately (verus after fade is complete)
            setting.contentdivs[setting.prevpage-1].style.display="none" //collapse last content div shown (it was set to "block")
            setting.onChange(setting.prevpage, setting.currentpage)
        }
        setting.contentdivs[turntopage-1].style.visibility="visible"
        setting.contentdivs[turntopage-1].style.display="block"
        if (setting.prevpage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted)
        this.css(setting.toclinks[setting.prevpage-1], "selected", "remove")
        if (turntopage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted)
        this.css(setting.toclinks[turntopage-1], "selected", "add")
        setting.prevpage=turntopage
        if (this.enablepersist)
        this.setCookie("fcspersist"+setting.id, turntopage)
    },

    setopacity:function(setting, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
        var targetobject=setting.contentdivs[setting.currentpage-1]
        if (targetobject.filters && targetobject.filters[0]){ //IE syntax
            if (typeof targetobject.filters[0].opacity=="number") //IE6
            targetobject.filters[0].opacity=value*100
            else //IE 5.5
            targetobject.style.filter="alpha(opacity="+value*100+")"
        }
        else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
        targetobject.style.MozOpacity=value
        else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
        targetobject.style.opacity=value
        setting.curopacity=value
    },

    fadeup:function(setting){
        if (setting.curopacity<1){
            this.setopacity(setting, setting.curopacity+setting.enablefade[1])
            window["fcsfade"+setting.id]=setTimeout(function(){featuredcontentslider.fadeup(setting)}, 50)
        }
        else{ //when fade is complete
            if (setting.cacheprevpage!=setting.currentpage) //if previous content isn't the same as the current shown div (happens the first time the page loads/ script is run)
            setting.contentdivs[setting.cacheprevpage-1].style.display="none" //collapse last content div shown (it was set to "block")
            setting.onChange(setting.cacheprevpage, setting.currentpage)
        }
    },

    cleartimer:function(setting, timervar){
        if (typeof timervar!="undefined"){
            clearTimeout(timervar)
            clearInterval(timervar)
            if (setting.cacheprevpage!=setting.currentpage){ //if previous content isn't the same as the current shown div
                setting.contentdivs[setting.cacheprevpage-1].style.display="none"
            }
        }
    },

    css:function(el, targetclass, action){
        var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
        if (action=="check")
        return needle.test(el.className)
        else if (action=="remove")
        el.className=el.className.replace(needle, "")
        else if (action=="add")
        el.className+=" "+targetclass
    },

    autorotate:function(setting){
        window["fcsautorun"+setting.id]=setInterval(function(){featuredcontentslider.turnpage(setting, "next")}, setting.autorotate[1])
    },

    getCookie:function(Name){ 
        var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
        if (document.cookie.match(re)) //if cookie found
        return document.cookie.match(re)[0].split("=")[1] //return its value
        return null
    },

    setCookie:function(name, value){
        document.cookie = name+"="+value

    },


    init:function(setting){
        var persistedpage=this.getCookie("fcspersist"+setting.id) || 1
        var urlselectedpage=this.urlparamselect(setting.id) //returns null or index from: mypage.htm?featuredcontentsliderid=index
        this.settingcaches[setting.id]=setting //cache "setting" object
        setting.contentdivs=[]
        setting.toclinks=[]
        setting.topzindex=0
        setting.currentpage=urlselectedpage || ((this.enablepersist)? persistedpage : 1)
        setting.prevpage=setting.currentpage
        setting.revealtype="on"+(setting.revealtype || "click")
        setting.curopacity=0
        setting.onChange=setting.onChange || function(){}
        if (setting.contentsource[0]=="inline")
        this.buildpaginate(setting)
        if (setting.contentsource[0]=="ajax")
        this.ajaxconnect(setting)
    }

}


// #########  code from images/loader.js   ######### //

var t_id = setInterval(animate,20);
var pos=0;
var dir=2;
var len=0;

function animate()
{
    var elem = document.getElementById('progress');
    if(elem != null) {
        if (pos==0) len += dir;
        if (len>32 || pos>79) pos += dir;
        if (pos>79) len -= dir;
        if (pos>79 && len==0) pos=0;
        elem.style.left = pos;
        elem.style.width = len;
    }
}

function remove_loading() {
    this.clearInterval(t_id);
    var targelem = document.getElementById('loader_container');
    targelem.style.display='none';
    targelem.style.visibility='hidden';
    var t_id = setInterval(animate,60);
}


// #########  code from images/preview_templates.js   ######### //

var offsetfrommouse=[15,25]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.

var defaultimageheight = 40;	// maximum image size.
var defaultimagewidth = 40;	// maximum image size.

var timer;

function gettrailobj(){
    if (document.getElementById)
    return document.getElementById("preview_div").style
}

function gettrailobjnostyle(){
    if (document.getElementById)
    return document.getElementById("preview_div")
}


function truebody(){
    return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function hidetrail(){	
    gettrailobj().display= "none";
    document.onmousemove=""
    gettrailobj().left="-500px"
    clearTimeout(timer);
}

function showtrail(imagename,title,width,height){
    i = imagename
    t = title
    w = width
    h = height
    timer = setTimeout("show('"+i+"',t,w,h);",200);
}
function show(imagename,title,width,height){

    var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
    var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

    if( (navigator.userAgent.indexOf("Konqueror")==-1  || navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1)) && (docwidth>650 && docheight>500)) {
        ( width == 0 ) ? width = defaultimagewidth: '';
        ( height == 0 ) ? height = defaultimageheight: '';

        width+=30
        height+=55
        defaultimageheight = height
        defaultimagewidth = width

        document.onmousemove=followmouse; 


        newHTML = '<div class="border_preview" style="width:'+  width +'px;height:'+ height +'px"><div id="loader_container"><div id="loader"><div align="center">Loading template preview...</div><div id="loader_bg"><div id="progress"> </div></div></div></div>';
        newHTML = newHTML + '<font size="2" face="Tahoma" color="#766a62"><b>' + ' '+title + '</b></font>'

        newHTML = newHTML + '<div class="preview_temp_load"><img onload="javascript:remove_loading();" src="' + imagename + '" border="0"></div>';
        newHTML = newHTML + '</div>'; 

        if(navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1 ){
            newHTML = newHTML+'<iframe src="about:blank" scrolling="no" frameborder="0" width="'+width+'" height="'+height+'"></iframe>';
        }		

        gettrailobjnostyle().innerHTML = newHTML;
        gettrailobj().display="block";
    }
}

function followmouse(e){

    var xcoord=offsetfrommouse[0]
    var ycoord=offsetfrommouse[1]

    var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
    var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

    if (typeof e != "undefined"){
        if (docwidth - e.pageX < defaultimagewidth + 2*offsetfrommouse[0]){
            xcoord = e.pageX - xcoord - defaultimagewidth; // Move to the left side of the cursor
        } else {
            xcoord += e.pageX;
        }
        if (docheight - e.pageY < defaultimageheight + 2*offsetfrommouse[1]){
            ycoord += e.pageY - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + e.pageY - docheight - truebody().scrollTop));
        } else {
            ycoord += e.pageY;
        }

    } else if (typeof window.event != "undefined"){
        if (docwidth - event.clientX < defaultimagewidth + 2*offsetfrommouse[0]){
            xcoord = event.clientX + truebody().scrollLeft - xcoord - defaultimagewidth; // Move to the left side of the cursor
        } else {
            xcoord += truebody().scrollLeft+event.clientX
        }
        if (docheight - event.clientY < (defaultimageheight + 2*offsetfrommouse[1])){
            ycoord += event.clientY + truebody().scrollTop - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + event.clientY - docheight));
        } else {
            ycoord += truebody().scrollTop + event.clientY;
        }
    }
    gettrailobj().left=xcoord+"px"
    gettrailobj().top=ycoord+"px"

}


// #########  code from js/process_ajax.js   ######### //


/**************************************************************************************************************/
// Create xmlhttp object based on browsertype
function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
    try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
    xmlhttp = false;
    }
    }
    @else
    xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
            xmlhttp.overrideMimeType("text/xml"); 
        } catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}
/**************************************************************************************************************/
// Define global variables to be used throughout
//var BackgroundtableBusy = false;
//var BackgroundtableHttp = ();
//var step1Over = false;
//var row = "";

/**************************************************************************************************************/


function ChangeCountry(str)
{
    /*if (!BackgroundtableBusy)
    {*/
    var url = "process.php";		
    var params = "mode=GetStateSelectBox&q="+str+"&sid="+Math.random();
    var htmlRecord = AjaxAgent.call(url,"","",params);
    var outputArr = htmlRecord.split("|");
    document.getElementById("divCustomerInfo").innerHTML=outputArr[0]; 
    document.getElementById("CountryCode").value=outputArr[1]; 

    //BackgroundtableBusy = true;

    //}
}

function ChangeCountryResponse()
{
    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;
                var outputArr = htmlRecord.split("|");
                document.getElementById("divCustomerInfo").innerHTML=outputArr[0]; 
                document.getElementById("CountryCode").value=outputArr[1]; 

                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function

//---------------------------------------------------------------------------------------------
function checkUserAvailability(str)
{
    document.getElementById('divUserNameInfo').innerHTML="<img style='border:0px' src='js/loading.gif'>";

    var url = "process.php";		
    var params = "mode=checkUserAvailability&q="+str+"&sid="+Math.random();

    var htmlRecord = AjaxAgent.call(url,"","",params);
    document.getElementById("divUserNameInfo").innerHTML=htmlRecord; 


}

function checkUserAvailabilityResponse()
{
    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;
                document.getElementById("divUserNameInfo").innerHTML=htmlRecord; 

                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function

function DeleteMyPic()
{

    var url = "process.php";		
    var params = "mode=DeleteMyPic&sid="+Math.random();


    var htmlRecord = AjaxAgent.call(url,"","",params);
    if(htmlRecord=="DONE")
    {
        document.getElementById('user_present_pic').style.display="none";
        alert("Das Bild wurde erfolgreich gelöscht!");
    }


}

function DeleteMyPicResponse()
{
    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;

                if(htmlRecord=="DONE")
                {
                    document.getElementById('user_present_pic').style.display="none";
                    alert("Das Bild wurde erfolgreich gelöscht!");
                }

                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function

//---------------------------------------------------------------------------------------------
function sendMailToFriends(mode,product_id,fromname,fromemail,friendemails,personalmess)
{


    //document.getElementById('emailsenddiv').innerHTML="<img src='js/loading.gif'>";

    var url = "process.php";		
    var params = "mode="+mode+"&product_id="+product_id+"&fromname="+fromname+"&fromemail="+fromemail+"&friendemails="+friendemails+"&personalmess="+encodeURIComponent(personalmess);

    var htmlRecord = AjaxAgent.call(url,"","",params);
    if(htmlRecord=='errordetail')
    {

        window.top.location='index.php';
    }
    else
    {
        document.getElementById('shopproductdetail').innerHTML=htmlRecord;
    }
}

function sendMailToFriendsResponse()
{

    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;

                if(htmlRecord=='errordetail')
                {

                    window.top.location='index.php';
                }
                else
                {
                    document.getElementById('shopproductdetail').innerHTML=htmlRecord;
                }

                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function

//---------------------------------------------------------------------------------------------
function ShowImport(importoption)
{
    document.getElementById('showimportsemail').innerHTML="<img style='border:0px' src='js/loading.gif'>";
    var url = "process.php";		
    var params = "mode=ShowImport&importoption="+importoption;

    var htmlRecord = AjaxAgent.call(url,"","",params);
    var outputArr = new Array();
    outputArr = htmlRecord.split(":--");
    document.getElementById('importimages').innerHTML=outputArr[0];
    document.getElementById('showimportsemail').innerHTML=outputArr[1];

}

function ShowImportResponse()
{
    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;

                // Draw Record status and nav buttons
                var outputArr = new Array();
                outputArr = htmlRecord.split(":--");
                document.getElementById('importimages').innerHTML=outputArr[0];
                document.getElementById('showimportsemail').innerHTML=outputArr[1];

                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function

//---------------------------------------------------------------------------------------------
function ImportEmails(spimport,username,password)
{
    document.getElementById('processdiv').innerHTML="<img style='border:0px' src='js/loading.gif'>";

    var url = "process.php";		
    var params = "mode=ImportEmails&spimport="+spimport+"&username="+username+"&password="+password;

    var htmlRecord = AjaxAgent.call(url,"","",params);
    document.getElementById('processdiv').innerHTML="";
    document.getElementById('showimportsemail').innerHTML=htmlRecord;


}

function ImportEmailsResponse()
{
    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;

                // Draw Record status and nav buttons
                document.getElementById('processdiv').innerHTML="";
                document.getElementById('showimportsemail').innerHTML=htmlRecord;

                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function

//---------------------------------------------------------------------------------------------
function ForgotMyPassword()
{
    var email = document.getElementById('forgot_email').value;

    if(Trim(email)=="")
    {
        alert("Bitte Ihre Email eingeben!");
        return false;
    }

    if(EmailCheckjs(email)==false)
    {
        alert("Ungültige Email-Adresse!");
        return false;
    }
    document.getElementById('forgot_pass').innerHTML="<img style='border:0px' src='js/loading.gif'>";


    var url = "process.php";		
    var params = "mode=ForgotPassword&email="+escape(email)+"&sid="+Math.random();

    var htmlRecord = AjaxAgent.call(url,"","",params);
    document.getElementById('forgot_pass').innerHTML=htmlRecord;

}

function ForgotMyPasswordResponse()
{
    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;

                document.getElementById('forgot_pass').innerHTML=htmlRecord;

                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function

function DeleteCommunityPic(groupId)
{

    var url = "process.php";		
    var params = "mode=DeleteCommunityPic&gId="+groupId+"&sid="+Math.random();

    var htmlRecord = AjaxAgent.call(url,"","",params);
    document.getElementById('user_pic_div').innerHTML="Deleting...";
    if(htmlRecord=="DONE")
    {
        document.getElementById('user_present_pic').style.display="none";
        alert("Das Bild wurde erfolgreich entfernt!");
    }
}

function DeleteCommunityPicResponse()
{
    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;

                if(htmlRecord=="DONE")
                {
                    document.getElementById('user_present_pic').style.display="none";
                    alert("Das Bild wurde erfolgreich entfernt!");
                }

                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function

//---------------------------------Model------------------------------------------------------------
function sendMailModelToFriends(mode,vname,name1,email,email1,email2,email3,personalmess)
{
    document.getElementById('emailmodelsenddiv').innerHTML="<img src='js/loading.gif'>";

    var url = "process.php";		
    var params = "mode="+mode+"&vname="+vname+"&name1="+name1+"&email="+email+"&email1="+email1+"&email2="+email2+"&email3="+email3+"&personalmess="+encodeURIComponent(personalmess);

    var htmlRecord = AjaxAgent.call(url,"","",params);
    document.getElementById('emailmodelsenddiv').innerHTML=htmlRecord;

}

function sendModelToFriendsResponse()
{
    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;

                document.getElementById('emailmodelsenddiv').innerHTML=htmlRecord;

                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function

//-------------------------------------end model--------------------------------------------------------

//---------------------------------loadjs------------------------------------------------------------
function locadvideottrenwalk(TbID,LID)
{
    document.getElementById('popupmaskloading_t').innerHTML="<img src='js/loading_big.gif'>";
    document.getElementById("popupmaskloading_t").className='popupMaskForLoading_trend';


    var url = "trendwalk_ajax.php";	


    var params = "TbID="+TbID+"&LID="+LID;

    var htmlRecord = AjaxAgent.call(url,"","",params);

    if(document.getElementById("selectedVideo").value!="")
    {
        var selectId=document.getElementById("selectedVideo").value;
        document.getElementById("i_"+selectId).style.width="70px";
        document.getElementById("i_"+selectId).style.height="93px";
        document.getElementById("i_"+selectId).className="trendwalkborder2";

        document.getElementById("i_"+LID).style.width="70px";
        document.getElementById("i_"+LID).style.height="93px";
        document.getElementById("i_"+LID).className="trendwalkborder";
    }
    else
    {
        document.getElementById("i_"+LID).style.width="70px";
        document.getElementById("i_"+LID).style.height="93px";
        document.getElementById("i_"+LID).className="trendwalkborder";
    }
    document.getElementById("selectedVideo").value=LID;
    document.getElementById('loadcontent').innerHTML=htmlRecord;
    document.getElementById("popupmaskloading_t").className='popupmaskloading_t_no_display';
    document.getElementById('popupmaskloading_t').innerHTML="";


}

function sendrepondtrendwalk()
{



    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;



                document.getElementById('loadcontent').innerHTML=htmlRecord;
                document.getElementById("popupmaskloading_t").className='popupmaskloading_t_no_display';
                document.getElementById('popupmaskloading_t').innerHTML="";



                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function

//-------------------------------------end model--------------------------------------------------------

function showhide(proid)
{




    var col_array=document.getElementById("proarray").value.split(",");
    //alert( col_array.length);

    var part_num=0;
    while (part_num < col_array.length)
    {
        //alert(col_array[part_num]);

        if(proid==col_array[part_num])
        {

            var divid='p_'+proid;
            var tableid='t_'+proid;
            document.getElementById(divid).style.display='inline';

            //document.getElementById(tableid).className='trendwalkborder';
            document.getElementById(tableid).style.border='2px solid #f00000';
            var linkId=proid+'_link';
            var clickURLId=proid+'_clickURL';
            if(document.getElementById(linkId).name!='')
            {
                //window.location.href=document.getElementById(clickURLId).href;
                document.getElementById(linkId).target='_blank';
                document.getElementById(linkId).href=document.getElementById(clickURLId).href;
            }
            else
            {
                document.getElementById(linkId).name=proid;
            }  

        }
        else
        {
            var divid='p_'+col_array[part_num];
            var tableid='t_'+col_array[part_num];
            document.getElementById(divid).style.display='none';
            //document.getElementById(tableid).className='trendwalkborder1';
            document.getElementById(tableid).style.border='2px solid white';

            var linkId=col_array[part_num]+'_link';
            document.getElementById(linkId).name='';
            document.getElementById(linkId).href='JavaScript:void(0);';
            document.getElementById(linkId).target='';
        }


        part_num+=1;
    }

}




// ============== for star style  page=======================//

//---------------------------------loadjs------------------------------------------------------------
function locadvideotstyle(SID)
{
    document.getElementById('popupmaskloading_t').innerHTML="<img src='js/loading_big.gif'>";
    document.getElementById("popupmaskloading_t").className='popupMaskForLoading_trend';

    //alert(SID);

    var url = "starstyle_ajax.php?SID="+SID;	
    var url_track = "http://www.fashion.de/starstyle.php?SID="+SID;  


    var params = "SID="+SID;

    var htmlRecord = AjaxAgent.call(url,"","",params);


    if(document.getElementById("selectedVideo").value!="")
    {
        var selectId=document.getElementById("selectedVideo").value;
        document.getElementById("i_"+selectId).style.width="70px";
        document.getElementById("i_"+selectId).style.height="93px";
        document.getElementById("i_"+selectId).className="trendwalkborder2";

        document.getElementById("i_"+SID).style.width="70px";
        document.getElementById("i_"+SID).style.height="93px";
        document.getElementById("i_"+SID).className="trendwalkborder";
    }
    else
    {
        document.getElementById("i_"+SID).style.width="70px";
        document.getElementById("i_"+SID).style.height="93px";
        document.getElementById("i_"+SID).className="trendwalkborder";
    }
    document.getElementById("selectedVideo").value=SID;
    var htmlRecord1 = htmlRecord.split("|||");

    document.getElementById('loadcontent').innerHTML=htmlRecord1[0];
    document.getElementById('star_name').innerHTML=htmlRecord1[1];
    document.getElementById('style_check').innerHTML=htmlRecord1[2];
    document.getElementById("popupmaskloading_t").className='popupmaskloading_t_no_display';
    document.getElementById('popupmaskloading_t').innerHTML="";
    ReloadPixelImages();

    //Tracking Url
    dcsMultiTrack('DCS.dcsuri',url_track);
    /*alert(url_track);*/

}
function URLEncode(plaintext)
{
    // The Javascript escape and unescape functions do not correspond
    // with what browsers actually do...
    var SAFECHARS = "0123456789" +					// Numeric
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
    "abcdefghijklmnopqrstuvwxyz" +
    "-_.!~*'()";					// RFC2396 Mark characters
    var HEX = "0123456789ABCDEF";

    var encoded = "";
    for (var i = 0; i < plaintext.length; i++ ) {
        var ch = plaintext.charAt(i);
        if (ch == " ") {
            encoded += "+";				// x-www-urlencoded, rather than %20
        } else if (SAFECHARS.indexOf(ch) != -1) {
            encoded += ch;
        } else {
            var charCode = ch.charCodeAt(0);
            if (charCode > 255) {
                alert( "Unicode Character '" 
                + ch 
                + "' cannot be encoded using standard URL encoding.\n" +
                "(URL encoding only supports 8-bit characters.)\n" +
                "A space (+) will be substituted." );
                encoded += "+";
            } else {
                encoded += "%";
                encoded += HEX.charAt((charCode >> 4) & 0xF);
                encoded += HEX.charAt(charCode & 0xF);
            }
        }
    } // for
    return encoded;
}

function URLDecode( )
{
    // Replace + with ' '
    // Replace %xx with equivalent character
    // Put [ERROR] in output if %xx is invalid.
    var HEXCHARS = "0123456789ABCDEFabcdef"; 
    var encoded = document.URLForm.F2.value;
    var plaintext = "";
    var i = 0;
    while (i < encoded.length) {
        var ch = encoded.charAt(i);
        if (ch == "+") {
            plaintext += " ";
            i++;
        } else if (ch == "%") {
            if (i < (encoded.length-2) 
            && HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
            && HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
                plaintext += unescape( encoded.substr(i,3) );
                i += 3;
            } else {
                alert( 'Bad escape combination near ...' + encoded.substr(i) );
                plaintext += "%[ERROR]";
                i++;
            }
        } else {
            plaintext += ch;
            i++;
        }
    } // while
    document.URLForm.F1.value = plaintext;
    document.URLForm.F1.select();
    return false;
}

function sendrepondstyle()
{



    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;
                var htmlRecord1 = htmlRecord.split("|||");

                document.getElementById('loadcontent').innerHTML=htmlRecord1[0];
                document.getElementById('star_name').innerHTML=htmlRecord1[1];
                document.getElementById('style_check').innerHTML=htmlRecord1[2];
                document.getElementById("popupmaskloading_t").className='popupmaskloading_t_no_display';
                document.getElementById('popupmaskloading_t').innerHTML="";
                ReloadPixelImages();
                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function

//-------------------------------------end model--------------------------------------------------------

function showhide_style(proid)
{




    var col_array=document.getElementById("proarray").value.split(",");
    //alert( col_array.length);

    var part_num=0;
    while (part_num < col_array.length)
    {
        //alert(col_array[part_num]);

        if(proid==col_array[part_num])
        {

            var divid='p_'+proid;
            var tableid='t_'+proid;
            document.getElementById(divid).className='display_inline';
            // document.getElementById(divid).style.display='inline';
            // document.getElementById(tableid).className='trendwalkborder';
            document.getElementById(tableid).style.border='2px solid #f00000';

            var linkId=proid+'_link';
            var clickURLId=proid+'_clickURL';
            if(document.getElementById(linkId).name!='')
            {
                //window.location.href=document.getElementById(clickURLId).href;
                document.getElementById(linkId).target='_blank';
                document.getElementById(linkId).href=document.getElementById(clickURLId).href;
            }
            else
            {
                document.getElementById(linkId).name=proid;
            }  
        }
        else
        {
            var divid='p_'+col_array[part_num];
            var tableid='t_'+col_array[part_num];
            document.getElementById(divid).className='login_layer_error_dispaly_none';
            //document.getElementById(divid).style.display='none';
            // document.getElementById(tableid).className='trendwalkborder1';
            document.getElementById(tableid).style.border='2px solid white';

            var linkId=col_array[part_num]+'_link';
            document.getElementById(linkId).name='';
            document.getElementById(linkId).href='JavaScript:void(0);';
            document.getElementById(linkId).target='';
        }


        part_num+=1;
    }

}

// #########  code from js/.js   ######### //
//add marken for list
function switch_marksheet_list(product_id, price_original, product_name_original, currency) {
    var object = document.getElementById('link_'+product_id);

    if(object) {
        var img = object.firstChild;
        if(img.innerHTML.search(/Artikel von Merkzettel entfernen/) != -1) {
            // product is already in the marksheet
            var response = delete_from_cart(product_id);
            if(response) {
                //rand_flt = Math.random();
                img.innerHTML = '<font class="linkL2Rb">Artikel merken</font>'
                //img.alt = 'In den Merkzettel übernehmen';
                //img.title = img.alt;
            }
        } else {
            // product is not in the marksheet yet
            var response = add_to_cart(product_id, price_original, product_name_original, currency);
            if(response) {
                //rand_flt = Math.random();
                //img.src = 'images/merkzettel_2.gif?' + rand_flt;

                img.innerHTML = '<font class="linkL2Red">Artikel von Merkzettel entfernen</font>';

                //img.alt = 'Vom Merkzettel entfernen';
                //img.title = img.alt;
            }
        }
    } else {
    }

    //	document.getElementById("marksheet_detail").innerHTML = response;
    return;
}


// #########  Start Grid & List View Drop Down box   ######### //

function getNextView()
{
    var link = document.getElementById('view').value; 
    window.location.href= link;
}

// #########  End Grid & List View Drop Down box   ######### //


// #########  Start Product Per Page View 12,24,36 Drop Down box   ######### //

function getProductPerPage()
{
    var link = document.getElementById('product_per_page').value; 
    window.location.href= link;
}

// #########  End Product Per Page View 12,24,36 Drop Down box   ######### //
function showProductTip_Layer(proid,mode)
{
    /*
    if (!BackgroundtableBusy)
    {



    var url = "shopproductdetail.php";        
    var params = "product_id="+proid;

    BackgroundtableHttp.open("POST", url, true);

    //Send the proper header infomation along with the request
    BackgroundtableHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    BackgroundtableHttp.setRequestHeader("Content-length", params.length);

    BackgroundtableHttp.setRequestHeader("Connection", "close");

    BackgroundtableHttp.onreadystatechange = showProductTip_Layer_response;

    BackgroundtableBusy = true;
    BackgroundtableHttp.send(params);
    }
    */
    if(mode=='zoom')
    {
        dcsMultiTrack('DCS.dcsuri', '/zoom_shopproductdetail.php','WT.ti', proid);

    }
    else
    {
        dcsMultiTrack('DCS.dcsuri', '/shopproductdetail.php','WT.ti', proid);

    }


    var url = "shopproductdetail.php";
    var params = "product_id="+proid;
    var showProductDetail = AjaxAgent.call(url,"","",params);
    //return showProductDetail;
    document.getElementById('shopproductdetail').style.display='block';

    document.getElementById('shopproductdetail').innerHTML=showProductDetail;	
}

function showProductTip_Layer_response()
{
    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;
                document.getElementById('shopproductdetail').style.display='block';

                document.getElementById('shopproductdetail').innerHTML=htmlRecord;

                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function
function tt_HideInit_close()
{
    document.getElementById('shopproductdetail').style.display='none';
}



function send_to_friend_Layer(proid)
{


    var url = "send_to_friend.php";        
    var params = "product_id="+proid;

    var htmlRecord = AjaxAgent.call(url,"","",params);
    document.getElementById('shopproductdetail').style.display='block';
    document.getElementById('shopproductdetail').innerHTML=htmlRecord;

}

function send_to_friend_Layer_response()
{

    if (BackgroundtableHttp.readyState == 4)
    {
        if (BackgroundtableHttp.responseText.indexOf('invalid') == -1)
        {
            try
            {
                var htmlRecord = BackgroundtableHttp.responseText;
                document.getElementById('shopproductdetail').style.display='block';

                document.getElementById('shopproductdetail').innerHTML=htmlRecord;

                BackgroundtableBusy = false;
            } // end try 
            catch(e)
            {
                alert("Error: " + e) ;
            } // end try catch
        } // end if response index -1
    } // end if readystate 4
} // end tableresponse function


/**
 * Send to Friend CheckSendEmailField Start
 */
function CheckSendEmailField(form,mode)
{
    var yname = "Bitte geben Sie Ihren Namen an!";
    var yemail = "Das Feld Mailadresse ist leer.";
    var yemail_value = "Mailadresse ungültig.";
    var friendemails = "Bitte geben Sie mindestens eine Empfängeradresse an.";
    var tempemail_msg = "Mailadresse ungültig."; 
    var ctr=eval("document."+form);
    if(ctr.yname.value=="")
    {
        alert(yname);
        ctr.yname.focus();
        return false;
    }
    if(ctr.yemail.value=="")
    {
        alert(yemail);
        ctr.yemail.focus();
        return false;
    }
    if (EmailCheckjs(ctr.yemail.value) == false)
    {
        alert(yemail_value);
        ctr.yemail.focus();
        return false;
    }
    if(ctr.friendemails.value=="")
    {
        alert(friendemails);
        ctr.friendemails.focus();
        return false;
    }
    freinds_emails=ctr.friendemails.value;
    var col_array=freinds_emails.split(",");
    var part_num=0;
    while (part_num < col_array.length)
    {
        tempemail=Trim(col_array[part_num]);
        if (EmailCheckjs(tempemail)==false)
        {
            alert(tempemail+" "+tempemail_msg);
            ctr.friendemails.focus();
            return false;
        }
        part_num+=1;
    }
    personalmessage=URLEncode(ctr.mess.value);
    product_id=ctr.product_id.value;
    sendMailToFriends(mode,product_id,ctr.yname.value,ctr.yemail.value,freinds_emails,personalmessage);
}

function ImportFriendsEmail()
{
    var xx=document.sendlink;
    if(xx.username.value=="")
    {
        alert("Username is required.");
        xx.username.focus();
        return false;
    }
    if(xx.password.value=="")
    {
        alert("Password is required.");
        xx.password.focus();
        return false;
    }
    var spimport=xx.spimport.value;
    var username=xx.username.value;
    var password=xx.password.value;
    ImportEmails(spimport,username,password);
}

function ImportImage()
{
    document.getElementById('selectedimportimg').src="images/email"+document.sendlink.spimport.value+".gif";
}

function toggle(id)
{
    var img = 'img_' + id;
    if(document.getElementById(id).style.display == 'block') 
    {
        document.getElementById(id).style.display = 'none';
        document.getElementById(img).src = 'images/left_navigation/filter_plus.gif';
    } 
    else 
    {
        document.getElementById(id).style.display = 'block';
        document.getElementById(img).src = 'images/left_navigation/filter_minus.gif';
    }

}
function toggle(id)
{
    var img = 'img_' + id;
    if(document.getElementById(id).style.display == 'block') 
    {
        document.getElementById(id).style.display = 'none';
        document.getElementById(img).src = 'images/left_navigation/filter_plus.gif';
    } 
    else 
    {
        document.getElementById(id).style.display = 'block';
        document.getElementById(img).src = 'images/left_navigation/filter_minus.gif';
    }

}
function toggle_off(id)
{
    var img = 'img_' + id;
    if(document.getElementById(id).style.display == 'none') 
    {
        document.getElementById(id).style.display = 'block';
        document.getElementById(img).src = 'images/left_navigation/filter_minus.gif';
    } 
    else 
    {
        document.getElementById(id).style.display = 'none';
        document.getElementById(img).src = 'images/left_navigation/filter_plus.gif';
    }

}

/**
 * Send to Friend CheckSendEmailField End
 */

// #########  code from js/subModal.js   ######### //

/**
 * SUBMODAL v1.5
 * Used for displaying DHTML only popups instead of using buggy modal windows.
 *
 * By Seth Banks
 * http://www.subimage.com/
 *
 * Contributions by:
 *     Eric Angel - tab index code
 *     Scott - hiding/showing selects for IE users
 *    Todd Huss - inserting modal dynamically and anchor classes
 *
 * Up to date code can be found at http://www.subimage.com/dhtml/subModal
 * 
 *
 * This code is free for you to use anywhere, just keep this comment block.
 */

// Popup code
var gPopupMask = null;
var gPopupContainer = null;
var gPopFrame = null;
var gReturnFunc;
var gPopupIsShown = false;
var gDefaultPage = "loading.html";
var gHideSelects = true;
var gReturnVal = null;

var gTabIndexes = new Array();
// Pre-defined list of tags we want to disable/enable tabbing into
var gTabbableTags = new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");    

// If using Mozilla or Firefox, use Tab-key trap.
if (!document.all) {
    document.onkeypress = keyDownHandler;
}

/**
 * Initializes popup code on load.    
 */
function initPopUp() {
    // Add the HTML to the body
    theBody = document.getElementsByTagName('BODY')[0];
    popmask = document.createElement('div');
    popmask.id = 'popupMask';
    popcont = document.createElement('div');
    popcont.id = 'popupContainer';
    popcont.innerHTML = '' +
    '<div id="popupInner">' +
    '<div id="popupTitleBar">' +
    '<div id="popupTitle"></div>' +
    '<div id="popupControls">' +
    '<img src="images/close_submodal.gif" onclick="hidePopWin(false);" id="popCloseBox" />' +
    '</div>' +
    '</div>' +
    '<iframe src="'+ gDefaultPage +'" style="width:100%;height:100%;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe>' +
    '</div>';
    theBody.appendChild(popmask);
    theBody.appendChild(popcont);

    gPopupMask = document.getElementById("popupMask");
    gPopupContainer = document.getElementById("popupContainer");
    gPopFrame = document.getElementById("popupFrame");    

    // check to see if this is IE version 6 or lower. hide select boxes if so
    // maybe they'll fix this in version 7?
    var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
    if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
        gHideSelects = true;
    }

    // Add onclick handlers to 'a' elements of class submodal or submodal-width-height
    var elms = document.getElementsByTagName('a');
    for (i = 0; i < elms.length; i++) {
        if (elms[i].className.indexOf("submodal") == 0) { 
            // var onclick = 'function (){showPopWin(\''+elms[i].href+'\','+width+', '+height+', null);return false;};';
            // elms[i].onclick = eval(onclick);
            elms[i].onclick = function(){
                // default width and height
                var width = 400;
                var height = 200;
                // Parse out optional width and height from className
                params = this.className.split('-');
                if (params.length == 3) {
                    width = parseInt(params[1]);
                    height = parseInt(params[2]);
                }
                showPopWin(this.href,width,height,null); return false;
            }
        }
    }
}
addEvent(window, "load", initPopUp);

/**
 * @argument width - int in pixels
 * @argument height - int in pixels
 * @argument url - url to display
 * @argument returnFunc - function to call when returning true from the window.
 * @argument showCloseBox - show the close box - default true
 */

function showPopWin(url, width, height, returnFunc, showCloseBox) {
    // show or hide the window close widget
    if (showCloseBox == null || showCloseBox == true) {
        document.getElementById("popCloseBox").style.display = "none";
    } else {
        document.getElementById("popCloseBox").style.display = "none";
    }
    gPopupIsShown = true;
    disableTabIndexes();
    gPopupMask.style.display = "block";
    gPopupContainer.style.display = "block";
    // calculate where to place the window on screen
    centerPopWin(width, height);

    var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);

    gPopupContainer.style.width = width + "px";
    gPopupContainer.style.height = (height+titleBarHeight) + "px";

    setMaskSize();

    // need to set the width of the iframe to the title bar width because of the dropshadow
    // some oddness was occuring and causing the frame to poke outside the border in IE6
    gPopFrame.style.width = parseInt(document.getElementById("popupTitleBar").offsetWidth, 10) + "px";
    gPopFrame.style.height = (height) + "px";

    // set the url
    gPopFrame.src = url;

    gReturnFunc = returnFunc;
    // for IE
    if (gHideSelects == true) {
        hideSelectBoxes();
    }

    window.setTimeout("setPopTitle();", 600);


}

//
var gi = 0;
function centerPopWin(width, height) {
    if (gPopupIsShown == true) {
        if (width == null || isNaN(width)) {
            width = gPopupContainer.offsetWidth;
        }
        if (height == null) {
            height = gPopupContainer.offsetHeight;
        }

        //var theBody = document.documentElement;
        var theBody = document.getElementsByTagName("BODY")[0];
        //theBody.style.overflow = "hidden";
        var scTop = parseInt(getScrollTop(),10);
        var scLeft = parseInt(theBody.scrollLeft,10);

        setMaskSize();

        //window.status = gPopupMask.style.top + " " + gPopupMask.style.left + " " + gi++;

        var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);

        var fullHeight = getViewportHeight();
        var fullWidth = getViewportWidth();

        gPopupContainer.style.top = (scTop + ((fullHeight - (height+titleBarHeight)) / 2)) + "px";
        gPopupContainer.style.left =  (scLeft + ((fullWidth - width) / 2)) + "px";
        //alert(fullWidth + " " + width + " " + gPopupContainer.style.left);
    }
}
addEvent(window, "resize", centerPopWin);
addEvent(window, "scroll", centerPopWin);
window.onscroll = centerPopWin;


/**
 * Sets the size of the popup mask.
 *
 */
function setMaskSize() {
    var theBody = document.getElementsByTagName("BODY")[0];

    var fullHeight = getViewportHeight();
    var fullWidth = getViewportWidth();

    // Determine what's bigger, scrollHeight or fullHeight / width
    if (fullHeight > theBody.scrollHeight) {
        popHeight = fullHeight;
    } else {
        popHeight = theBody.scrollHeight;
    }

    if (fullWidth > theBody.scrollWidth) {
        popWidth = fullWidth;
    } else {
        popWidth = theBody.scrollWidth;
    }

    gPopupMask.style.height = popHeight + "px";
    gPopupMask.style.width = popWidth + "px";
}

/**
 * @argument callReturnFunc - bool - determines if we call the return function specified
 * @argument returnVal - anything - return value 
 */
function hidePopWin(callReturnFunc) {
    gPopupIsShown = false;
    var theBody = document.getElementsByTagName("BODY")[0];
    theBody.style.overflow = "";
    restoreTabIndexes();
    if (gPopupMask == null) {
        return;
    }
    gPopupMask.style.display = "none";
    gPopupContainer.style.display = "none";
    if (callReturnFunc == true && gReturnFunc != null) {
        // Set the return code to run in a timeout.
        // Was having issues using with an Ajax.Request();
        gReturnVal = window.frames["popupFrame"].returnVal;
        window.setTimeout('gReturnFunc(gReturnVal);', 1);
    }
    gPopFrame.src = gDefaultPage;
    // display all select boxes
    if (gHideSelects == true) {
        displaySelectBoxes();
    }
}

/**
 * Sets the popup title based on the title of the html document it contains.
 * Uses a timeout to keep checking until the title is valid.
 */
function setPopTitle() {
    return;
    if (window.frames["popupFrame"].document.title == null) {
        window.setTimeout("setPopTitle();", 10);
    } else {
        document.getElementById("popupTitle").innerHTML = window.frames["popupFrame"].document.title;
    }
}

// Tab key trap. iff popup is shown and key was [TAB], suppress it.
// @argument e - event - keyboard event that caused this function to be called.
function keyDownHandler(e) {
    if (gPopupIsShown && e.keyCode == 9)  return false;
}

// For IE.  Go through predefined tags and disable tabbing into them.
function disableTabIndexes() {
    if (document.all) {
        var i = 0;
        for (var j = 0; j < gTabbableTags.length; j++) {
            var tagElements = document.getElementsByTagName(gTabbableTags[j]);
            for (var k = 0 ; k < tagElements.length; k++) {
                gTabIndexes[i] = tagElements[k].tabIndex;
                tagElements[k].tabIndex="-1";
                i++;
            }
        }
    }
}

// For IE. Restore tab-indexes.
function restoreTabIndexes() {
    if (document.all) {
        var i = 0;
        for (var j = 0; j < gTabbableTags.length; j++) {
            var tagElements = document.getElementsByTagName(gTabbableTags[j]);
            for (var k = 0 ; k < tagElements.length; k++) {
                tagElements[k].tabIndex = gTabIndexes[i];
                tagElements[k].tabEnabled = true;
                i++;
            }
        }
    }
}


/**
 * Hides all drop down form select boxes on the screen so they do not appear above the mask layer.
 * IE has a problem with wanted select form tags to always be the topmost z-index or layer
 *
 * Thanks for the code Scott!
 */
function hideSelectBoxes() {
    for(var i = 0; i < document.forms.length; i++) {
        for(var e = 0; e < document.forms[i].length; e++){
            if(document.forms[i].elements[e].tagName == "SELECT") {
                document.forms[i].elements[e].style.visibility="hidden";
            }
        }
    }
}

/**
 * Makes all drop down form select boxes on the screen visible so they do not reappear after the dialog is closed.
 * IE has a problem with wanted select form tags to always be the topmost z-index or layer
 */
function displaySelectBoxes() {
    for(var i = 0; i < document.forms.length; i++) {
        for(var e = 0; e < document.forms[i].length; e++){
            if(document.forms[i].elements[e].tagName == "SELECT") {
                document.forms[i].elements[e].style.visibility="visible";
            }
        }
    }
}

function showPopWin2(url, width, height, returnFunc, showCloseBox) {
    // show or hide the window close widget
    if (showCloseBox == null || showCloseBox == true) {
        document.getElementById("popCloseBox").style.display = "block";
    } else {
        document.getElementById("popCloseBox").style.display = "none";
    }
    gPopupIsShown = true;
    disableTabIndexes();
    gPopupMask.style.display = "block";

    gPopupMask.onclick = function(){
        // default width and height
        window.parent.location='myprofile.php';
    }


    gPopupContainer.style.display = "block";
    // calculate where to place the window on screen
    centerPopWin(width, height);

    var titleBarHeight = "0";


    gPopupContainer.style.display = "none";

    setMaskSize();

    // need to set the width of the iframe to the title bar width because of the dropshadow
    // some oddness was occuring and causing the frame to poke outside the border in IE6
    gPopFrame.style.display = "none";

    gReturnFunc = returnFunc;
    // for IE
    if (gHideSelects == true) {
        hideSelectBoxes();
    }

    window.setTimeout("setPopTitle();", 600);
}

// ######### code from assets/dropdowntabs.js   ######### //

//Drop Down Tabs Menu- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Created: May 16th, 07'

var tabdropdown={
    disappeardelay: 00, //set delay in miliseconds before menu disappears onmouseout
    disablemenuclick: false, //when user clicks on a menu item with a drop down menu, disable menu item's link?
    enableiframeshim: 1, //1 or 0, for true or false

    //No need to edit beyond here////////////////////////
    dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, previousmenuitem:null,
    currentpageurl: window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, ""), //get current page url (minus hostname, ie: http://www.dynamicdrive.com/)

    getposOffset:function(what, offsettype){
        var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
        var parentEl=what.offsetParent;
        while (parentEl!=null){
            totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
            parentEl=parentEl.offsetParent;
        }
        return totaloffset;
    },

    showhide:function(obj, e, obj2){ //obj refers to drop down menu, obj2 refers to tab menu item mouse is currently over
        if (this.ie || this.firefox)
        this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
        if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
            if (obj2.parentNode.className.indexOf("default")==-1) //if tab isn't a default selected one
            obj2.parentNode.className="selected"
            obj.visibility="visible"
        }
        else if (e.type=="click")
        obj.visibility="hidden"
    },

    iecompattest:function(){
        return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    },

    clearbrowseredge:function(obj, whichedge){
        var edgeoffset=0
        if (whichedge=="rightedge"){
            //var windowedge=this.ie && !window.opera? this.standardbody.scrollLeft+this.standardbody.clientWidth-15 : window.pageXOffset+window.innerWidth-15
            var windowedge=1024;
            this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
            if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
            edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
        }
        else{
            var topedge=this.ie && !window.opera? this.standardbody.scrollTop : window.pageYOffset
            var windowedge=this.ie && !window.opera? this.standardbody.scrollTop+this.standardbody.clientHeight-15 : window.pageYOffset+window.innerHeight-18
            this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
            if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
                edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
                if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
                edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
            }
            this.dropmenuobj.firstlink.style.borderTopWidth=(edgeoffset==0)? 0 : "1px" //Add 1px top border to menu if dropping up
        }
        return edgeoffset
    },

    dropit:function(obj, e, dropmenuID){
        if (this.dropmenuobj!=null){ //hide previous menu
            this.dropmenuobj.style.visibility="hidden" //hide menu
            if (this.previousmenuitem!=null && this.previousmenuitem!=obj){
                if (this.previousmenuitem.parentNode.className.indexOf("default")==-1) //If the tab isn't a default selected one
                this.previousmenuitem.parentNode.className=""
            }
        }
        this.clearhidemenu()
        if (this.ie||this.firefox){
            obj.onmouseout=function(){tabdropdown.delayhidemenu(obj)}
            obj.onclick=function(){return !tabdropdown.disablemenuclick} //disable main menu item link onclick?
            this.dropmenuobj=document.getElementById(dropmenuID)
            this.dropmenuobj.onmouseover=function(){tabdropdown.clearhidemenu()}
            this.dropmenuobj.onmouseout=function(e){tabdropdown.dynamichide(e, obj)}
            this.dropmenuobj.onclick=function(){tabdropdown.delayhidemenu(obj)}
            this.showhide(this.dropmenuobj.style, e, obj)
            this.dropmenuobj.x=this.getposOffset(obj, "left")
            this.dropmenuobj.y=this.getposOffset(obj, "top")
            this.dropmenuobj.style.left="200px"

            //this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"

            this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+0+"px"
            this.previousmenuitem=obj //remember main menu item mouse moved out from (and into current menu item)
            this.positionshim() //call iframe shim function
        }

    },

    contains_firefox:function(a, b) {
        if(b != null)
        {
            while (b.parentNode)
            if ((b = b.parentNode) == a)
            return true;
        }    
        return false;
    },

    dynamichide:function(e, obj2){ //obj2 refers to tab menu item mouse is currently over
        var evtobj=window.event? window.event : e
        if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
        this.delayhidemenu(obj2)
        else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
        this.delayhidemenu(obj2)
    },

    delayhidemenu:function(obj2){
        this.delayhide=setTimeout(function(){tabdropdown.dropmenuobj.style.visibility='hidden'; if (obj2.parentNode.className.indexOf('default')==-1) obj2.parentNode.className=''},this.disappeardelay) //hide menu
    },

    clearhidemenu:function(){
        if (this.delayhide!="undefined")
        clearTimeout(this.delayhide)
    },

    positionshim:function(){ //display iframe shim function
        if (this.enableiframeshim && typeof this.shimobject!="undefined"){
            if (this.dropmenuobj.style.visibility=="visible"){
                this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
                this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"
                this.shimobject.style.left=this.dropmenuobj.style.left
                this.shimobject.style.top=this.dropmenuobj.style.top
            }
            this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"
        }
    },

    hideshim:function(){
        if (this.enableiframeshim && typeof this.shimobject!="undefined")
        this.shimobject.style.display='none'
    },

    isSelected:function(menuurl){
        var menuurl=menuurl.replace("http://"+menuurl.hostname, "").replace(/^\//, "")
        return (tabdropdown.currentpageurl==menuurl)
    },

    init:function(menuid, dselected){
        this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
        var menuitems=document.getElementById(menuid).getElementsByTagName("td")
        //                    menuitems[i].style.backgroundColor="#DD4814";
        for (var i=0; i<menuitems.length; i++){
            if (menuitems[i].getAttribute("rel")){
                var relvalue=menuitems[i].getAttribute("rel")

                document.getElementById(relvalue).firstlink=document.getElementById(relvalue).getElementsByTagName("td")[0];

                menuitems[i].onmouseover=function(e){
                    var event=typeof e!="undefined"? e : window.event
                    tabdropdown.dropit(this, event, this.getAttribute("rel"))
                }
            }
            if (dselected=="auto" && typeof setalready=="undefined" && this.isSelected(menuitems[i].href)){
                menuitems[i].parentNode.className+=" selected default"
                var setalready=true
            }
            else if (parseInt(dselected)==i)
            menuitems[i].parentNode.className+=" selected default"
        }
    }

}

function newImage(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
    }
}

function changeImages() {
    if (document.images && (preloadFlag == true)) {
        for (var i=0; i<changeImages.arguments.length; i+=2) {
            document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
        }
    }
}

var preloadFlag = false;
function preloadImages() {
    if (document.images) {
        but_01_over = newImage("images/but_01-over.gif");
        but_01_but_02_over = newImage("images/but_01-but_02_over.gif");
        but_02_but_01_over = newImage("images/but_02-but_01_over.gif");
        but_02_over = newImage("images/but_02-over.gif");
        but_02_but_03_over = newImage("images/but_02-but_03_over.gif");
        but_03_but_02_over = newImage("images/but_03-but_02_over.gif");
        but_03_over = newImage("images/but_03-over.gif");
        preloadFlag = true;
    }
}

/* Open product_url.php in different position */
function oeffnefenster (url,toolbar,addressbar,statusbar) 
{
    fenster = window.open(url, "fenster1", "status="+statusbar+", toolbar="+toolbar+", location="+addressbar+",scrollbars=yes,resizable=yes,left=210,top=200");

    fenster.focus();
}
/* BEGIN : facebook,tweeter calling & tracking function */
function fbs_click(url,title,source,site_url,loc,pid) {
    //alert(url);
    //alert(title);
    //alert(source);
    //var tracking_url = site_url+loc+'/'+source+'/'+pid;
    var tracking_url = '/'+loc+'/'+source+'/'+pid+'/';
    //alert(tracking_url);
    if(source=="Facebook")
    {
        window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&t='+encodeURIComponent(title),'sharer','toolbar=0,status=0,width=626,height=436');
    }
    else
    {
        if(source=="Twitter")
        {
            window.open('http://twitter.com/home?status='+title+' '+url,'sharer','toolbar=0,status=0,width=626,height=436');

        }
    }
    dcsMultiTrack('DCS.dcsuri',tracking_url);
    return false;
}

/* END :  facebook,tweeter calling & tracking function */


//######  Login Form Validation Start  ######//  
function validate() {
    if(tfv.exec()) {

        //do the login
        var email = document.getElementById("loginemail").value;
        var password = document.getElementById("password").value;
        var rememberme_checked = document.getElementById("rememberme").checked;

        if(rememberme_checked == false)
        {
            var rememberme = "no";
        } else {
            var rememberme = "yes";
        }

        var url = "process.php";
        var params = "mode=checkLogin&email="+email+"&password="+password+"&rememberme="+rememberme;
        var response = AjaxAgent.call(url,"","",params);

        //alert(invalid_password_error);

        //alert(invalid_email_error);
        //alert(response);

        if(response == "invalid") {
            document.getElementById("error").style.display = "block";
            document.getElementById("error11").style.display = "block";
            document.getElementById("error22").style.display = "block";
            document.getElementById("error").innerHTML = invalid_login_error;
            //document.getElementById("error22").innerHTML = invalid_password_error;
            document.getElementById("error11").innerHTML =invalid_email_error;

        } else if(response == "invalid_password") {
            document.getElementById("error").style.display = "block";
            document.getElementById("error22").style.display = "block";
            document.getElementById("error11").style.display = "none";
            document.getElementById("error").innerHTML = invalid_login_error;
            document.getElementById("error22").innerHTML = invalid_password_error;
        }else if(response == "invalid_email") {
            document.getElementById("error").style.display = "block";
            document.getElementById("error11").style.display = "block";
            document.getElementById("error22").style.display = "none";
            document.getElementById("error").innerHTML = invalid_login_error;
            document.getElementById("error11").innerHTML =invalid_email_error;
        }else if(response == "not_activated") {
            document.getElementById("error").style.display = "block";
            document.getElementById("error").innerHTML = account_not_activated;
        } else {
            //window.location.href='{/literal}{sitefunction name="GetFooterContentURL" str="marksheet" orig="marksheet.php"}{literal}';
            window.location.href='/marksheet.php';
        }

    } else {
        return;
    }
}

//######  Login Form Validation End  ######//  


//######  User Login Form Signup Validation Start  ######//  
function validate_signup() {
    if(tfv_signup.exec()) {

        //do the signup
        var email_signup_marksheet = document.getElementById("email_signup_marksheet").value;
        var password_signup_marksheet = document.getElementById("password_signup_marksheet").value;
        var newsletter_signup_marksheet_chk = document.getElementById("newsletter_signup_marksheet");

        if(newsletter_signup_marksheet_chk.checked==true){
            var newsletter_signup_marksheet = "yes";
        }else{
            var newsletter_signup_marksheet = "no";
        }

        var url = "process.php";
        var params = "mode=signup&email="+email_signup_marksheet+"&password="+password_signup_marksheet+"&newsletter="+newsletter_signup_marksheet;

        var response = AjaxAgent.call(url,"","",params);

        if(response == "invalid") {
            document.getElementById("error_signup").style.display = "block";
            document.getElementById("error_signup").innerHTML = "User Already Exist";
        } else {

            //reload the marksheet_detail
            //var url = "process.php";
            //var params = "mode=reloadMarksheetDetail";
            //var reload_marksheetdetail = AjaxAgent.call(url,"","",params);
            //window.parent.document.getElementById("marksheet_detail").innerHTML = reload_marksheetdetail;

            window.location.href='marksheet.php';


        }

    } else {
        return;
    }
}

//######  User Login Form Signup Validation End  ######//  


//######  validate_marksheet Form Validation Start  ######//  

function validate_marksheet() {
    if(tfv_marksheet.exec()) {

        //do the login
        var email_marksheet = document.getElementById("email_marksheet").value;
        var password_marksheet = document.getElementById("password_marksheet").value;
        var rememberme_marksheet_checked = document.getElementById("rememberme_marksheet").checked;

        if(rememberme_marksheet_checked == false)
        {
            var rememberme_marksheet = "no";
        } else {
            var rememberme_marksheet = "yes";
        }


        var url = "process.php";
        var params = "mode=checkLogin&email="+email_marksheet+"&password="+password_marksheet+"&rememberme="+rememberme_marksheet;
        var response = AjaxAgent.call(url,"","",params);

        if(response == "invalid") {
            document.getElementById("error_user_login").style.display = "block";
            document.getElementById("error_user_login").innerHTML = invalid_login_error;
        } else if(response == "not_activated") {
            document.getElementById("error_user_login").style.display = "block";
            document.getElementById("error_user_login").innerHTML = account_not_activated;
        } else {

            //reload the marksheet_detail
            //var url = "process.php";
            //var params = "mode=reloadMarksheetDetail";
            //var reload_marksheetdetail = AjaxAgent.call(url,"","",params);
            //document.getElementById("marksheet_detail").innerHTML = reload_marksheetdetail;

            window.location.href='marksheet.php';

        }

    } else {
        return;
    }
}

//######  validate_marksheet Form Validation End  ######//  

//######  showProductTip For Marksheet Validation Start  ######//  

function showProductTip(productid){
    dcsMultiTrack('DCS.dcsuri', '/shopproductdetail/'+productid,'WT.ti', productid);
    var url = "process.php";
    var params = "mode=showproductdetailframe&smode=marksheet&product_id="+productid;
    var showProductDetail = AjaxAgent.call(url,"","",params);
    return showProductDetail;
}

//######  showProductTip For Marksheet Validation End  ######//  