//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- BEGN AJAX PAGINATION MADDNESS! -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"skins/Skin_2/ajaxpagination.css\" />");

//Ajax Pagination Script- Author: Dynamic Drive (http://www.dynamicdrive.com)
//** Created Sept 14th, 07'
//** Updated Oct 31st, 07'- Fixed bug when book only contains 1 page
//** Updated Aug 9th 08'- Upgraded to v1.2:
			//1) Adds ability to limit the range of the visible pagination links shown for a book with many pages
			//2) Adds Session only persistence to persist the last page user viewed when navigating away then returning to the webpage containing the script.
			//3) Modified Ajax request function in IE7 to use ActiveXObject object, so script can be tested offline
//** Updated Aug 29th 08'- MANUAL OVERRIDE FOR SHIEKH VIA REZ (RIPPED APART!!!)
			//1) Orient Yourself Objectionaly, and seek the light!
			//2) Last mods made: 9/3/2008
//** Updated May 25th 09' - Reset Initial Page to 0 when gallery undergoes CategoryFilterID or ManufacturerFilterID changes (Reza Moini)
            //1) This is determined in function shiekhGalleryCipher() in XSLTExtensionBase.cs
            //2) When the Gallery Filter is rendered, we add a "PaginationReset=1" to QueryString for all relevant links

var ajaxpageclass=new Object()
ajaxpageclass.loadstatustext="<img src='images/loading.gif' /> Requesting content, please wait..." // HTML to show while requested page is being fetched:
ajaxpageclass.ajaxbustcache=false // Bust cache when fetching pages?
ajaxpageclass.paginatepersist=true //enable persistence of last viewed pagination link (so reloading page doesn't reset page to 1)?
ajaxpageclass.pagerange=9 // Limit page links displayed to a specific number (useful if you have many pages in your book)?
ajaxpageclass.ellipse="..." // Ellipse text (no HTML allowed)

ajaxpageclass.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
}

ajaxpageclass.setCookie=function(name, value){
	document.cookie = name+"="+value
}

ajaxpageclass.getInitialPage=function(divId, pageinfo){
    /*-=-=-=-=-=- rezDefied -=-=-=-=-=-=-*/
	var persistedpage=this.getCookie(divId)
	
    var daQS = window.location.search;
    var selectedpage;
    if(!daQS){
        
        selectedpage = 0;
    }
    else{
        
        if(daQS.indexOf("PaginationReset=1") > 0){
            
            selectedpage = 0;
            ajaxpageclass.setCookie(this.divId, selectedpage)
        }
        else{
            
            selectedpage=(this.paginatepersist && this.getCookie(divId)!=null)? parseInt(this.getCookie(divId)) : pageinfo.selectedpage
        }
        
	}
	return (selectedpage>pageinfo.pages.length-1)? 0 : selectedpage //check that selectedpage isn't out of range
}

ajaxpageclass.createBook=function(pageinfo, divId, paginateIds){ //MAIN CONSTRUCTOR FUNCTION
	this.pageinfo=pageinfo //store object containing URLs of pages to fetch, selected page number etc
	this.divId=divId
	this.paginateIds=paginateIds //array of ids corresponding to the pagination DIVs defined for this pageinstance
	//NOTE: this.paginateInfo stores references to various components of each pagination DIV defined for this pageinstance
	//NOTE: Eg: divs[0] = 1st paginate div, pagelinks[0][0] = 1st page link within 1st paginate DIV, prevlink[0] = previous link within paginate DIV etc
	this.paginateInfo={divs:[], pagelinks:[[]], prevlink:[], nextlink:[], previouspage:null, previousrange:[null,null], leftellipse:[], rightellipse:[]}
	this.dopagerange=false
	this.pagerangestyle=''
	this.ellipse='<span style="display:none">'+ajaxpageclass.ellipse+'</span>' //construct HTML for ellipse
	var initialpage=ajaxpageclass.getInitialPage(divId, pageinfo)
	this.buildpagination(initialpage)
	this.selectpage(initialpage)
}

