﻿$ektron(document).ready(function () {
    $ektron("#row2").children("div").reverseOrder(); //flip bottom row default.aspx
    $ektron("#solution_main").children("div").reverseOrder(); //flip solution.aspx
    $ektron("#topTools").children("div").reverseOrder(); // all pages
    $ektron("#ctl00_main_cbProfile").children("div").reverseOrder(); //flip profile.aspx
    $ektron(".arabic .sungardContentContainer").children("div:not(.sitemap)").reverseOrder(); //flip news.aspx
    $ektron(".arabic .sungardFilterNav ul").children("li").reverseOrder(); //flip filter listings example casestudies.aspx
    $ektron(".arabic .search table td").children("input").reverseOrder();
    $ektron(".arabic .breadCrumb span").children().reverseOrder();
    $ektron(".arabic .megaNav li:eq(1), .arabic .tabs li:eq(0)").remove();

    /*begin breadcrumb fix*/
    function reverseBread() {
        Array.prototype.clean = function (deleteValue) {
            for (var i = 0; i < this.length; i++) {
                if (this[i] == deleteValue) {
                    this.splice(i, 1);
                    i--;
                }
            }
            return this;
        };
        var strbreadCrumbMarkUp = $(".breadCrumb span").html();
        var arrayCrumb = new Array();
        arrayCrumb = strbreadCrumbMarkUp.split("››").reverse();
        arrayCrumb = arrayCrumb.clean(" ");
        if (arrayCrumb.length < 2) {
            $(".breadCrumb").html(arrayCrumb.join().replace(",", ""));
        }
        else {
            $(".breadCrumb").html(arrayCrumb.join().replace(",", " &lsaquo;&lsaquo; "));
        }
    }
    /*end breadcrumb fix*/
    reverseBread(); //flips the order of bread crumbs for arabic language.




/** This part replaces the jcarousel functionality with scrollable **/

	var imgLink = new Array();
	var imgSrc = new Array();
	var imgAlt = new Array();
	var imgCount = $('ul#help-you-jcarousel > li').length;
	var i = 0;
	
	$('ul#help-you-jcarousel').find('li').each(function() {
		imgLink[i] = $(this).find('a').attr('href');
		imgSrc[i] = $(this).find('img').attr('src');
		imgAlt[i] = $(this).find('img').attr('alt');
		i++;
	});
	
	var htmlReplace = '<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/scrollableStyles.css\" />';
	htmlReplace = htmlReplace + '<script type=\"text/javascript\" src=\"/js/jquery.tools.min.js\" ></script>';
	htmlReplace = htmlReplace + '<script type=\"text/javascript\" src=\"/js/scrollableScript.js\" ></script>';
	htmlReplace = htmlReplace + '<div class=\"picscrollarea\">';
	htmlReplace = htmlReplace + '<a class=\"prev browse left\"></a>';
	htmlReplace = htmlReplace + '<div class=\"scrollable\">';
	htmlReplace = htmlReplace + '<div class=\"items\">';
	for (i=0; i<imgCount; i++) {
		htmlReplace = htmlReplace + '<div class=\"picsClass\"><a href=\"' + imgLink[i] + '"><img height=\"120\" width=\"195\" alt=\"' + imgAlt[i] + '\" src=\"' + imgSrc[i] + '\" /></a></div>';
	}
	htmlReplace = htmlReplace + '</div>';
	htmlReplace = htmlReplace + '</div>';
	htmlReplace = htmlReplace + '<a class=\"next browse right\"></a>';
	htmlReplace = htmlReplace + '</div>';
	
	$('div.carousel').html(htmlReplace);

});
