// JavaScript 
var imageNumber = 1;
var flagged = false;
function imageLeft(){
    if(imageNumber != 1){
        $('image' + imageNumber).hide();
        $('navNumber' + imageNumber).setStyle({
            color: '#42607a'
        });
        imageNumber--;
        $('image' + imageNumber).show();
        $('navNumber' + imageNumber).setStyle({
            color: '#e65a1d'
        });
        if (imagesQuantity > 10) {
            if (imageNumber < 11) {
                $('group2').hide();
                $('group1').show();
            }
            else {
                $('group2').hide();
                $('group1').show();
            }
        }
    }
}
function imageRight(){
    if(imageNumber<imagesQuantity){
        $('image' + imageNumber).hide();
        $('navNumber' + imageNumber).setStyle({
            color: '#42607a'
        });
        imageNumber++;
        $('image' + imageNumber).show();
        $('navNumber' + imageNumber).setStyle({
            color: '#e65a1d'
        });
        if (imagesQuantity > 10) {
            if (imageNumber < 11) {
                $('group2').hide();
                $('group1').show();
            }
            else {
                $('group2').hide();
                $('group1').show();
            }
        }
    }
} 
function callByNumber(number){
    $('image' + imageNumber).hide();
    $('navNumber' + imageNumber).setStyle({
        color: '#42607a'
    });
    imageNumber = number;
    $('image' + imageNumber).show();
    $('navNumber' + imageNumber).setStyle({
        color: '#e65a1d'
    });
} 
function imageReplace(num){
    for(var i=1; i<=5; i++){
        if(i<=num)
            $("rate"+i).src="public/images/design/product_detailpage_10.jpg";
        else
            $("rate"+i).src="public/images/design/product_detailpage_12.jpg";
    }
}
function imageRestore(num){		
    for(var i=1; i<=5; i++){
        if(i<=num)
            $("rate"+i).src="public/images/design/product_detailpage_10.jpg";
        else
            $("rate"+i).src="public/images/design/product_detailpage_12.jpg";
    }
}
function vimageReplace(num){
    for(var i=1; i<=5; i++){
        if(i<=num)
            $("vrate"+i).src="public/images/design/product_detailpage_10.jpg";
        else
            $("vrate"+i).src="public/images/design/product_detailpage_12.jpg";
    }
}
function vimageRestore(num){
    for(var i=1; i<=5; i++){
        if(i<=num)
            document.getElementById("vrate"+i).src="public/images/design/product_detailpage_10.jpg";
        else
            document.getElementById("vrate"+i).src="public/images/design/product_detailpage_12.jpg";
    }
}

function emailVideo(productId){		
    var url = baseUrl + '/product/email/productId/' + productId;
    window.open(url,'Welcome','width=500,height=250,menubar=no,status=no,location=no,toolbar=no,scrollbars=no');
}
function productComment(productId){		
    var url = baseUrl + '/product/comment/productId/' + productId;
    window.open(url,'Welcome','width=500,height=250,menubar=no,status=no,location=no,toolbar=no,scrollbars=no');
}
function flag(productId){
    if(!flagged){
        document.body.style.cursor = 'wait';
        var url = baseUrl + '/product/flag/productId/' + productId;
        new Ajax.Request(url,{
            method: 'get',
            onSuccess: function(transport){
                alert('The site administrator has been notified. Thank You for your assistance.');
                document.body.style.cursor = 'default';
                flagged = true;
            }
        });
    }
}
function rate(productId, rating, type){
    document.body.style.cursor = 'wait';
    var url = baseUrl + '/product/rate/productId/' + productId + '/rating/' + rating + '/type/' + type ;
    new Ajax.Request(url,{
        method: 'get',
        onSuccess: function(transport){
            alert(transport.responseText);
            document.body.style.cursor = 'default';
        }
    });
}
function favorite(productId){
    document.body.style.cursor = 'wait';
    var url = baseUrl + '/product/favorite/productId/' + productId;
    new Ajax.Request(url,{
        method: 'get',
        onSuccess: function(transport){
            alert(transport.responseText);
            document.body.style.cursor = 'default';
        }
    });
}
function registerGoToStore(productId){
    var url = baseUrl + '/product/registerbuynowclick/productId/' + productId;
    new Ajax.Request(url,{
        method: 'get'
    });
}

function flashButtonClick(action){
    pageTracker._trackEvent('Player Button', action, productName);
}

function productBounce(){
    var confirmation = confirm('You do not have credentials entered for this affiliate network. Would you like to go to your control panel to enter these credentials?');
    if(confirmation){
        var url = baseUrl + '/seller/interface/page/embedable';
        window.location = url;
    }
}