ajaxpageclass.createBook.prototype={

	buildpagination:function(selectedpage){ //build pagination links based on length of this.pageinfo.pages[]
		//this.dopagerange=(this.pageinfo.pages.length>ajaxpageclass.pagerange) //Bool: enable limitpagerange if pagerange value is less than total pages available
		//alert(this.pageinfo.pages.length);
		this.dopagerange=(this.pageinfo.pages.length > 0) //Bool: enable limitpagerange if pagerange value is less than total pages available
		this.pagerangestyle=this.dopagerange? 'style="display:none"' : '' //if limitpagerange enabled, hide pagination links when building them
		this.paginateInfo.previousrange=null //Set previousrange[start, finish] to null to start
		if (this.pageinfo.pages.length==0)
			return
		else if (this.pageinfo.pages.length==1)
			var paginateHTML="Page 1 of 1" //Pagination HTML to show when there's only 1 page (no pagination needed)
		else{ //construct paginate interface
			var paginateHTML='<div id="daPaginationControls" class="pagination"><ul>\n'
			if(this.pageinfo.pages[selectedpage-1]){
			    paginateHTML+='<li style="display:inline"><a HREF="' + this.pageinfo.pages[selectedpage-1] + '" rel="'+(selectedpage-1)+'">< previous</a></li>\n' //previous link HTML
			}
			else{
			    paginateHTML+='<li style="display:inline"><a onclick="return false;" rel="'+(selectedpage-1)+'"></a></li>\n' //previous link HTML
			}
			
			
			for (var i=0; i<this.pageinfo.pages.length; i++){
				var ellipses={left: (i==0? this.ellipse : ''), right: (i==this.pageinfo.pages.length-1? this.ellipse : '')} //if this is 1st or last page link, add ellipse next to them, hidden by default
				//-=-=- daRez: HREF Alteration
				//paginateHTML+='<li>'+ellipses.right+'<a href="#page'+(i+1)+'" rel="'+i+'" '+this.pagerangestyle+'>'+(i+1)+'</a>'+ellipses.left+'</li>\n'
				paginateHTML+='<li>'+ellipses.right+'<a href="'+ this.pageinfo.pages[i] +'" rel="'+i+'" '+this.pagerangestyle+'>'+(i+1)+'</a>'+ellipses.left+'</li>\n'
			}
			
			if(selectedpage < this.pageinfo.pages.length-1){
			    paginateHTML+='<li style="display:inline"><a HREF="' + this.pageinfo.pages[selectedpage+1] + '" rel="'+(selectedpage+1)+'">next ></a></li>\n' //next link HTML
			}
			else{
			    paginateHTML+='<li style="display:inline"><a onclick="return false;" rel="'+(selectedpage+1)+'"></a></li>\n' //previous link HTML
			}
			
			paginateHTML+='</ul></div>'
		}// end construction
		this.paginateInfo.previouspage=selectedpage //remember last viewed page
		for (var i=0; i<this.paginateIds.length; i++){ //loop through # of pagination DIVs specified
			var paginatediv=document.getElementById(this.paginateIds[i]) //reference pagination DIV
			this.paginateInfo.divs[i]=paginatediv //store ref to this paginate DIV
			paginatediv.innerHTML=paginateHTML
			var paginatelinks=paginatediv.getElementsByTagName("a")
			var ellipsespans=paginatediv.getElementsByTagName("span")
			this.paginateInfo.prevlink[i]=paginatelinks[0]
			this.paginateInfo.nextlink[i]=paginatelinks[paginatelinks.length-1]
			this.paginateInfo.leftellipse[i]=ellipsespans[0]
			this.paginateInfo.rightellipse[i]=ellipsespans[1]
			this.paginateInfo.pagelinks[i]=[] //array to store the page links of pagination DIV
			for (var p=1; p<paginatelinks.length-1; p++){
				this.paginateInfo.pagelinks[i][p-1]=paginatelinks[p]
			}
			var pageinstance=this
			paginatediv.onclick=function(e){
				var targetobj=window.event? window.event.srcElement : e.target
				if (targetobj.tagName=="A" && targetobj.getAttribute("rel")!=""){
					if (!/disabled/i.test(targetobj.className)){ //if this pagination link isn't disabled (CSS classname "disabled")
						pageinstance.selectpage(parseInt(targetobj.getAttribute("rel")))
					}
				}
				//-=-=-=- daRez
				//-=-=-=- DoDaClick!
				//return false
			}
		}
	},

	selectpage:function(selectedpage){
		//replace URL's root domain with dynamic root domain (with or without "www"), for ajax security sake:
		/*
		//-=-=-=- daRez: K1LL K0D3
		if (this.pageinfo.pages.length>0){
			var ajaxfriendlyurl=this.pageinfo.pages[selectedpage].replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
			ajaxpageclass.connect(ajaxfriendlyurl, this.divId) //fetch requested page and display it inside DIV
		}
		*/
		if (this.pageinfo.pages.length<=1){ //if this book only contains only 1 page (or 0)
			return //stop here
		}
		var paginateInfo=this.paginateInfo
		for (var i=0; i<paginateInfo.divs.length; i++){ //loop through # of pagination DIVs specified
			var paginatediv=document.getElementById(this.paginateIds[i])
			paginateInfo.prevlink[i].className=(selectedpage==0)? "prevnext disabled" : "prevnext" //if current page is 1st page, disable "prev" button
			paginateInfo.prevlink[i].setAttribute("rel", selectedpage-1) //update rel attr of "prev" button with page # to go to when clicked on
			paginateInfo.nextlink[i].className=(selectedpage==this.pageinfo.pages.length-1)? "prevnext disabled" : "prevnext"
			paginateInfo.nextlink[i].setAttribute("rel", selectedpage+1)
			paginateInfo.pagelinks[i][paginateInfo.previouspage].className="" //deselect last clicked on pagination link (previous)
			paginateInfo.pagelinks[i][selectedpage].className="currentpage" //select current pagination link
		}
		paginateInfo.previouspage=selectedpage //Update last viewed page info
		ajaxpageclass.setCookie(this.divId, selectedpage)
		this.limitpagerange(selectedpage) //limit range of page links displayed (if applicable)
	},
	
	limitpagerange:function(selectedpage){
		//reminder: selectedpage count starts at 0 (0=1st page)
		//-=-=-=- daRez: did you think you were clever? perhaps SMART? maybe w1z3?
		var paginateInfo=this.paginateInfo
		
		if (this.dopagerange){
			var visiblelinks=ajaxpageclass.pagerange-1 //# of visible page links other than currently selected link
			var visibleleftlinks=Math.floor(visiblelinks/2) //calculate # of visible links to the left of the selected page
			var visiblerightlinks=visibleleftlinks+(visiblelinks%2==1? 1 : 0) //calculate # of visible links to the right of the selected page
			if (selectedpage<visibleleftlinks){ //if not enough room to the left to accomodate all visible left links
				var overage=visibleleftlinks-selectedpage
				visibleleftlinks-=overage //remove overage links from visible left links
				visiblerightlinks+=overage //add overage links to the visible right links
			}
			else if ((this.pageinfo.pages.length-selectedpage-1)<visiblerightlinks){ //else if not enough room to the left to accomodate all visible right links
				var overage=visiblerightlinks-(this.pageinfo.pages.length-selectedpage-1)
				visiblerightlinks-=overage //remove overage links from visible right links
				visibleleftlinks+=overage //add overage links to the visible left links
			}
			var currentrange=[selectedpage-visibleleftlinks, selectedpage+visiblerightlinks] //calculate indices of visible pages to show: [startindex, endindex]
			var previousrange=paginateInfo.previousrange //retrieve previous page range
			for (var i=0; i<paginateInfo.divs.length; i++){ //loop through paginate divs
			
			    if (previousrange){ //if previous range is available (not null)
					for (var p=previousrange[0]; p<=previousrange[1]; p++){ //hide all page links
					    try{
					        paginateInfo.pagelinks[i][p].style.display="none"
					    }
					    catch(e){ }
					}
				}
				
				for (var p=currentrange[0]; p<=currentrange[1]; p++){ //reveal all active page links
				    try{
    				    paginateInfo.pagelinks[i][p].style.display="inline"
    				    
    					if(document.all){
    					    paginateInfo.pagelinks[i][p].parentElement.style.display="inline"
    					}
    					else{
    					    paginateInfo.pagelinks[i][p].parentNode.style.display="inline"
    					}
    				}
    				catch(e){ }
				}
				
				paginateInfo.pagelinks[i][0].style.display="inline" //always show 1st page link
				
				if(document.all){
				    
				    paginateInfo.pagelinks[i][0].parentElement.style.display="inline" //always show 1st page link
				}
				else{
				    
				    paginateInfo.pagelinks[i][0].parentNode.style.display="inline" //always show 1st page link
				}
				
				paginateInfo.pagelinks[i][this.pageinfo.pages.length-1].style.display="inline" //always show last page link
				
				if(document.all){
				    
				    paginateInfo.pagelinks[i][this.pageinfo.pages.length-1].parentElement.style.display="inline" //always show last page link
				}
				else{
				    
				    paginateInfo.pagelinks[i][this.pageinfo.pages.length-1].parentNode.style.display="inline" //always show last page link
				}
			    
				paginateInfo.leftellipse[i].style.display=(currentrange[0]>1)? "inline" : "none" //if starting page is page3 or higher, show ellipse to page1
				paginateInfo.rightellipse[i].style.display=(currentrange[1]<this.pageinfo.pages.length-2)? "inline" : "none" //if end page is 2 pages before last page or less, show ellipse to last page
			}
		}
			paginateInfo.previousrange=currentrange
	},
	
	refresh:function(pageinfo){
    	this.pageinfo=pageinfo
    	var initialpage=ajaxpageclass.getInitialPage(this.divId, pageinfo)
    	this.buildpagination(initialpage)
    	this.selectpage(initialpage)
	}

}
//-=-=-=- You would think this might be a working out of box widget =)_ N0T!!!
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- END AJAX PAGINATION MADDNESS! -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


