﻿

var req;

function getAbsX(elt) { return (elt.x) ? elt.x : getAbsPos(elt,"Left"); }

function getAbsY(elt) { return (elt.y) ? elt.y : getAbsPos(elt,"Top"); }

function getAbsPos(elt,which) {

 iPos = 0;

 while (elt != null) {

  iPos += elt["offset" + which];

  elt = elt.offsetParent;

 }

 return iPos;

}

function ajaxRequest(p_Form,p_isXml,p_submitMethod,p_parameters,p_url,p_targetDiv) {

    

//    alert(p_Form);

//    alert(p_isXml);

//    alert(p_submitMethod);

    //alert("parameters"+p_parameters);

   // alert("URL:"+p_url);

   // alert("targetdiv:"+p_targetDiv); 

   

   //code starts for loading panel  

     var div=document.getElementById(p_targetDiv);

    var newdiv = document.createElement('div');

    var divIdName = 'divImage';

    

      newdiv.setAttribute('id',divIdName);

    newdiv.style.width =div.offsetWidth+"px";//div.offsetWidth;// "100px";

    newdiv.style.height =div.offsetHeight+"px";//div.offsetHeight;// "100px";

    newdiv.style.left =getAbsX(div)+"px";// "100px";

    newdiv.style.top = getAbsY(div)+"px";//div.offsetTop-div.offsetHeight;//"100px";

    newdiv.style.position = "absolute";

    newdiv.style.background = "#FFFFFF";

    newdiv.style.zIndex="999"; 

    newdiv.style.filter="alpha(opacity=80)";     

    newdiv.style.mozOpacity="0.80";     

    newdiv.style.khtmlOpacity="0.80";     

    newdiv.style.opacity="0.80";     

    newdiv.innerHTML = "<img src='images/loading3.gif' alt='loading' />";

    div.appendChild(newdiv);

    //code ends here

    

    

    //document.getElementById(p_targetDiv).innerHTML = 'loading data...';

  

    if(p_Form == null) {

  

    if (window.XMLHttpRequest) {

        req = new XMLHttpRequest();

        req.onreadystatechange = function() {ajaxResponse(p_targetDiv);};

   

      //mozilla post

      if(p_submitMethod=="POST") {

       p_url=p_url + "?" + createTimestamp();

       req.open("POST", p_url, true);

       req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

        if (p_isXml)

        {

            req.setRequestHeader("Content-Type", "text/xml");

        }

       req.send(p_parameters);

      }

      //mozilla get

      else {

        var ampersand = "&";

        if (p_parameters == "") ampersand = "";

        p_url=p_url + "?" + p_parameters + ampersand + createTimestamp();

        req.open("GET", p_url, true);

        if (p_isXml)

        {try{

            req.overrideMimeType('text/xml');

            }

            catch(e)

            {}

        }

        req.send(null);

        }

        

    } else if (window.ActiveXObject) {

        req = new ActiveXObject("Microsoft.XMLHTTP");

        if (req) {

            req.onreadystatechange = function() {ajaxResponse(p_targetDiv);};

        //windows post    

       if(p_submitMethod=="POST") {

        p_url=p_url + "?" + createTimestamp();

       req.open("POST", p_url, true);

       req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

        if (p_isXml)

        {

            req.setRequestHeader("Content-Type", "text/xml");

        }

       req.send(p_parameters);

      }

      //windows get

      else {

        var ampersand = "&";

        if (p_parameters == "") ampersand = "";

        p_url=p_url + "?" + p_parameters + ampersand + createTimestamp();

          req.open("GET", p_url, true);

           if (p_isXml){

            req.setRequestHeader("Content-Type", "text/xml");

          }

          req.send();

        }

          

        }

       

       }

       }

       //form handling start

       else {

       

        formObject = p_Form;

            p_url = formObject.action;

        p_submitMethod = formObject.method;

        

        //alert(p_submitMethod);

        //alert(p_url);

            var data = "";

            for (i = 0; i < formObject.elements.length; i++){

                if (formObject.elements[i].type != "submit" || formObject.elements[i].type != "button"){

                    if(i==formObject.elements.length-1) {

                     p_parameters += (formObject.elements[i].name + "=" + formObject.elements[i].value) + "";

              

                    }

                    else {

                    p_parameters += (formObject.elements[i].name + "=" + formObject.elements[i].value) + "&";

                    }

                }

            }

          

          //form posting start

            if (window.XMLHttpRequest) {

        req = new XMLHttpRequest();

        req.onreadystatechange = function() {ajaxResponse(p_targetDiv);};

   

      //mozilla post

      if(p_submitMethod=="POST") {

       p_url=p_url + "?" + createTimestamp();

       req.open("POST", p_url, true);

       req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

        if (p_isXml)

        {

            req.setRequestHeader("Content-Type", "text/xml");

        }

       req.send(p_parameters);

      }

      //mozilla get

      else {

        var ampersand = "&";

        if (p_parameters == "") ampersand = "";

        p_url=p_url + "?" + p_parameters + ampersand + createTimestamp();

        req.open("GET", p_url, true);

        if (p_isXml)

        {

            req.overrideMimeType('text/xml');

         

        }

        req.send(null);

        }

        

    } else if (window.ActiveXObject) {

        req = new ActiveXObject("Microsoft.XMLHTTP");

        if (req) {

            req.onreadystatechange = function() {ajaxResponse(p_targetDiv);};

        //windows post    

       if(p_submitMethod=="POST") {

        p_url=p_url + "?" + createTimestamp();

       req.open("POST", p_url, true);

       req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

        if (p_isXml)

        {

            req.setRequestHeader("Content-Type", "text/xml");

        }

       req.send(p_parameters);

      }

      //windows get

      else {

        var ampersand = "&";

        if (p_parameters == "") ampersand = "";

        p_url=p_url + "?" + p_parameters + ampersand + createTimestamp();

          req.open("GET", p_url, true);

           if (p_isXml){

            req.setRequestHeader("Content-Type", "text/xml");

          }

          req.send();

        }

          

        }

          

          //form posting end

          

            }

       

       } 

        //form handling end

 

} 





