var screenPath = "";
//var scale = 1;
var scaleBlockCategories = 1;
var scaleCaptcha = 1;
var scaleCaptchaVendor = 1;
var scaleCaptchaAffiliate = 1;
var scaleCaptchaContact_us = 1;
var scaleBlockCategoriesPosX = 1;
var scaleBlockCategoriesPosY = 1;

var scale_c = 0;
function scaleContent() {
    return 0;
    var styleFile = "style_xxx.css";
    if (screen.width < 1600 && screen.height < 800) {
        styleFile = "style_1024x768.css";
        screenPath = "/1024x768";

        scaleBlockCategories = 1;
        scaleBlockCategoriesPosX = 0.6;
        scaleBlockCategoriesPosY = 1;
        scaleCaptcha = 0.35;
        scaleCaptchaVendor = 0.42;
        scaleCaptchaAffiliate = 0.45;
        scaleCaptchaContact_us = 0.47;
        scale_c = 0.2;
    } else if (screen.width < 1900 && screen.height < 1000) {
        styleFile = "style_1600x900.css";
        screenPath = "/1600x900";
        scaleBlockCategories = 1;
        scaleBlockCategoriesPosX = 2.5;
        scaleBlockCategoriesPosY = 1.5;

        scaleCaptcha = 0.57;
        scaleCaptchaVendor = 0.65;
        scaleCaptchaAffiliate = 0.75;
        scaleCaptchaContact_us = 0.9;
        scale_c = 0.1;
    }

    jQuery('img').each(function(){
        if (this.src.indexOf('google.com') == -1 && this.src.indexOf('/leads/upload/images/') == -1 && this.src.indexOf('/leads/upload/advertise/images/') == -1)
             this.src = this.src.substr(0,this.src.lastIndexOf('/'))+screenPath+this.src.substr(this.src.lastIndexOf('/'));    
    });

    var headID = document.getElementsByTagName("head")[0];
    var cssNode = document.createElement('link');

    cssNode.type = 'text/css';
    cssNode.rel = 'stylesheet';
    cssNode.href = 'assets/components/call/'+styleFile;
    cssNode.media = 'screen';
    headID.appendChild(cssNode);

}

function resizeRecaptcha(type) {
    return 0;
   // alert(type);
    if (typeof(type) == "undefined") {
        type = '';
    }

    var scale = scaleCaptcha;
    switch(type) {
        case 'vendor':
                scale = scaleCaptchaVendor;
        break;

        case 'affiliate':
                scale = scaleCaptchaAffiliate;
        break;
        
        case 'contact_us':
                scale = scaleCaptchaContact_us;
        break;
    }
    if (scale == 1) return;
    if (jQuery('#recaptcha_widget_div').attr('resize') == '1') return;
    jQuery('#recaptcha_widget_div').attr('resize', '1');

    jQuery('#recaptcha_widget_div').children().each(function() {        
        if (this.id !='recaptcha_response_field') { 
            jQuery(this).height(jQuery(this).height()*scale);
        }

        if (type =='vendor' || type =='affiliate')
            jQuery(this).width(jQuery(this).width()*(scale + scale_c));
        else
            jQuery(this).width(jQuery(this).width()*scale);

        if (jQuery(this).children().length) {
            scalingChildren(this, scale);
        }
    });
}

function scalingChildren(parrent, scale) {
    return 0;
    jQuery(parrent).children().each(function() {
        if (this.id !='recaptcha_response_field')
            jQuery(this).height(jQuery(this).height()*scale);

        jQuery(this).width(jQuery(this).width()*scale);

        if (jQuery(this).children().length) {
            scalingChildren(this, scale);
        }
    });
}
var logo = 0;
function LogoChanche() {
    return 0;
    var countLogo = 4;
    logo++;
    if (logo>countLogo) {
       logo=1; 
    }
    setLogo(logo, false);
//    jQuery('.logoimg').removeClass('logo-active');
//    jQuery('#logo-'+logo).addClass('logo-active');
}

var logoInterval = setInterval(LogoChanche, 10000);

function setPagePerson(step) {
    return 0;
    
    jQuery('.person_bg img').attr('src', jQuery('.person_bg img').attr('src').substr(0, jQuery('.person_bg img').attr('src').lastIndexOf('/')) + '/person_bg_step_' + step  + '.jpg');
}

function setLogo(id, clear) {
    if (clear != false)
        clearInterval(logoInterval);
    jQuery('.logoimg').removeClass('logo-active');
    jQuery('#logo-'+id).addClass('logo-active');

    jQuery('.site-nav').removeClass('blue_logo');
    jQuery('.site-nav').removeClass('orange_logo');
    jQuery('.site-nav').removeClass('green_logo');
    jQuery('.site-nav').removeClass('yellow_logo');

    var hoverClass = "";

    switch(id) {
        case 1:
                hoverClass = 'blue_logo';
        break;
        case 2:
                hoverClass = 'orange_logo';
        break;
        case 3:
                hoverClass = 'green_logo';
        break;
        case 4:
                hoverClass = 'yellow_logo';
        break;
    }
    
    jQuery('.site-nav').addClass(hoverClass);
}

function repositionBlocksCategories(selectorCls, wrapper, column) {
    return 0;
    var col = 0;
    var top = new Array(10,10,10,10);
    var r_padding = 0;
    var t_padding = 10*scaleBlockCategoriesPosY;

    jQuery('.' + selectorCls).each(function (i) {

        if (col == column) {
                col = 0;
                r_padding = 0;
               // t_padding += 10;
        }

        jQuery(this).css('left', col*jQuery(this).width() + r_padding);
        
        jQuery(this).css('top', top[col]);
        top[col] = top[col] + jQuery(this).height() + t_padding;
       //debugger;
        r_padding += 5*scaleBlockCategoriesPosX;

        col++;
    });
    var max = top[0];

    for (var i = 0; i < col; i++) {
        if (max < top[i]) {
            max = top[i];
        }
    }

    jQuery('.' + wrapper).height(max)
}