function redifyDimension(daValue){
    
    daQS = location.href;
    
    var newDestination;
    
    var locationVSsearch = "?";
    if(daQS.indexOf("?") > 0){
        
        locationVSsearch = "&";
    }
    
    
    var qsRezolutionPattern = /(rezolution=)(\d+)/gi;
    if(qsRezolutionPattern.test(daQS)){
        
        newDestination = daQS.replace(qsRezolutionPattern, "$1" + daValue.value);
    }
    else{
        
        newDestination = daQS + locationVSsearch + "rezolution=" + daValue.value;
    }
    
    var daGallSize = "21";
    switch(daValue.value){
        case "2":
            
            daGallSize = "28";
            break;
        case "3":
            
            daGallSize = "35";
            break;
        case "4":
            
            daGallSize = "42";
            break;
    }
    
    var qsGallSizePattern = /(gallsize=)(\d+)/gi;
    if(qsGallSizePattern.test(daQS)){
        
        newDestination = newDestination.replace(qsGallSizePattern, "$1" + daGallSize);
    }
    else{
        
        newDestination += "&gallsize=" + daGallSize;
    }
    
    
    
    var qsPageNumPattern = /(pagenum=)(\d+)/gi;
    if(qsPageNumPattern.test(daQS)){
        
        newDestination = newDestination.replace(qsPageNumPattern, "$1" + "1");
    }
    
    document.location.href = newDestination;
}