function ajaxResponse(p_targetDiv) {

   // only if req is "loaded"

  

   if (req.readyState == 4) {

       // only if "OK"

       

       if (req.status == 200 || req.status == 304) {

           results = req.responseText;

          //alert(results);

          intStartRating();

           document.getElementById(p_targetDiv).innerHTML = results;

           

           $.fn.rating.options = { //$.extend($.fn.rating, { options: {

            cancel: 'Cancel Rating',   // advisory title for the 'cancel' link

            cancelValue: '',           // value to submit when user click the 'cancel' link

            split: 0,                  // split the star into how many parts?

            

            // Width of star image in case the plugin can't work it out. This can happen if

            // the jQuery.dimensions plugin is not available OR the image is hidden at installation

            starWidth: 18//,

            

            //NB.: These don't need to be pre-defined (can be undefined/null) so let's save some code!

            //half:     false,         // just a shortcut to control.split = 2

            //required: false,         // disables the 'cancel' button so user can only select one of the specified values

            //readOnly: false,         // disable rating plugin interaction/ values cannot be changed

            //focus:    function(){},  // executed when stars are focused

            //blur:     function(){},  // executed when stars are focused

            //callback: function(){},  // executed when a star is clicked

 }; //} });

    /*--------------------------------------------------------*/

    /*

        ### Default implementation ###

        The plugin will attach itself to file inputs

        with the class 'multi' when the page loads

    */

    $(function(){ $('input[type=radio].star').rating(); });

         //  $('.jqzoom').jqzoom();

       } else {

            //alert(req.status);

             //alert(req.statusText);             

           document.getElementById(p_targetDiv).innerHTML="Please Try Again:\n" +req.status;

           



              //alert(req.statusText);

       }

   }

}

// Function to register Star Rating

function intStartRating()