function customRezolution(){
    
    var daLoke = location.href;
    
    var daRez = false;
    
    var daRezolutionT = document.getElementById("daRezolutionT");
    var daRezolutionB = document.getElementById("daRezolutionB");
    
    var qsRezPat = /rezolution=(\d+)/gi;
    
    if(qsRezPat.test(daLoke)){
        
        for(c=0; c < daRezolutionT.options.length; c++){
            
            if(daRezolutionT.options[c].value == RegExp.$1){
                
                daRezolutionT.options[c].selected = true;
                daRezolutionB.options[c].selected = true;
                daRez = true;
            }
        }
    }
    
    if(!daRez){
        
        daRezolutionT.options[0].selected = true;
    }
    
    
    var daPaginationControls = document.getElementById("daPaginationControls");
    if(!daPaginationControls){
        
        var daRezSelektor = document.getElementById("screenResolutionT");
        daRezSelektor.style.display = "none";
        daRezSelektor = document.getElementById("screenResolutionB");
        daRezSelektor.style.display = "none";
        daRezSelektor = document.getElementById("navSelectDescriptionT");
        daRezSelektor.style.display = "none";
        daRezSelektor = document.getElementById("navSelectDescriptionB");
        daRezSelektor.style.display = "none";
    }
}

function dBdR(){
    /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    -=-=-=-=-=-=-=-=-=-  Dynamic Browser Dimension Resolution -=-=-=-=-=-=-=-=-=-
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        HTML OBJECT ID'S CONTROLING PAGE DIMENSIONS
            # shiekhTopNav - default: 783
            # wrapper      - default: 783
            # content      - default: 650
            # footer       - default: 783
            # shiekhTN003  - default: 650
            # shiekhTN004  - default: 650
    */
    
    var daQS = location.search;
    
    if(daQS){
        
        var qsRezPat = /rezolution=(\d+)/gi;
        if(qsRezPat.test(daQS)){
            
            switch(RegExp.$1){
                case "2":
                    
                    dynamicDimensions("983px","983px","850px","983px","850px","850px");
                    break;
                case "3":
                    
                    dynamicDimensions("1183px","1183px","1050px","1183px","1050px","1050px");
                    break;
                case "4":
                    
                    dynamicDimensions("1383px","1383px","1250px","1383px","1250px","1250px");
                    break;
            }
        }
    }
}


function dynamicDimensions(a, b, c, d, e, f){ //-=-=-=- MUSIC 2 YOUR EARS
    
    //document.getElementById('shiekhTopNav').style.width = a;
    document.getElementById('wrapper').style.width = b;
    document.getElementById('content').style.width = c;
    document.getElementById('footer').style.width = d;
    //document.getElementById('shiekhTN003').style.width = e;
    //document.getElementById('shiekhTN004').style.width = f;
    
    document.getElementById('pcontent').style.width = f;
}


function galleryFilterControl(daSelect){
    
    switch(daSelect.name){
        
        case "type":
            
            if(daSelect.selectedIndex == 0){
                
                document.forms["FilterForm"].elements["style"].options[0].selected = true;
            }
            
            daRiveStyle(daSelect.options[daSelect.selectedIndex].value);
            break;
        case "style":
            
            daRiveType(daSelect.options[daSelect.selectedIndex].value);
            break;
        case "ManufacturerFilterID":
            
            document.FilterForm.submit();
            break;
    }
}


function galleryFilterControl(categoryID, currentControl, postBackURL){
    
    daNewDestination = postBackURL;
    
    switch(currentControl){
        
        case "typeSelection":
            
            daNewDestination += categoryID;
            break;
    }
    
    document.location.href = daNewDestination;
}