{

//Start scripts for rating @@@@@@@@@@

/*

 ### jQuery Star Rating Plugin v3.10 - 2009-03-23 ###

 * Home: http://www.fyneworks.com/jquery/star-rating/

 * Code: http://code.google.com/p/jquery-star-rating-plugin/

 *

    * Dual licensed under the MIT and GPL licenses:

 *   http://www.opensource.org/licenses/mit-license.php

 *   http://www.gnu.org/licenses/gpl.html

 ###

*/



/*# AVOID COLLISIONS #*/

;if(window.jQuery) (function($){

/*# AVOID COLLISIONS #*/

    

    // IE6 Background Image Fix

    if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e) { }

    // Thanks to http://www.visualjquery.com/rating/rating_redux.html

    

    // plugin initialization

    $.fn.rating = function(options){

        if(this.length==0) return this; // quick fail

        

        // Handle API methods

        if(typeof arguments[0]=='string'){

            // Perform API methods on individual elements

            if(this.length>1){

                var args = arguments;

                return this.each(function(){

                    $.fn.rating.apply($(this), args);

    });

            };

            // Invoke API method handler

            $.fn.rating[arguments[0]].apply(this, $.makeArray(arguments).slice(1) || []);

            // Quick exit...

            return this;

        };

        

        // Initialize options for this call

        var options = $.extend(

            {}/* new object */,

            $.fn.rating.options/* default options */,

            options || {} /* just-in-time options */

        );

        

        // loop through each matched element

        this

         .not('.star-rating-applied')

            .addClass('star-rating-applied')

        .each(function(){

            

            // Load control parameters / find context / etc

            var eid = (this.name || 'unnamed-rating').replace(/\[|\]+/g, "_");

            var context = $(this.form || document.body);

            var input = $(this);

            var raters = context.data('rating') || { count:0 };

            var rater = raters[eid];

            var control;

            

            // if rater is available, verify that the control still exists

            if(rater) control = rater.data('rating');

            

            if(rater && control){

                // add star to control if rater is available and the same control still exists

                control.count++;

                

            }

            else{

                // create new control if first star or control element was removed/replaced

                

                // Initialize options for this raters

                control = $.extend(

                    {}/* new object */,

                    options || {} /* current call options */,

                    ($.metadata? input.metadata(): ($.meta?input.data():null)) || {}, /* metadata options */

                    { count:0, stars: [], inputs: [] }

                );

                

                // increment number of rating controls

                control.serial = raters.count++;

                

                // create rating element

                rater = $('<span class="star-rating-control"/>');

                input.before(rater);

                

                // Mark element for initialization (once all stars are ready)

                rater.addClass('rating-to-be-drawn');

                

                // Accept readOnly setting from 'disabled' property

                if(input.attr('disabled')) control.readOnly = true;

                

                // Create 'cancel' button

                rater.append(

                    control.cancel = $('<div class="rating-cancel"><a title="' + control.cancel + '">' + control.cancelValue + '</a></div>')

                    .mouseover(function(){

                        $(this).rating('drain');

                        $(this).addClass('star-rating-hover');

                        //$(this).rating('focus');

                    })

                    .mouseout(function(){

                        $(this).rating('draw');

                        $(this).removeClass('star-rating-hover');

                        //$(this).rating('blur');

                    })

                    .click(function(){

                     $(this).rating('select');

                    })

                    .data('rating', control)

                );

                

            }; // first element of group

            

            // insert rating star

            var star = $('<div class="star-rating rater-'+ control.serial +'"><a title="' + (this.title || this.value) + '">' + this.value + '</a></div>');

            rater.append(star);

            

            // inherit attributes from input element

            if(this.id) star.attr('id', this.id);

            if(this.className) star.addClass(this.className);

            

            // Half-stars?

            if(control.half) control.split = 2;

            

            // Prepare division control

            if(typeof control.split=='number' && control.split>0){

                var stw = ($.fn.width ? star.width() : 0) || control.starWidth;

                var spi = (control.count % control.split), spw = Math.floor(stw/control.split);

                star

                // restrict star's width and hide overflow (already in CSS)

                .width(spw)

                // move the star left by using a negative margin

                // this is work-around to IE's stupid box model (position:relative doesn't work)

                .find('a').css({ 'margin-left':'-'+ (spi*spw) +'px' })

            };

            

            // readOnly?

            if(control.readOnly)//{ //save a byte!

                // Mark star as readOnly so user can customize display

                star.addClass('star-rating-readonly');

            //}  //save a byte!

            else//{ //save a byte!

             // Enable hover css effects

                star.addClass('star-rating-live')

                 // Attach mouse events

                    .mouseover(function(){

                        $(this).rating('fill');

                        $(this).rating('focus');

                    })

                    .mouseout(function(){

                        $(this).rating('draw');

                        $(this).rating('blur');

                    })

                    .click(function(){

                        $(this).rating('select');

                    })

                ;

            //}; //save a byte!

            

            // set current selection

            if(this.checked)    control.current = star;

            

            // hide input element

            input.hide();

            

            // backward compatibility, form element to plugin

            input.change(function(){

    $(this).rating('select');

   });

            

            // attach reference to star to input element and vice-versa

            star.data('rating.input', input.data('rating.star', star));

            

            // store control information in form (or body when form not available)

            control.stars[control.stars.length] = star[0];

            control.inputs[control.inputs.length] = input[0];

            control.rater = raters[eid] = rater;

            control.context = context;

            

            input.data('rating', control);

            rater.data('rating', control);

            star.data('rating', control);

            context.data('rating', raters);

  }); // each element

        

        // Initialize ratings (first draw)

        $('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn');

        

        return this; // don't break the chain...

    };

    

    /*--------------------------------------------------------*/

    

    /*

        ### Core functionality and API ###

    */

    $.extend($.fn.rating, {

        

        focus: function(){

            var control = this.data('rating'); if(!control) return this;

            if(!control.focus) return this; // quick fail if not required

            // find data for event

            var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );

   // focus handler, as requested by focusdigital.co.uk

            if(control.focus) control.focus.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);

        }, // $.fn.rating.focus

        

        blur: function(){

            var control = this.data('rating'); if(!control) return this;

            if(!control.blur) return this; // quick fail if not required

            // find data for event

            var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );

   // blur handler, as requested by focusdigital.co.uk

            if(control.blur) control.blur.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);

        }, // $.fn.rating.blur

        

        fill: function(){ // fill to the current mouse position.

            var control = this.data('rating'); if(!control) return this;

            // do not execute when control is in read-only mode

            if(control.readOnly) return;

            // Reset all stars and highlight them up to this element

            this.rating('drain');

            this.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-hover');

        },// $.fn.rating.fill

        

        drain: function() { // drain all the stars.

            var control = this.data('rating'); if(!control) return this;

            // do not execute when control is in read-only mode

            if(control.readOnly) return;

            // Reset all stars

            control.rater.children().filter('.rater-'+ control.serial).removeClass('star-rating-on').removeClass('star-rating-hover');

        },// $.fn.rating.drain

        

        draw: function(){ // set value and stars to reflect current selection

            var control = this.data('rating'); if(!control) return this;

            // Clear all stars

            this.rating('drain');

            // Set control value

            if(control.current){

                control.current.data('rating.input').attr('checked','checked');

                control.current.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-on');

            }

            else

             $(control.inputs).removeAttr('checked');

            // Show/hide 'cancel' button

            control.cancel[control.readOnly || control.required?'hide':'show']();

            // Add/remove read-only classes to remove hand pointer

            this.siblings()[control.readOnly?'addClass':'removeClass']('star-rating-readonly');

        },// $.fn.rating.draw

        

        select: function(value){ // select a value

            var control = this.data('rating'); if(!control) return this;

            // do not execute when control is in read-only mode

            if(control.readOnly) return;

            // clear selection

            control.current = null;

            // programmatically (based on user input)

            if(typeof value!='undefined'){

             // select by index (0 based)

                if(typeof value=='number')

             return $(control.stars[value]).rating('select');

                // select by literal value (must be passed as a string

                if(typeof value=='string')

                    //return 

                    $.each(control.stars, function(){

                        if($(this).data('rating.input').val()==value) $(this).rating('select');

                    });

            }

            else

                control.current = this[0].tagName=='INPUT' ? 

                 this.data('rating.star') : 

                    (this.is('.rater-'+ control.serial) ? this : null);

            

            // Update rating control state

            this.data('rating', control);

            // Update display

            this.rating('draw');

            // find data for event

            var input = $( control.current ? control.current.data('rating.input') : null );

            // click callback, as requested here: http://plugins.jquery.com/node/1655

            if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event

        },// $.fn.rating.select

        

        readOnly: function(toggle, disable){ // make the control read-only (still submits value)

            var control = this.data('rating'); if(!control) return this;

            // setread-only status

            control.readOnly = toggle || toggle==undefined ? true : false;

            // enable/disable control value submission

            if(disable) $(control.inputs).attr("disabled", "disabled");

            else                $(control.inputs).removeAttr("disabled");

            // Update rating control state

            this.data('rating', control);

            // Update display

            this.rating('draw');

        },// $.fn.rating.readOnly

        

        disable: function(){ // make read-only and never submit value

            this.rating('readOnly', true, true);

        },// $.fn.rating.disable

        

        enable: function(){ // make read/write and submit value

            this.rating('readOnly', false, false);

        }// $.fn.rating.select

        

 });

    

    /*--------------------------------------------------------*/

    

    /*

        ### Default Settings ###

        eg.: You can override default control like this:

        $.fn.rating.options.cancel = 'Clear';

    */

    $.fn.rating.options = { //$.extend($.fn.rating, { options: {

            cancel: 'Cancel Rating',   // advisory title for the 'cancel' link

            cancelValue: '',           // value to submit when user click the 'cancel' link

            split: 0,                  // split the star into how many parts?

            

            // Width of star image in case the plugin can't work it out. This can happen if

            // the jQuery.dimensions plugin is not available OR the image is hidden at installation

            starWidth: 18//,

            

            //NB.: These don't need to be pre-defined (can be undefined/null) so let's save some code!

            //half:     false,         // just a shortcut to control.split = 2

            //required: false,         // disables the 'cancel' button so user can only select one of the specified values

            //readOnly: false,         // disable rating plugin interaction/ values cannot be changed

            //focus:    function(){},  // executed when stars are focused

            //blur:     function(){},  // executed when stars are focused

            //callback: function(){},  // executed when a star is clicked

 }; //} });

    /*--------------------------------------------------------*/

    /*

        ### Default implementation ###

        The plugin will attach itself to file inputs

        with the class 'multi' when the page loads

    */

    $(function(){ $('input[type=radio].star').rating(); });

    

    /*# AVOID COLLISIONS #*/

})(jQuery);

/*# AVOID COLLISIONS #*/



//End scripts for rating @@@@@@@@@@



}

//End Function to register Star Rating



// Creates a timestamp for querystring.

    function createTimestamp()

    {

        return "timestamp=" + new Date().getTime().toString();

    }





// for paging



function makePOSTRequest(url, parameters) {

      

      http_request = false;

      if (window.XMLHttpRequest) { // Mozilla, Safari,...

         http_request = new XMLHttpRequest();

         if (http_request.overrideMimeType) {

            // set type accordingly to anticipated content type

            //http_request.overrideMimeType('text/xml');

            http_request.overrideMimeType('text/html');

         }

      } else if (window.ActiveXObject) { // IE

         try {

            http_request = new ActiveXObject("Msxml2.XMLHTTP");

         } catch (e) {

            try {

               http_request = new ActiveXObject("Microsoft.XMLHTTP");

            } catch (e) {}

         }

      }

      if (!http_request) {

         alert('Cannot create XMLHTTP instance');

         return false;

      }

      

      http_request.onreadystatechange = alertContents;

      http_request.open('POST', url, true);

      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

      http_request.setRequestHeader("Content-length", parameters.length);

      http_request.setRequestHeader("Connection", "close");

      http_request.send(parameters);

   }







   function alertContents() {

      if (http_request.readyState == 4) {

         if (http_request.status == 200) {

            //alert(http_request.responseText);

            result = http_request.responseText;

            //alert(result);

            document.getElementById('myspan').innerHTML = result;            

         } else {

            //alert(http_request.responseText);

            //alert('There was a problem with the request.');

         }

      }

   }

   function setTagSearchTrack(topicname,tagName,application) {

   

     var xhr; 

      try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }

    catch (e) 

    {

        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }

        catch (e2) 

        {

          try {  xhr = new XMLHttpRequest();     }

          catch (e3) {  xhr = false;   }

        }

     }

  

     xhr.onreadystatechange  = function()

    { 

         if(xhr.readyState  == 4)

         {

             //for testing

             // if(xhr.status  == 200) 

             // alert(xhr.responseText);

             // else 

             // alert(xhr.status);

         }

    }; 

   xhr.open("GET", "code_setBanner.aspx?Random=" + Math.random() + "&topicname=" + topicname + "&tagname=" + tagName + "&application=" + application  ,  true); 

   xhr.send(null); 

}