function daRiveStyle(daTypeID){
    
    //daCurrentStyleSelection = document.forms["FilterForm"].style;
    //alert(daCurrentStyleSelection.options[daCurrentStyleSelection.selectedIndex].value);
    //return false;
    
    /*
    daCurrentStyle = document.FilterForm.style.options[document.FilterForm.style.options.selectedIndex].value;
    if(parseInt(daCurrentStyle) > daTypeID){
        
        document.FilterForm.CategoryFilterID.value = daCurrentStyle;
    }
    else{
        
        document.FilterForm.CategoryFilterID.value = daTypeId;
    }
    //alert(document.FilterForm.CategoryFilterID.value);
    document.FilterForm.submit();
    //return false;
    
    if(daStyleID.options[daStyleID.selectedIndex].value ) document.FilterForm.CategoryFilterID.value = daTypeId;
    else document.FilterForm.CategoryFilterID.value = daTypeId;
    //document.FilterForm.CategoryFilterID.value += "," + daTypeId;
    document.FilterForm.submit();
    */
    
    
    document.FilterForm.CategoryFilterID.value = daTypeID;
    document.FilterForm.submit();
}


function daRiveType(daStyleId){
    
    daStyle = document.forms["FilterForm"].elements["style"];
    
    if(daStyle.selectedIndex == 0){
        
        daType = document.forms["FilterForm"].elements["type"];
        document.forms["FilterForm"].elements["CategoryFilterID"].value = daType.options[daType.selectedIndex].value;
    }
    else{
        
        document.FilterForm.CategoryFilterID.value = daStyleId;
    }
    
    document.FilterForm.submit();
}





//DaJamez-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- shiekh gallery filter related functions
function NavMenuType_MouseOut_Collapse(Type) {
    var type = '';
    if (Type == 1) {
        type = 'url(images/NewTemplatePics/nav-button_type.gif)';
    }
    else if (Type == 2) {
        type = 'url(images/NewTemplatePics/nav-button_style.gif)';
    }
    else if (Type == 3) {
        type = 'url(images/NewTemplatePics/nav-button_brand.gif)';
    }
    else if (Type == 4) {
        type = 'url(images/NewTemplatePics/nav-button_size.gif)';
    }
    else if (Type == 5) {
        type = 'url(images/NewTemplatePics/nav-button_color.gif)';
    }
    return type;
}
function NavMenuType_MouseOver_Expand(Type) {
    var type = '';
    if (Type == 1) {
        type = 'url(images/NewTemplatePics/nav-expanded_type.gif)';
    }
    else if (Type == 2) {
        type = 'url(images/NewTemplatePics/nav-expanded_style.gif)';
    }
    else if (Type == 3) {
        type = 'url(images/NewTemplatePics/nav-expanded_brand.gif)';
    }
    else if (Type == 4) {
        type = 'url(images/NewTemplatePics/nav-expanded_size.gif)';
    }
    else if (Type == 5) {
        type = 'url(images/NewTemplatePics/nav-expanded_color.gif)';
    }
    return type;

}
//=====================================================================
//=====================================================================
function expand1(s, m, Type) {
    var d = document.getElementById(m);
    var td = document.getElementById(s);
    var varType = '';

    varType = NavMenuType_MouseOver_Expand(Type);
    //td.src = varType;
    td.style.backgroundImage = varType;
    
    d.style.position = "absolute";
    d.style.visibility = "visible";
    d.style.display = "block";
}
function collapse1(s, m, Type) {
    var d = document.getElementById(m);
    var td = document.getElementById(s);
    var varType = '';

    varType = NavMenuType_MouseOut_Collapse(Type);
    //td.src = varType;
    td.style.backgroundImage = varType;
    
    d.style.position = "static";
    d.style.visibility = "hidden";
    d.style.display = "none";
}
//====================================================================
function expand2(s, m, Type) {
    var d = document.getElementById(m);
    var td = document.getElementById(s);
    var varType = '';

    varType = NavMenuType_MouseOver_Expand(Type);
    //td.src = varType;
    td.style.backgroundImage = varType;
    
    d.style.position = "absolute";
    d.style.visibility = "visible";
    d.style.display = "block";
}
function collapse2(s, m, Type) {
    var d = document.getElementById(m);
    var td = document.getElementById(s);
    var varType = '';
    
    varType = NavMenuType_MouseOut_Collapse(Type);
    //td.src = varType;
    td.style.backgroundImage = varType;
    
    d.style.position = "static";
    d.style.visibility = "hidden";
    d.style.display = "none";
}
//=====================================================================
function GallerySortByDropDown(daValue) {

    daQS = location.href;

    var newDestination;
    var locationVSsearch = "?";
    if (daQS.indexOf("?") > 0)
        locationVSsearch = "&";
        
    newDestination = daQS + locationVSsearch;
    
    var SortBy_Value = "";
    switch (daValue.value) {
        case "0":
            SortBy_Value = "0";
            break;
        case "7":
            SortBy_Value = "7";
            break;
        case "8":
            SortBy_Value = "8";
            break;
        case "9":
            SortBy_Value = "9";
            break;
        case "10":
            SortBy_Value = "10";
            break;
        case "11":
            SortBy_Value = "11";
            break;         
    }

    var qsSortByPattern = /(SortByValue=)(\d+)/gi;
    if (qsSortByPattern.test(daQS)) {

        newDestination = newDestination.replace(qsSortByPattern, "$1" + SortBy_Value);
    }
    else {

        newDestination += "SortByValue=" + SortBy_Value;
    }
    
    document.location.href = newDestination.replace("&&", "&");
}
//=====================================================================
function GalleryDisplayDropDown(daValue) {

    daQS = location.href;

    var newDestination;
    var locationVSsearch = "?";
    if (daQS.indexOf("?") > 0) {

        locationVSsearch = "&";
    }

    //var qsRezolutionPattern = /(rezolution=)(\d+)/gi;
    //if (qsRezolutionPattern.test(daQS))
    //    newDestination = daQS.replace(qsRezolutionPattern, "$1" + daValue.value);
    //else
    //    newDestination = daQS + locationVSsearch + "rezolution=" + daValue.value;
    
    newDestination = daQS + locationVSsearch;
    

    var daGallSize = "";
    switch (daValue.value) {

        case "24":
            daGallSize = "24";
            break;
        case "48":
            daGallSize = "48";
            break;
        case "72":
            daGallSize = "72";
            break;
    }

    var qsGallSizePattern = /(gallsize=)(\d+)/gi;
    if (qsGallSizePattern.test(daQS)) {

        newDestination = newDestination.replace(qsGallSizePattern, "$1" + daGallSize);
    }
    else {

        newDestination += "gallsize=" + daGallSize;
    }



    //var qsPageNumPattern = /(pagenum=)(\d+)/gi;
    //if (qsPageNumPattern.test(daQS)) {

    //    newDestination = newDestination.replace(qsPageNumPattern, "$1" + "1");
    //}

    document.location.href = newDestination.replace("&&", "&");
}

//Shiekh gallery page - display drop down, load selected value function.
//function SetOptionsValue() {
//    var name = gup('gallsize');
//    var str_LocationHref = new Array();
//    if (location.href.search("gallsize") != -1)
//       document.getElementById('GalleryDisplayDropDown_Select1').value = name;
//}
//REGULAR EXPRESSION FUNCTION.
//function gup(name) {
//    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
//    var regexS = "[\\?&]" + name + "=([^&#]*)";
//    var regex = new RegExp(regexS);
//    var results = regex.exec(window.location.href);
//    if (results == null)
//        return name;
//    else
//        return results[1];
//}
//=====================================================================

function daShiekh(){
   
    var divh = document.getElementById('bodyWrapper');
    
    //alert("divh = " + divh.offsetHeight + "px");

    if (divh.offsetHeight < 625) {
        divh.style.height = '625px';

        //Commented out because these two conditions are used for gallery page only.
        //Now we need for more than one page for displaying white background content.
        //if (location.href.indexOf("?") > 0)
        //if (location.href.indexOf("c-") > 0)
        
        divh.style.backgroundImage = "url(skins/skin_2/images/background-middle_whiteColor.gif)";
	
    }
}
